Posts

Showing posts from July, 2014

c# - Should I re-use a Struct? -

i know structs value types , live on stack, unless declared field in reference type, , contain values in memory @ location. i'm wondering whether or not efficient or worthwhile re-use declared struct in iterated loop rather creating new 1 each time. how costly stack instantiate variables, if @ all? also, related question, if instantiate struct inside method call create local copy of struct or create first parameter of method when executes? about declarations: // worth doing... mystruct ms = new mystruct(0); (int = 0; i< 10000; i++) { ms.num = i; // ms } // ...over this: (int = 0; i< 10000; i++) { mystruct ms = new mystruct(i); // ms } public struct mystruct { public int num; public mystruct(int mynum) { num = mynum; } } and instantiation: for (int = 0; i< 10000; i++) { mymethod(new mystruct(i)); // mystruct live in scope? }

java - How to get long from byte array returned by jmrtd's sendGetChallenge (used to get passport random number) -

i'm using jmrtd library on android , process passport information. the first step send challenge passport responds random 64 bit number byte array (8 bytes). the function sendgetchallenge returns byte array. i need print out byte array number make analysis i'm having trouble converting byte array returned long, because i'm not sure if array big endian or little endian. so far i've used following methods: public static long bytearraytolong(byte[] bytes){ long value = 0; value += (long) (bytes[7] & 0x000000ff) << 56; value += (long) (bytes[6] & 0x000000ff) << 48; value += (long) (bytes[5] & 0x000000ff) << 40; value += (long) (bytes[4] & 0x000000ff) << 32; value += (bytes[3] & 0x000000ff) << 24; value += (bytes[2] & 0x000000ff) << 16; value += (bytes[1] & 0x000000ff) << 8; value += (bytes[0] & 0x000000ff); return value; } or private long bytea

iphone - Not able to display anything on table view Swift -

this history view, have tableview inside view controller. reason can't output anything, trying hardcode , not displaying @ all. 1 thing know need make tableview functions override , if error. import uikit class history: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { @iboutlet var tableview: uitableview! override func viewdidload() { super.viewdidload() tableview.delegate = self tableview.datasource = self self.view.backgroundcolor = uicolor(patternimage: uiimage(named: "newbackground.jpg")!) } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return 1 } func numberofsectionsintableview(tableview: uitableview) -> int { return 1 } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("h

java - I want the full verision of my website to appear in mobile browsers -

