Posts

Showing posts from July, 2015

php - How many days since sign up in mysql with new column -

i'd add column database displays amount of time in days since user signed up. currently have field displays date signed in unix. is possible new column increase fields 1 each day? you can basic sql information dynamically. datediff() need: select datediff(current_date, from_unixtime(date_signed_up)) days_since_signup tablename

Excel VBA script to prefill online form using IE? -

i in need of assistance. trying write vba script take value in column , place on online form in input element no id name ("oldurl"). vba script take value in adjacent cell in column b , place in same form ("digishop") in input field named ("newurl"). the form on secure server have gotten far window pulling , form selected. having trouble finding way target input field since have no id. below code , thank help. sub redirect() dim ie object dim doc object dim form object dim oldurl object dim newurl object set ie = createobject("internetexplorer.application") ie .visible = true .navigate "https://...." until .readystate = 4: doevents: loop set doc = ie.document set form = doc.forms("digishop") set oldurl = doc.getelementbyid("oldurl")'error occurs here. element has no id oldurl.value = range("a2") set newurl = doc.getelementbyid("newurl") newurl.va...

windows phone 8 - Mvvm How to get the value txtNmItem with TextChanged method -

how value txtnmitem textchanged method? <textbox grid.column="1" name="txtnmitem" background="#f3f3f3" borderbrush="#f3f3f3" verticalalignment="top" text="{binding path=snmitem, mode=twoway}"> <i:interaction.triggers> <i:eventtrigger eventname="textchanged"> <cmd:eventtocommand command="{binding elementname=listaitem,path=datacontext.salvarcommand}" passeventargstocommand="true"/> </i:eventtrigger> </i:interaction.triggers> </textbox> viewmodel public relaycommand<object> salvarcommand { { return new relaycommand<object>(salvar); } } private async void salvar(object e) { i ...

python - PyYAML Basic config file writeback -

i'm new python, , i'm looking basic things pyyaml. want take yaml file: #lets test out logfile config --- filepath: c:\users\me\documents\python\yaml_test1\ filename: logfile_ log_no: 1 now i'm shooting way control path logfile, root name of log, , number log we're on appended filename (to rollover new log when hit kb file size). import yaml import os rootdir = os.getcwd() c_filename = rootdir + "\\config.yml" c_filein = open(c_filename,'r+') conf = yaml.load(c_filein) = conf['log_no'] += 1 print conf['log_no'] = print yaml.dump(conf['log_no']) yaml.dump(conf,c_filein) c_filein.close() my problem dumping file dumps full (though updated) yaml file, @ end of config. suggestions? ninja edit: i'm open , suggestions, it's use other yaml. reading , wanted give shot. so i'm going close since have found configparser module looking rotating logfile

c++ - comma separated stream into struct -

i have structure int , 2 strings. when reading in file comma seperated first 2 values , last value terminated newline. third argument empty however. ex data: 7, john doe, 123-456-7891 123 fake st. i want make program grab first number , put in int, find comma , put second number in struct's string etc. first question should use class instead? have seen getline(stream, mystring, ','); arguments different data types can't throw them vector. my code: struct person{ int id;//dont care if unique string name; string extrainfo; }; int main(int argc, char* argv[]){ assert( argc ==2 && "invalid number of command line arguments"); ifstream inputfile (argv[1]); assert( inputfile.is_open() && "unable open file"); } what best way of storing information , retrieving file comma separated first 2 , ends newline? want program ignore blank lines in file. i'd read file line-by-line using normal ge...

java - Making a client-server chat - running into issues with connecting client to client -

i trying learn how make multiple-client chatting program. im following oracle tutorial on custom networking, not looking for. far, have no code of own share, of copied oracle tutorial , think pasting here copyright infringement(??). link at: http://docs.oracle.com/javase/tutorial/networking/sockets/clientserver.html+ client code link: http://docs.oracle.com/javase/tutorial/displaycode.html?code=http://docs.oracle.com/javase/tutorial/networking/sockets/examples/knockknockclient.java anyway, have server-client working server tells knock knock jokes, client reads , prints, user replies , on. how start edit have client talk other clients directly? im sorry, have no background networking @ all. if can direct me informative source better suited goals appreciate it. as in knock-knock example, each client connects server, not mutually directly connected. there solution make forwarding sever :arrange each client id, , clients use id identify talking partners. to this, h...

Create a Second Activity in Android Studio -

this question has answer here: how add new activity existing project in android studio? 3 answers i have started playing android studio. cannot figure out how add second activity project. know in beta phase, appreciated. you need create second java file extends activity base class , add reference in androidmanifest.xml

shell - Check folder size in Bash -

i'm trying write script calculate directory size , if size less 10gb, , greater 2gb action. need mention folder name? # 10gb size="1074747474" # check current size check="`du /data/sflow_log/`" if [ "$check" -gt "$size" ]; echo "done" fi you can do: du -h your_directory which give size of target directory

java - Getting a NotSerializableException even though all the objects I'm sending are Serializable -

okay, have class extends jframe , i'm trying create jpanel takes in information , sends out "event" object when submit button pressed. seems working, except when press submit, tells me client needs serializable... (the client class basic class opens connection specific port. works, i've tested , it's not problem). have serialized objects sending. don't understand why getting notserializableexception. been trying figure out hours now. insight appreciated. here code: public class windowgameactual extends jframe implements actionlistener { private final static int port = 11114; private gamestate game; public windowclient connection; jpanel container; jtextarea description; jtextfield difficulty; jcheckbox check4; jcheckbox check6; jcheckbox check8; jcheckbox check12; jcheckbox check20; jcheckbox agl; jcheckbox str; jcheckbox mana; public class windowclient extends client { public windowclient(string host) throws ioexception { su...

ruby on rails - Bundler::Git error on app startup (passenger 4, nginx flavor, and jruby 1.7.3 for the app under rvm) -

there many similar questions, rather dated. error familiar, updated passenger 4.0.0.2 , jruby 1.7.3. the web application cannot started, , in stack trace is the git source not yet checked out. please run bundle install before trying start application (bundler::giterror) i have tried couple things suggested other posts, such bundle install --development have tried suggestions per rvm passenger instructions no avail. another curious thing, cannot run passenger-status under jruby gemset, , error, gem::loaderror: not find passenger (>= 0) double-checked , made sure passenger installed under gemset. my nginx config pointing proper ruby wrappers, not source of error. still have hunch due different gemsets, having use mri ruby passenger installation (per recommendation phusion team), can't seem pinpoint source of error. any appreciated. edit upon closer inspection of environment variables, gem_path being left blank edit 2 installed passenger gem, , did bu...

Solr delete by id is working, but delete by query isn't -

i'm using solr 4.0 beta. found able delete document id can't same work using delete query, example noticeid:728 , , can use same query syntax select want. there i'm missing? time move beta, maybe have hit out bug delete query bug

html - How to move the menu vertical align of the grey bar -

i want move menu wordings align vertical on grey bar, please see attachment. http://i1127.photobucket.com/albums/l622/sugarboylovephoto/screenshot2013-05-21at124323pm_zps317fe22f.png this html code of menu bar <body> <div id="header"> <div class="head-padding"></div> <div id="head"><img src="images/head01.png" width="1010" height="106"></div> <div id="nav" class="navbgimg"> <a href="#about" class="mid">about</a> <a href="#studying">studying science</a> <a href="#ssci">about ssci</a> <a href="#highlights">programme highlights </a> <a href="#life">student life</a> <a href="#fun">fun fact</a> <...

java - LibGdx avoid TouchUp after screen change -

upon touchdown() call game.setscreen(new screenclass(this)); this works great when gets new screen , release mouse (or lift finger) new screen firing touchup() event. there way prevent first touchup getting recorded ? you can add flag on second screen ignore first touchup event. private boolean isfirsttouchup = true; in touchup event, add code, if(isfirsttouchup){ isfirsttouchup = false; }else{ // touchup event here, } hope can :d

how to share the part of the project using git -

i have project share team. want parts of project shared. i have thougth use branch. seems not work. i have tried this: git init git add -a git commit -m "first commit" git checkout -b share //delete files unshared git add -a git commit "commit @ share branch" do miss anything? you may create 2 separate repositories, 1 private code , second shared code. using git submodules make shared repository part of private repository. submodules allow keep repository subdirectory of repository. way files managed git , still able share specific part of project others.

coding style - Is there a simpler way to derefence nullable references in Java? -

consider following code snippet: if (foo != null && foo.bar != null && foo.bar.boo != null && foo.bar.boo.far != null) { dosomething (foo.bar.boo.far); } my question simple: there more simple\shorter way ? in detail: there more simple way validate each part of chain, i'd imagine similar .. if (validate("foo.bar.boo.far")) { dosomething (foo.bar.boo.far); } maybe ? if (fooutils.isfarnotempty(foo)){ dosomething (foo.bar.boo.far); } and in fooutils : boolean isfarnotempty (foo foo){ return foo != null && foo.bar != null && foo.bar.boo != null && foo.bar.boo.far != null; }

ios - objective-c json serialization -

i need create post request , in it's body need put json. template json file follows: {"key" : [{...}, {...}, {...} ..... ]} what i've tried doing this: @{@"key" : @[@{...}, @{...} ... ]}; the issue have puts round brackets around nsarray . output: {key = ({...}, {...}, ..... )} snippet code(after i've created nsdictionary ) nserror *error; nsdata *jsondata = [nsjsonserialization datawithjsonobject:mydictionary options:nsjsonwritingprettyprinted error:&error]; [request sethttpbody:jsondata]; is there way me make nsarray have [ ] instead of ( ) ? nslog uses {} printing nsdictionary , () printing nsarray contents. has nothing json. json data structure created , encoded correctly. verify this: nslog(@"%@", [[nsstring alloc] initwithdata:jsondata encoding:nsutf8stringencoding]); and see ac...

javascript - ASP.Net MVC jQuery and plugins loaded in wrong order -

i'm using asp.net mvc , attempting use tinymce html editor. i added nuget - however, adds editortemplate ( shared -> editortemplates -> tinymce_jquery_full.cshtml ), renders jquery tinymce within page - ie. before jquery scripts loaded (by default in mvc templates, @ bottom of page) - tinymce not work. the template is: @* don't forget reference jquery library here, inside view or layout. <script src="@url.content("~/scripts/jquery-x.x.x.min.js")" type="text/javascript"> </script> *@ <script src="@url.content("~/scripts/tinymce/jquery.tinymce.js")" type="text/javascript"></script> <script type="text/javascript"> (function(){ $(function() { $('#@viewdata.templateinfo.getfullhtmlfieldname(string.empty)').tinymce({ // location of tinymce script script_url: '@url.content("~/scripts/tinymce/tiny_mce.js")',...

cordova - Store multiple contacts in phonegap -

i using below code save contacts in device using phonegap. want perform action after contacts saved successfully. save() method asynchronous can't able know when contacts saved. is possible without making change in save() method? if not then, changes required in save() method? (var = 0; < allcontacts.length; i++) { var obj = eval(allcontacts[i]); var contact = navigator.contacts.create(obj); contact.save(); } thanks in advance yogesh patel i made change on above code i have written code restore multiple contacts in iphone phonegap. , want perform action after contacts restore successfull. working fine if no of contacts near 400 if increase no of contacts near 1000 skip some(10 15) of contacts. each time when restore different no of skip contacts. , skip contacts fail() function not called. should next? need change save method in cordova js? below code: function storecontacttodevice(json1,callback) { var temp=0...

Using bzr with SFTP on Windows/Cygwin -

note: i'm not sure if belongs on serverfault or stackoverflow i'm working on project has sftp-only bzr repository. works fine using linux machine, when using windows cygwin following issue: $ bzr checkout sftp://user@hostname/var/bzr/project bzr: error: unsupported protocol url "sftp://user@hostname/var/bzr/project": unable import paramiko (required sftp support): no module named crypto i have installed cygwin's python-paramiko package, i'm not sure why it's refusing use it. any suggestions appreciated. clarification: work windows bazaar gui tool & windows cmd shell, i'm wondering if can make work in cygwin prefer unixy command line tools. played around today. had install python-crypto should prerequisite of python-paramiko isn't.

email - java.mail mark message as unread -

i building automatic mail processor application , parsing emails 1 one. if parsing 1 of messages fails mark message unread? how mark message unread please? thank you messageobject.setflag(flags.flag.seen, false); the first parameter flag, second 1 it's if want negate flag, seen flase unseen. ps: need use imap, can't pop3

websphere - Errors while testing simple BPEL component in isolation -

errors while testing simple bpel component in isolation @wid 7.0.0.4 bpel component has 1 java snippet containing single line: system.out.println("+++++++++++++++++" + input1); at same time, java components working fine. my configuration follows: ubuntu 12.10 wid 7.0.0.4 wps 7 [5/21/13 10:42:25:111 msd] 0000024f htm cwtke0044i: originator becomes administrator of task component1. happens, because no people assignment criteria defined administrators of task, or because usage returns empty set of users. [5/21/13 10:42:26:215 msd] 00000222 cem w com.ibm.websphere.cem getemitterfactory cemem0003e: specified emitter factory not found in jndi. {0} [5/21/13 10:42:26:216 msd] 00000222 localexceptio e cntr0020e: ejb threw unexpected (non-declared) exception during invocation of method "invokeprocesssessionbean" on bean "beanid(bpecontainer_qnode_server1#bpecontainer.jar#cscopeprovider, null)". exception data: com.ibm.bpe.a...

ios - How can I measure my app's data traffic? -

i'm developing ipad app, loads images , video calls. images retrieved on http, , video stream on rtp. there way measure download , upload being performed app? i'm not looking debug tool, i'd log how bandwidth customers use. try use google analytics sdk

drupal - Search index doesn't work -

i having issue while indexing site. ran cron multiple times 1day ago update 16000 nodes search index. worked fine till 73%. after 73% stopped indexing. next day re-indexed search , tried run cron beginning, search index remained 0%. have tried removing cache , few more minimal tasks , ran cron again still @ 0%. can 1 me on this? have enabled module or made change (after 73% of indexing)? check error log, might answer there. generally, because of oom. so, increasing memory limit in php.ini can help. you can increase memory limit settings.php file adding following line: ini_set('memory_limit', '225m');

javascript - How can a number in a dictionary in an array be NaN directly after I inserted 1? -

Image
i have piece of code includes this: var clustercenters = [{"x": 1,"y": 1},{"x": 10,"y": 10}]; console.log(clustercenters); in chrome 26: in firefox 21: why error occur? i guess error has in following function. function getkmeansinfo(k, mousex, mousey) { // choose cluster centers var clustercenters = [{"x": 1,"y": 1},{"x": 10,"y": 10}]; console.log(clustercenters); (iteration=0;iteration< 20;iteration++) { // each object, check cluster nearest (i=0; i<points.length; i++) { var distmin = 1000000; var clustermin = 0; for(j=0; j<k; j++) { var dist = euklideandist(clustercenters[j], points[i]); if (dist < distmin) { distmin = dist; clustermin = j } } points[i]["cluster"] = clustermin; ...

git - Commit encoding change -

i have files us-ascii encoding committed repository. when change encoding utf-8 cannot commit, because get: $ git status # on branch master nothing commit (working directory clean) how can commit such changes? us-ascii , utf-8 same in lower 7 bits (0-127), aka of english characters. there no difference.

javascript - Getting parent element in jQuery -

i have tried parent element's id of clicked element. have tried this $(window).click(function(event) { alert("clicked on " + event.target.id + ". parent " + $(event.target).parent().attr("id")); }); if have following structure, returns clicked on x. parent undefined . <div id="y"> <div id="x">x</div> </div> why isn't giving parent's id? i have tried following too $(this).closest("div").attr("id"); $(this).parent().attr('id') $(document).on('click', '.clicked-element', function(){ parentelid = $(this).parent().attr('id'); // parentelid = $(this).parents('.custom-parent-class').attr('id'); // if wan't id different parent });

linq - C# Directory.GetFiles with mask -

in c#, files specific directory matches following mask: prefix "myfile_" suffix numeric number file extension xml i.e myfile_4.xml myfile_24.xml the following files should not match mask: _myfile_6.xml myfile_6.xml_ the code should somehing this (maybe linq query can help) string[] files = directory.getfiles(folder, "???"); thanks i not regular expressions, might - var myfiles = file in system.io.directory.getfiles(folder, "myfile_*.xml") regex.ismatch(file, "myfile_[0-9]+.xml",regexoptions.ignorecase) //use correct regex here select file;

Difference between eq and == in Grails withCriteria query -

i want fetch db requirements related given project(in case currentproject) i've used 2 ways this first 1 : requirement.withcriteria {.... eq("project", currentproject) ... } i note query doesn't use equals method of project class, query returns me want. second requirement.withcriteria { .... currentproject == property('project') ... } this query use equals method compare 2 projects, not overwrite equals method exception has been thrown saying "grails can't cast hibernatebuild domain" so, wonder know difference between 2 queries ? thanks all! withcriteria method goes database fetch entities. on database level there no concept of equals (db not know java). first query gives right results because compares db mapping (primary / foreign keys). as second query - not advice use it. if uses equals, when fetches projects db memory. , bad idea.

c# - Getting InvalidOperationException during call to GetResponseAsync()? -

preface: know code excerpt lengthy did't want leave out detail else might spot cause of issue. reason verbose nature of code , many exception traps due hunt nullreferenceexception describe below. can wade through code salient parts jumping await keywords found amongst async methods call each other. update: invalidoperationexception occurring because altering isenabled status of buttons. on main thread not sure why happening. know why? i have windows phone 7 application written c# getting system.invalidoperationexception when getresponseasync() called in particular code context. application uses petfinder api create cat breed guessing game intention of helping cats in animal shelters adopted. here exact exception message in entirety: message: unhandled exception of type 'system.invalidoperationexception' occurred in system.windows.ni.dll before exception occurs, there several successful calls getresponseasync() . have included code methods involved in...

python - Opening files found from os.listdir() and comparing lines inside? -

alright, i'm writing program connect wireless networks. have of down (in fact, it's complete. i'm working on features.) i'm writing gui frontend wireless network connection backend called netctl arch linux operating system. basically, people can manually create profiles , name whatever want (i.e., "asdfasdfasdf"), mine generate $networkssid_wifiz. however, every file have 1 line in able determine if same network. the line is: essid='$networkssid' so how go opening each file appears in os.listdir , checking if 2 files have same line (while not producing overhead, preferably.)? all profiles saved in /etc/netctl whether generated program, or user. sample files: user created: description='a simple wpa encrypted wireless connection' interface=wlp2s0 connection=wireless security=wpa ip=dhcp essid='momandkids' # prepend hexadecimal keys \" # if key starts ", write '""<key>"' # see ...

regex - About regexp performancing -

given string ab given regex pattern (a)(b) if need remove full string, print second group, can write 2 variant: 1) preg_replace("#(a)(b)#", "$2", "ab") // save both group and so: 2) preg_replace("#(?:a)(b)#", "$1", "ab") // dont save first group what variant better performance? i ran each operation in tight loop 5,000,000 each , compared times. compared 4 operations: preg_replace("#(a)(b)#", "$2", "ab"); preg_replace("#(?:a)(b)#", "$2", "ab"); preg_replace("#a(b)#", "$2", "ab"); preg_replace("#a(?=b)#", "", "ab"); i didn't see consistent difference in times, think doesn't matter performance, i.e. choose whichever makes sense design / semantic perspective. #1 , #2 performed same. #2 seems faster, occassionally slower (probably due server noise). #3 consistently 5% fa...

Ember.js {{render}} Helper renders corresponding View twice? -

i've got app want render info bar user within application.hbs this: {{render "userinfobar"}} {{outlet}} <footer id="footer-info">copyright me</footer> i created userinfobarcontroller , userinfobarview classes both derive corresponding ember classes , write log output init() function of both. now, occurs userinfobarview s init() method gets called twice! first time gets called before init() method of userinfobarcontroller , after controller initialized gets called again. therefore i'm unable set elementid userinfobarview , because first initialized userinfobarview inserted before... here's log output gets generated: userinfobarview:: init() called... userinfobarcontroller:: init() called... userinfobarview:: init() called... userinfobarview:: inserted dom...ember195 userinfobarview:: inserted dom...ember198 this controller: app.userinfobarcontroller = ember.objectcontroller.extend({ init: function() { consol...

notifications - Android App Versioning -

i have android app published in google play following version: android:versioncode="1" android:versionname="1.0" i think that's default version when creating android app in eclipse ide. made minor changes in app. want publish updated app. recommended versioncode , versionname updated app? what want users installed app notified google play new version available. im new android development. in device, received notification installed app there new version available. want functionality. i'm thinking of having: android:versioncode="2" android:versionname="1.0.1" is ok? thanks yes thats perfect. typically, release first version of application versioncode set 1, monotonically increase value each release, regardless whether release constitutes major or minor release. means android:versioncode value not have strong resemblance application release version visible user (see android:versionname, below). ...

angularjs - Angular-UI run dropdownToggle from ng-click -

is there way run dropdowntoggle ng-click directive ? using ngmobile avoid delayed click of "actions" button on touch devices. <div class="btn-group"> <a class="btn dropdown-toggle"> actions <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a>action 1</a></li> <li><a>action 2</a></li> </ul> </div> there problem menu, doesn't close on tap if don't keep action1/action2 pressed long time. (much longer usual tap). looks found solution (not best 1 assume) works. if has better one, please share. opening dropdown adds "open" class dropdown element, in order opened on using ng-click needed add class. i know it's temporary solution didn't find better one. here's code: <div class="btn-group" ng-class="{o...

jboss7.x - JAAS DatabaseServerLoginModule rolesQuery does not return user roles -

Image
i'm using jaas jboss 7. login module used databaseserverloginmodule . here configuration: <login-module code="database" flag="required"> <module-option name="dsjndiname" value="java:jboss/datasources/oracleds"/> <module-option name="principalsquery" value="select passwd fo.users username=?"/> <module-option name="rolesquery" value="select userroles, 'roles' fo.userroles username=?"/> </login-module> the authentication occurred without problems (the login module able recuperate password of given username). problem can not recuperate roles using rolesquery , authorization fails. example user krisv role dme , if execute rolesquery inside scrapbook in eclipse got result: when want access web page has role dme auth-constraint following: the 'roles' parts read jboss , understands camelcase should read 'roles' tell me ho...

javascript - Blobs, ArrayBuffers and ArrayBufferViews in Internet Explorer 9? -

i'm developing little web application, fetches binary image data encapsulated in xml nodes xhr. current web application using arraybuffers, arraybufferviews , blobs generate blob urls show fetched images in html documents, works fine. need support internet explorer 9 (sigh), doesn't support arraybuffers, arraybufferviews, blobs or typedarrays. i found answer regarding arraybuffers , typedarrays here: internet explorer error : script5009: arraybuffer undefined but blobs? suggestions here? or maybe (a hint for) clever workaround? thanks in advance!