how can make without scaling down? want people have zoom in. possible? website not mobile friendly atm :( as long don't include viewport meta tag, you'll experience you're looking for.

html - SVG Path Clipping issue in Chrome -

Image
i'm experience clipping issue seems affect chrome not firefox. firefox: chrome: this svg tag definitions: <svg width="0" height="0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <g> <clippath id="c3"> <polygon points="64.405,221.5 1.207,111.5 64.405,1.5 190.802,1.5 254,111.5 190.802,221.5"/> </clippath> </g> <defs> <g id="fullhex"> <polyline points="64.405,221.5 1.207,111.5 64.405,1.5 190.802,1.5 254,111.5 190.802,221.5 64.405,221.5" style="fill:none; stroke:rgba(60,158,194,.9); stroke-width:10" /> </g> </defs> </svg> this html hexagon containers: <div id="heximagecontainer"> <div id="profileimg1container" class="profileimgcontainer&quo

php - Maximum function nesting level in Yii -

i know there duplicates question, tried of them, none of them worked. @ last commented out zend_extension in php.ini, browser keeps on processing endlessly. what have i'm calling simple widget view echo \sintret\chat\chatroom::widget([ 'url' => \yii\helpers\url::to(['/site/send-chat']), 'usermodel'=> \common\models\user::classname(), 'userfield' => 'avatarimage' ]); in controller: public function actionsendchat() { if (!empty($_post)) { echo \sintret\chat\chatroom::sendchat($_post); } } here github link chatroom.php contains main widget, has 2 main functions init() , run(). sendchat calling in our controller. any thoughts resolve error welcome.

Swift Property Encapsulation -

i'm wondering "standard" way of declaring property in swift is. in particular, seems of apple's swift example code doesn't encapsulate properties (you can freely , set property without having go through getter , setter methods). (i'm used java have trouble believing that's how apple expects developers write code.) right now, have: private var x: int private var xlistener: xlistener? public func getx() -> int { return x } public func setx(newvalue: int) { x = newvalue if (let listener = xlistener) { listener.onxset(x) } } but feel there must simpler way this. saw mention of computed properties seems don't store value, use them you'd have do: private storedx: int public var x: int { { return storedx } set { storedx = newvalue } didset { if (let listener = xlistener) { listener.onxset(storedx) } } } i have trouble believing either of these meth

javascript - Jquery.ajax requesting a 'Get' to Web API 2 backend is not working -

i have web api 2 project, , trying write front-end jquery. having issues, , quite frankly, confusing behaviors, when trying user (login). backend: using system; using system.collections.generic; using system.data; using system.data.entity; using system.data.entity.infrastructure; using system.linq; using system.net; using system.net.http; using system.threading.tasks; using system.web.http; using system.web.http.description; using angularjswebapiempty.models; using system.web.script.serialization; namespace angularjswebapiempty.controllers { public class artistscontroller : apicontroller { private bandioappentities db = new bandioappentities(); public artistscontroller() { db.configuration.proxycreationenabled = false; } // get: api/artists public iqueryable<artist> getartists() { return db.artists; } // get: api/artists/5 [responsetype(typeof(artist))] public artist get(string username, string password)

Prolog more than one argument or a list as a comparison for a query? -

i'm new prolog , struggling queries. want allow user input number of arguments query. right can work 1 argument aminofor(x) :- aminoname(x,_,z), aminoclass(z,'hydropathy',a), print('hydropathy'), print(a). with if enter valid input x , it'll output 'hydropathy' , value of a . however, want make enter multiple inputs x , have give me hydropathy . e.g. right if enter aminofor(g) . tell me hydropathy neutral if enter aminofor(g,h) . error: undefined procedure: aminofor/2 error: however, there definitions for: error: aminofor/1 false. how solve this, apologies in advance problem explanation appreciated.

javascript - Add each image to text area on click -

i able answer original question here , had change way doing , not working. changed too: foreach ($image_data $key => $row) { //print_r($row); echo '<div class="item image-link" id="img_link" onclick="myfunction()"> <img src="'.$row['s3_link'].'" class="img-responsive img-post" /> <div class="after"> <span class="zoom"> <i class="fa fa-check text-success"></i> </span> </div> </div>'; } this 1 of many different ways have tried it: function myfunction() { var $this = $('.image-link'); var myimg = document.getelementsbyclassname('img-post')[0]; var mysrc = '<div class="col-xs-3 col-

java - How can I make a link redirect to a servlet? -

this question has answer here: call servlet on click of hyperlink 4 answers i have html file following link: <li><a class="active" href="personalinfooutput.java">view personal information</a></li> when clicks on "view personal information", want redirect servlet, why put: href="personalinfooutput.java but not working. returning: http status 404 - /payroll/personalinfooutput.java here personalinfooutput.java servlet import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class personalinfooutput extends httpservlet { protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html;charset=utf-8"); printwriter out = response

unix - Slow, word-by-word terminal printing in Python? -

this question has answer here: how print 1 character @ time on 1 line? 3 answers i'm writing python app involving database. hell of it, i'm including easter egg. if user decides nuke database, terminal, he'll prompted confirm simple (y/n). if types dlg2209tvx instead, lines scene of wargames print. doubt ever find unless through source, that's okay. the problem printing lines plays scene way fast , ruins it. implemented timer between each character's lines slow things down, , it's better, still seems unnatural. there standardized way print each word or character out instead of doing lines @ time? or should start adding timers between words? standardized? not know of. try this: import random import sys import time def slowprint(s): c in s + '\n': sys.stdout.write(c) sys.stdout.flush() # defeat bufferi

html - AngularJS ng-repeat in div tag issue -

Image
i can't able loop array in div tag. my javascript source code is <script type="text/javascript"> var app = angular.module('drag-and-drop', ['ngdragdrop']); app.controller('onectrl', function($scope, $timeout) { $scope.list1 = []; $scope.list2 = []; $scope.list3 = []; $scope.list4 = []; $scope.list5 = [ { 'title': 'item 1', 'drag': true }, { 'title': 'item 2', 'drag': true }, { 'title': 'item 3', 'drag': true }, { 'title': 'item 4', 'drag': true }, { 'title': 'item 5', 'drag': true }, { 'title': 'item 6', 'drag': true }, { 'title': 'item 7', 'drag': true }, { 'title': 'item 8', 'drag': true } ]; //

javascript - ngrepeat Edit in line with form -

Image
i trying allow renaming of item in line. aware of using $scope.editmode etc, realized when use ng-repeats getting of entries in list edditable rather specific index. here have in html: <li ng-repeat="playlist in myplaylist"> <a href="" data-ng-hide="editplaylist">{{playlist.name}}</a> <form data-ng-show="editplaylist" data-ng-submit="renameplaylist()"> <input data-ng-model="editableplaylistname"> </form> </li> my controller uses context menu setting so: $scope.editplaylist =false; $scope.menuoptions = [ ['rename', function ($itemscope) { $scope.editplaylist = true; $scope.editableplaylistname = $itemscope.playlist.name; }] etc. when want rename, setting hide , shows true/false accordingly, issue of items in list true resulting number of input fields each item. how go around show input field corresp

nginx - Lumen in a subfolder trailing slashes issue -

in public/index.php have changed $app->run() $app->run($app['request']) , resulted in lumen working in sub-folder, works: http://local.dev/app/ http://local.dev/app/test however if there's slash @ end of route notfoundhttpexception . example: http://local.dev/app/test/ i'm using nginx , rewrite rule folder is: location /app/ { try_files $uri $uri/ /app/index.php?$query_string; } am doing wrong?

php - MagicSuggest dependent multiple dropdowns not working -

i using magicsuggest custom dropdown, have 2 dropdowns category , sub category.. sub categories should populated based on category selection. when select category, , subcategory, work first time, if change category sub categories not change , shows same list. here jquery.. var cat = $('#category').magicsuggest({ maxselection:1, data: site+'project/getcats/', valuefield: 'id', displayfield: 'title', mode: 'remote', renderer: function(data){ return '<div>' + '<div class="title">' + data.title + '</div>' + '</div>'; }, resultasstring: true, selectionrenderer: function(data){ return '<div class="name">' + data.title + '</div>'; } }); $(cat).bind('selectionchange', function(event, combo, selection){ cat_id = cat.getvalue(); src = site+'proje

javascript - Mootools getElements("input[type=radio]") returns Object not Array -

can shed light why getelements("input[type=radio]") or getelements("input[name=radioname]") return object rather array specified in docs? in case, not returning objects, key value index string ("0", "1"...) , last value of key "length" , value of int n. any ideas? which documentation referring to? according : http://mootools.net/docs/core/element/element#element:getelements , return array. and way describe object, looks array me.

ios - Drawing on an image causes the photo to expand -

hi build in app allow users use finger draw line on top of image, issue when user touches screen start drawing images expands make image distorted. here code of viewcontroller: update: code updated try use second image view suggestion maile import uikit import mobilecoreservices class newautographviewcontroler: uiviewcontroller, uinavigationcontrollerdelegate, uiimagepickercontrollerdelegate, uigesturerecognizerdelegate {          var signeditmode: bool = false          @iboutlet var btnedit: uibarbuttonitem!     @iboutlet var textfieldalbum: uitextfield!     @iboutlet var imageview: uiimageview!          @iboutlet var signimageview: uiimageview!     @ibaction func btnbackclick(sender: anyobject) {         self.navigationcontroller?.popviewcontrolleranimated(true)              }          @ibaction func btneditclick(sender: anyobject) {         if signeditmode {             signeditmode = false             signimageview.backgroundcolor = nil             btnedit.title = &qu

php - method not found laravel model -

i have 2 model, jadwalterapisklinik , pesertaklinik. i try call data using code : $data = jadwalterapisklinik::wherehas('pesertaklinik', function($q){ $q->wherehas('timecontrolling', function($qq){ $qq->where('status', 'done'); }); })->with(['pesertaklinik' => function($q){ $q->with(['timecontrolling' => function($qq){ $qq->where('status', 'done'); }]); }])->orderby('tanggal', 'desc')->get(); $data = $data->pesertaklinik()->paginate(10); but result "method pesertaklinik not exist." this method pesertaklinik in jadwalterapisklinik model : public function pesertaklinik(){ return $this->hasmany(pesertaklinik::class, 'jadwal_terapis_id'); } but when use find(1) on first query not get() , working fine. str

node.js - Why does a while loop block the node event loop? -

the following example given in node.js book: var open = false; settimeout(function() { open = true }, 1000) while (!open) { console.log('wait'); } console.log('open sesame'); explaining why while loop blocks execution, author says: node never execute timeout callback because event loop stuck on while loop started on line 7, never giving chance process timeout event! however, author doesn't explain why happens in context of event loop or going on under hood. can elaborate on this? why node stuck? , how 1 change above code, whilst retaining while control structure event loop not blocked , code behave 1 might reasonably expect; wait logged 1 second before settimeout fires , process exits after logging 'open sesame'. generic explanations such answers to question io , event loops , callbacks not me rationalise this. i'm hoping answer directly references above code help. it's simple really. internally, node.js co

ASP.NET MVC 4 - Dynamic page layouts with widget zones -

i building asp.net mvc 4 dashboard site.i trying come design requirement. site going 3 colum layout. left column vertical navigation menu. centre , right columns contain widgets. same wiget can appear either in centre zone or right zone. requirement change 3 column layout 2 column or other layout minimal interference in future. widget system many different widgets displayed user based on roles , these widgets can placed in position/zone. suggestions on how start great. none of requires doing special in asp.net mvc, more getting right layout in html & css . suggest work on getting template html , css working first. there plenty of places on web find 3 column templates started. once have html & css sorted, find asp.net mvc flexible enough work whatever layout come with. find "child actions" best way handle widgets.

How to change Navigation drawer launcher icon color in Android -

Image
i want change navigation drawer launcher default icon . want set custom icon how can please help. above picture indicates 3 white line stacked on top of 1 in toolbar, want change icon. here fragmentdrawer.java:- public class fragmentdrawer extends fragment { private static string tag = fragmentdrawer.class.getsimplename(); private recyclerview recyclerview; private actionbardrawertoggle mdrawertoggle; private drawerlayout mdrawerlayout; private navigationdraweradapter adapter; private view containerview; private static string[] titles = null; private fragmentdrawerlistener drawerlistener; private hashmap<string,string> category = new hashmap<>(); private list<string> cat_array = new arraylist<>(); private static string[] maintitle = null ; private imageview iicon; public fragmentdrawer() { } public void setdrawerlistener(fragmentdrawerlistener listener) { this.drawerlistener

php - Laravel custom controller get 404 error -

i have simple custom controller in route : route::controller( 'validationmobiles', 'validationmobilescontroller', [ 'getindex' => 'validationmobiles.index', ] ); unfortunately 404 error after run url : http://localhost/laravel/public/validationmobiles.index my controller: namespace app\http\controllers; class validationmobilescontroller extends controller { public function getindex() { dd('ss'); } } updated: full controll, method work fine in laravel 4, in laravel 5 added namespace: route::controller( 'validationmobiles', 'validationmobilescontroller', [ 'getindex' => 'validationmobiles.index', 'postupdate' => 'validationmobiles.update', 'postedit' => 'validationmobiles.edit', 'getdelete' => 'validationmobiles.delete', 'getaccept' => &#

amazon ec2 - Weave plugin on AWS EC2 -

i've tested weave overlay network docker on centos 7, after had try deploy system in aws environment. there difference. when docker launches on ec2 instances, weaveplugin container starts. makes impossible launch weave before stopping plugin. can't launch weave network on statup. on centos added commands in /etc/rc.d/rc.local: rm -f /opt/wenv /usr/local/bin/weave launch $host1 touch /opt/wenv echo $(weave env) > /opt/wenv "weave env" - export environments on logon. on ec2 after boot see via "docker ps" weaveplugin container stated. , "weave launch" not work before i'll "weave stop-plugin". if add command in rc.local on ec2, "weave env" not works, file /opt/wenv empty. maybe last command runs early, must wait successful starting of previous command guess because works on centos. suggestions please. oh! forgot add full path weave env:) so, in /etc/rc.local: rm -f /opt/wenv /usr/local/bin/weave launch $hos

database - inserting double dimensional array into ms-access dynamically in java -

i want insert double dimensional array ms-access dynamically in java .. here code.. try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); string url = "jdbc:odbc:driver={microsoft access driver " + "(*.mdb, *.accdb)};dbq=c:\\documents , settings\\anil kumar\\desktop\\hyperdata.mdb"; con = drivermanager.getconnection(url); system.out.println("connected!"); } catch (sqlexception e) { system.out.println("sql exception: "+ e.tostring()); } catch (exception e) { e.printstacktrace(); } if have string array 2 columns: string[][] = new string[10][2]; preparedstatement pst = con.preparestatement("insert sap_details values (?,?)"); (int = 0; < 10; i++) { pst.setstring(1, a[i][0]); pst.setstring(2, a[i][1]); pst.addbatch(); } pst.executebatch(); what if have have string array n columns , n rows? how insert string array a[n][n]? have inne

javascript - How to refresh a specific div of a page in PHP? -

i making online game using php , javascript, have more knowledge in php in javascript, though new in both languages, keep in mind. so trying make in php / javascript , of course html refresh div or area of code need, , can't make page reload every time gets new information or data because when php ran , done can't have else running, unless use loop though sounds bit sketchy , not sure if that's method. have tried: (php) header("reload: 1"); though refreshed page, want happen when data not happening, example program information ready send client page asll other client. though explination if possible refresh specific area when told example getting mysql data. function refresh_box() { $("#mydiv").load('path php file'); settimeout(refresh_box, 60000); } $(document).ready(function(){ refresh_box(); }); this settimeout call function every 1 minute , load content dynamically in mydiv .

mobile - Cordova-Like Hybrid App Framework - But Offline -

i've been looking creating mobile app (for both ios , android) out of responsive website. i understand open-source project enables apache cordova , , popular saas version of adobe phonegap . after taking @ phonegap , some of competitors , understand they work in same way : developer builds responsive website. developer uses 1 of sass options/vanilla cordova in order wrap said website in ios/android package (optionally using some of framework's native sdks , "app" native-like functionalities.). developer uploads packaged "app" various app stores. if i'm not mistaken, means all cordova , derivatives do (no disrespect intended, obviously) take url, allow code in use native functions, , wrap in package suitable mobile phones . my site different - don't care internet connection. all want html & css work on phones located in remote places bad internet connection. so - loading website in webview not enough me, want run without i

entity framework - Converting a datetime to date in iEF -

i have linq statement runs expected in linqpad (using linq sql) when bring c# app using ef 6, error saying cd.logtimestamp.date (in groupby statement) not supported. i'm attempting convert datetime2 value date value group purposes. helper.getdbcontext().sitelog .where( sl => sl.siteid == 3 ) .groupby( cd => new { cd.siteid, cd.logtimestamp.date } ) .select( g => new dailytraffic() { siteid = g.key.siteid, trafficdate = g.key.date, newusers = g.count( row => row.isnewuser ), returningusers = g.count( row => row.isreturninguser ), totalusers = g.count( row => row.isnewuser ) + g.count( row => row.isreturninguser ), pageviews = g.count( row => row.ispageview ) } ) .orderby( g => g.siteid ).thenby( g => g.trafficdate ) .tolist(); is there preferred way convert datetime2 value date value in ef 6 using qa ( how use entity fra

javascript - Image getting out of place when content is expanded -

so, have this site. when user clicks in "learn more" in 1st , 2nd sections, image on side moves. wish stays originally. i don't why happens , don't know how fix it. suggestions? thanks. ps: please check site example below doesn't have images. $("#firstp").click(function() { $("#one .hidden").addclass("block"); $("#one .hidden").removeclass("hidden"); $("#firstp").addclass("hidden"); }); $("#secondp").click(function() { $("#two .hidden").addclass("block"); $("#two .hidden").removeclass("hidden"); $("#secondp").addclass("hidden"); }); @import url("https://fonts.googleapis.com/css?family=raleway:200,700|source+sans+pro:300,600,300italic,600italic"); html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquo

java - how to reload or refresh a tab's content base on actions in vaadin -

the content of tab formed , displayed when application loaded. later content of tab may changed other actions. want show newer content after each action. , each time when click tab sheet, content should refresh/updated. failed. //the content of tab "reprintstab" class //in "reprintstab" query data database , print out //later update data in database somewhere else, , want tab shows new content //i want click tab sheet reload "reprinttab" class , print out new content //here did: public tabsheet sheet; //add tab , add content "reprinttab" tab sheet.addtab(new reprintstab()); //add listener sheet.addlistener(new tabsheet.selectedtabchangelistener() { @override public void selectedtabchange(selectedtabchangeevent event) { //i know not work, because reload class. not put content under tab want new reprintstab(); } }); what should do? please me, thanks.

c - Segmentation fault after fopen inside a function. No issues when doing fopen in main, -

i trying learn c. goal of function foo accept string, change of it's characters , see if there file name. if such file exists, print it's contents on stdout. sounds pretty simple , should be, keep getting segmentation fault when call fopen inside foo function. guess doing bad memory, can't figure out is. here source: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> void foo(const char* fname); int main() { printf("hello world!\n"); foo("a.c"); return 0; } void foo(const char* fname) { size_t len = strlen(fname); printf("size %i", (int)len); char* fname_hash; strcpy(fname_hash, fname); int i; //"escape" of characters for(i =0; < len; i++){ if( fname_hash[i] == '/' || fname_hash[i] == '.' || fname_hash[i] == '&' || fname_hash[i] == ' '

Associate a Public Static Ip to Web App in the Azure Portal -

Image
is possible associate reserved public ip address web app int azure portal? i need replace ip (40 112 ...) reserved ip. no. faq: can use reserved ip azure services? reserved ips can used vms , cloud service instance roles exposed through vip. reserved ip overview https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-reserved-public-ip/

arrays - Pick random from Java List [] -

i have list of 14 items use in method. wondering how can make randomly pick different items list instead of forcing selecting list number [0] etc. code in method this. stats.list[0].clone (); i need like.. stats.list[randomnumber/decision].clone (); my list code list [0] = new ped (names.getstring("idc"), "c"); list [1] = new ped (names.getstring("id"), "d"); thanks ya help! random r = new random(); int randomnum = r.nextint(sizeoflist); stats.list[randomnum].clone (); use random class.

c++ - Icon path lookup in Qt -

qt supports icon theme lookup returning qicon. qml view need icon path instead of qicon. there way either path looked icon or lookup returns icon path? i.e. want put icon name according icon naming specification function returns path image file. if not possible qt, next best option? there library out there icon specified in freedesktop icon theme sspecification ?

ssl - Whats wrong with this script? - python, gmail, smtp_ssl -

haven't used python in time, need script email myself alerts etc. why wont work? switched using ssl after gmail told me insecure app tried access. # import smtplib actual sending function import smtplib # import email modules we'll need email.mime.text import mimetext msg = mimetext("test file") me = 'me@gmail.com' = me msg['subject'] = 'this test' msg['from'] = me msg['to'] = #username , password here username = 'username' password = 'password' # send message via gmail ssl s = smtplib.smtp_ssl('smtp.gmail.com:465') s.login(username,password) s.send_message(msg) s.quit() the error when attempt run follows: traceback (most recent call last): file "f:\desktop\emailtest.py", line 24, in <module> s.login(username,password) file "f:\python34\lib\smtplib.py", line 652, in login raise smtpauthenticationerror(code, resp) smtplib.smtpauthenticationerror: (5