Posts

Showing posts from June, 2014

c++ - what's wrong with std::remove_if in this code -

solution.cc:14:47: error: no matching function call 'remove_if(std::basic_string::iterator, std::basic_string::iterator, )' #include <iostream> #include <algorithm> using namespace std; int main() { /* enter code here. read input stdin. print output stdout */ string s; std::getline(cin, s); std::transform(s.begin(), s.end(), s.begin(), ::tolower); std::remove_if(s.begin(), s.end(), isspace); // cout<<s; int len=s.length(); len=len+90; bool temp; bool value[len]; for(int i=0;i<len;i++) { int x=(int)s[i]; if(value[x]!=1) value[x]=1; } for(int i=65;i<=90;i++) if(value[i]==1) {temp=true;continue;} else {temp=false;break;} if(temp) cout<<"pangram"<<endl; else cout<<"not pangram"<<endl; return 0; } i tried compiling code in g++ 4.9.1 . exact error is: in function int main() : error: no

NameError: global name 'unicode' is not defined - in Python 3 -

i trying use python package called bidi. in module in package (algorithm.py) there lines give me error, although part of package. here lines: # utf-8 ? need unicode if isinstance(unicode_or_str, unicode): text = unicode_or_str decoded = false else: text = unicode_or_str.decode(encoding) decoded = true and here error message: traceback (most recent call last): file "<pyshell#25>", line 1, in <module> bidi_text = get_display(reshaped_text) file "c:\python33\lib\site-packages\python_bidi-0.3.4-py3.3.egg\bidi\algorithm.py", line 602, in get_display if isinstance(unicode_or_str, unicode): nameerror: global name 'unicode' not defined how should re-write part of code works in python3? if have used bidi package python 3 please let me know if have found similar problems or not. appreciate help. python 3 renamed unicode type str , old str type has been replaced bytes . if isinstance(unicode_or_str, s

r - {plotrix} - gap.plot - colors and background of points -

Image
i using gap.plot function plotrix package. have following points: circles in black (often written pch=21, col="black" ) with background in chosen color (e.g. col="red" ) however, doesn't seem work on gap.plot : the col set color black but bg not fill background of points chosen color (strangely, color "cut" part of plot, see below). here code, showing various attempts following reading of this link , that link . edit: better description of question problems are: gap.plot() attempts not have red background points() gives black circle red background, "y" value false (normally y=12.5, here y=21 instead; because of gap). do know how obtain black circle filled color? library(plotrix) x=seq(from=0,to=18,by=2) y=rep(15,10) cex=1 ## plots x11() # gap.plot() pch=21 col="black" bg="red" gap.plot(x,y+2.5, gap=c(1,9), gap.axis="y", xlim=c(0,25), ylim=c(0,25), type="b",cex=c

version control - Git and Dropbox, gitignore trouble -

me , team have been trying set version control repository in dropbox, we've run strange snag, not sure if it's because of dropbox or not, gitignore file being, well, ignored. we're working on windows 7, , we've tried of fixes we've found on .gitignore not working seems none help, guys have ideas on fix, or recommend version/source control plays dropbox? git , dropbox technologies don't play together. in git, local , on purpose. means can locally make changes, commit when done , push in shared place, others can access it. how source code developed. dropbox more writing , sharing documents. not have control shared others, dropbox continuously syncs. can lead coworker getting changed file you, breaks work. furthermore can no longer make use of branches, coworkers have same dropbox folder, ergo working tree , means have same branch. no way user test on local branch. you should ask question whether developing documents (text, spreadsheet, etc.) or

text to speech - Docker espeakbox: What do I do now? -

seems real simple, i'm not sure now. have docker on osx , i'm want try out espeakbox. ran the command mentioned here . to "run container " it's evidently running: bash-3.2$ docker ps container id image command created status ports names 705a605786c7 parente/espeakbox "/server" 34 seconds ago 33 seconds 0.0.0.0:8080->8080/tcp espeakbox so, do now, use see it, hear it, etc. thanks. there's full instructions on github page, i'm loath answer question. however, i'm assuming confusion you're not sure container running. if you're using boot2docker, do: $ curl http://$(boot2docker ip):8080/speech?text=hello i assume sends mp3 file. basically, docker run command told docker forward port 8080 on container port 8080 on host. when using boot2docker, host virtualbox vm, need use ip of vm connec

Use specific jvm installation when call java application from php code -

i have 2 installations of jdk on account , not have root access change default 1 "usr/bin/java" specific 1 /home/username/jdk/bin/java" i tried following in php code: $java_home = "/home/username/jdk"; $path = "$java_home/bin:".getenv('path'); putenv("java_home=$java_home"); but when execute following below above mentioned lines: which java i got /usr/bin/java any idea please how make works? java application want run php code not work on default one. thanks if feasible, qualify java command, e.g. /home/username/jdk/bin/java , when running java program. this way can use multiple different jvm's in different places of php code. note: know using qualified access works on windows, if java_home points different installation. i'm assuming same true linux.

configuration - Can I get Kronos-Haskell to use my Haskell platform? -

kronos-haskell installs self-contained application , can exist (as near can tell) alongside installation of haskell platform without issues or interactions. nice feature, use current version of haskell, along additional packages i've installed haskell platform. is there way kronos-haskell use installation of haskell platform? you can build ihaskell using recipe readme : git clone http://www.github.com/gibiansky/ihaskell cd ihaskell ./macos-install.sh note - might take while there ton of dependencies.

android - how to customize the google marker cluster renderer? -

in application have put more 50k markers on google maps. want customize marker cluster renderer. number displayed on marker wasn't correct displays wrong number haven't contains number pins displays on marker. please me solve problem. using following code cluster markers: mmap.movecamera(cameraupdatefactory.newlatlngzoom(new latlng(51.503186, -0.126446), 10)); // initialize manager context , map. // (activity extends context, can pass 'this' in constructor.) mclustermanager = new clustermanager<myitem>(this, mmap); mclustermanager.setrenderer(new myclusterrenderer<myitem>(this, mmap,mclustermanager)); // point map's listeners @ listeners implemented cluster // manager. mmap.setoncamerachangelistener(mclustermanager); mmap.setonmarkerclicklistener(mclustermanager); additems(); function add items private void additems() { (int = 0; < placescoordinates.size(); i++) { myitem offsetitem = new myitem(placescoordinates.get(i).getlat(

javascript - how to print the return value of a function in jquery -

i want print return value function $(document).ready(function () { $('.click').click(function (e) { var value = 1; check(value); //function call value:value=1 alert(val); //here want return value function }); function check(value) { if (value == 1) { var val = 'success'; return val; } else { var val = 'error'; } } }); //document ready function so how acieve return value of function , print value of function returned you this: var value = 1; var valofvalue = check(value); //function call value:value=1 alert(valofvalue); //here want return value function or, shorter: var value = 1; alert(check(value)); the reason wasn't working because val not global variable - made in check() function , no 1 other things inside check() can access it. made variable, valofvalue , store return value , use in click function. even better, save making m

what is the best method to transmit a public private key pair when the recipients initially have neither? -

what best method transmit public private key pair when recipients have neither, diffie-hellman 1 such method susceptable man in middle attacks other methods available? information appears suggest parties have secret key public key / private key encryption designed deal problem. both parties can freely exchange public keys other encrypt outgoing messages with. man in middle attacks can occur in sense 3rd party can generate messages either party can decrypt neither (as need private keys). a complete secure exchange eliminate man in middle might go this: both parties exchange public keys party sends message random number contained within it party b decrypts random number , replies same number encrypted party a. when party gets same number back, can sure no man in middle attack has occurred. all messages continue use number proof of message came from. tls uses more complicated version of scheme it's handshake: https://en.wikipedia.org/wiki/transport_layer

c - Why do I have to use %ld when referring to the size of an int variable? -

i define int this: int a; when want lookup size of int, have use format specifier %ld this: printf("int size %ld\n", sizeof(a)); when use %d format specifier, following error: foo.c:7:10: warning: format ‘%d’ expects argument of type ‘int’, argument 2 has type ‘long unsigned int’ [-wformat=] printf("int size %d\n", sizeof(a)); the question is, why result of sizeof() defined long unsigned int when parameter of function int? the type of sizeof(anything) size_t , unsigned integral constant. print it, should using %zu .

ios - Access to PFQueryTableViewController activity indicator? -

i'm using pfquerytableviewcontroller, , i'd access activity indicator pause ui updating until it's finished. there bool value can access reference it? (i understand can using plain uitableview particular use using pfqtvc) edit: im in swift

javascript - Google map not showing on bootstrap modal -

im planning show google map on modal, map not showing modal this code: <div style="margin-top:-7px;"> <button class="btn btn-default pull-right btn-mini " style="margin-right:5px;" data-toggle="modal" data-target="#mymodal7"><i class="fa fa-globe"></i> show map</button> </div> <div class="modal inmodal fade" id="mymodal7" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-md"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">close</span></button> <h4 class="modal-title">addres

exception - Is there any way to catch eval fatal error in php? -

im executing list of php codes via eval, if there error in code want display code have fatal error/parse error. is there way give custom message fatal error or other error my code : $output = []; foreach($codes $key => $res) { if(eval($res['code'])) { eval($res['code']); $output[$key] = $result; } else { $output[$key] = "fatal error in code"; } } var_dump($output); try change code to,using try-catch $output = []; try { foreach($codes $key => $res) { if(eval($res['code'])) { eval($res['code']); $output[$key] = $result; } else { $output[$key] = "fatal error in code"; } } } catch (exception $ex) { var_dump($ex); }

Python Canopy: Is it possible to do word wrap in the editor? -

i using canopy editing , running files. finding difficult take more 80 lines of code in it. is possible enable word wrapping in canopy editor? sorry, editor not yet support soft (display-only) wrapping. the user's guide includes example of macro hard (insert newlines) wrapping, not 1 wants: http://docs.enthought.com/canopy/configure/macro_howto.html#writing-macros-from-scratch fwiw, python standards specify maximum line length of 79 characters: https://www.python.org/dev/peps/pep-0008/#maximum-line-length

java - Why is the ArrayList not updated in the following example? -

i using jnativehook library. an instance of globalkeylistener starts listening keystrokes , adds them arraylist1 ; problem arraylist1 not seem updated ( list1itemcount never bigger 0) when accessing on infinite while(true) loop in child class. why , must achieve that? public class child { public static void main(string[] args) { // logger "org.jnativehook" , set level warning. logger logger = logger.getlogger(globalscreen.class.getpackage().getname()); logger.setlevel(level.warning); try { globalscreen.registernativehook(); } catch (nativehookexception ex) { system.err.println("there problem registering native hook."); system.err.println(ex.getmessage()); system.exit(1); } globalkeylistener globalkeylistener = new globalkeylistener(); globalscreen.addnativekeylistener(globalkeylistener); connection conn; while(tru

replace - How to insert text before the first line if a certain word exists in the whole text with regex? -

i'd regex. example: convert this(where bla can text): bla bla blaba bla bla blablbalba bala bla cocoa bla bla bla bla bla bla bla bla bla bla to this: chocolate unhealty! bla bla blaba bla bla blablbalba bala bla cocoa bla bla bla bla bla bla bla bla bla bla search (.*\n.*cocoa.*\n.*) and replace by chocolate unhealty!$1 () stores result can access later $1 . .* matches char 0 unlimited times. \n matches newline.

linux - Bash script process substitution Syntax error: "(" unexpected -

i want run script: #!/bin/bash echo <(true) and " syntax error: "(" unexpected " . found similar situations still can't solve this. i'm beginner @ shell scripting , understand: the shebang use correct , chooses bash shell , process substitution syntax should work i try same command line , works. checked echo $0 , gives me " bash " , what's difference running command in command line , script invokes same shell? maybe it's simple, couldn't find explanation or solution. you should run script bash , i.e. either bash ./script.sh or making use of shebang ./script.sh after setting executable. running sh ./script.sh error, commented cyrus. see also: role of shebang @ unix.se

mysql - How to unscape text from database in android studio -

i'm creating text view in android studio, text view empty default, fetches data mysql database. text long , contains "\n" character force line breaks. reason, text view displaying \n , there isn't line breaks. here code: <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:singleline="false" android:id="@+id/textview" android:layout_centerhorizontal="true" android:gravity="center" android:textalignment="center" android:layout_below="@+id/imageview3" android:layout_margintop="70dp" android:textcolor="#ffffff" android:textsize="35sp" /> here picture of app showing text no line break :( https://goo.gl/cr34cq the text in picture edited in mysql database. displayed is. i can provide java code , mysql database table also. here j

javascript - How can I change an image with onclick() & if statement repeatedly? -

i new javascript , need issue. i have 3 traffic light images want change each click. go green amber 1 click, amber red click, red green, etc. i have code below, seems go green red first click. any appreciated. thanks. <!doctype html> <html> <body> <button onclick="nextlight()">click here</button> <img id="demo" src="green.png"> <script> function nextlight() { var lights = ["blank.png", "green.png", "amber.png", "red.png"] if (document.getelementbyid("demo").src == lights[1]) { document.getelementbyid("demo").src = lights[2]; } else if (document.getelementbyid("demo").src == lights[2]) { document.getelementbyid("demo").src = lights[3]; } } </script> </body> </html> you have lights array possible states. need iterate between them. there problem time takes loa

Filter popular posts by category in a collection in Jekyll using Liquid -

i have plugin generates list of popular posts in collection in jekyll based on page views. inside collection have 2 categories , filter popular posts same category original post. here code i've written: <ul> {% if page.path contains '_kb/cat1' %} {% assign popular_posts = site.popular_posts | where:"category","cat1" %} {% page in popular_posts | limit:3 %} <li> <a href="{{ page.url }}" title="{{ page.title }}">{{ page.title }}</a> </li> {% endfor %} {% else %} {% assign popular_posts = site.popular_posts | where:"category","cat2" %} {% page in popular_posts | limit:3 %} <li> <a href="{{ page.url }}" title="{{ page.title }}">{{ page.title }}</a> </li> {% endfor %} {% endif %} </ul> is there way make code simpler? how can exclude original post list? example,

Swift - Cropping images *outside* of allowsEditing -

i have very simple project set allows click "browse photo" button. user selects photo photo gallery, , it's displayed on programmatically created uiimageview. works charm. - missing key functionality required. i need user able scale image (via pinching , dragging) after displayed within uiimageview. allowsediting = true, lets user crop before . need similar functionality, however, allowing them edit once it's on main ui. help appreciated. please , thank you!! import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var imageview: uiimageview! var imageviewlayer: calayer{ return imageview.layer } override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. imageviewlayer.contents = uiimage(named: "ss3.jpg")?.cgimage imageviewlayer.contentsgravity = kcagravityresizeaspect } override func didreceivememorywarning() { super.didreceivememorywarning() // dispo

c++ - C++11 Vector of Pointers to Templated Static Member Function -

say have class goes this: struct mystruct { template<typename t> static int func() { // template parameter. } }; now want create vector of pointers functions func 's prototype. since prototype not depend on template parameter, should possible. and, sure enough, can explicitly typedef pointer func , so: typedef int (* funcptr)(mystruct * pointer); and then, creating vector easy as: std::vector<funcptr> funcvector; however, avoid declaring func 's prototype twice. possible so? use decltype : std::vector<decltype(&mystruct::func<void>)> funcvector;

java - How to Select an Array By Selected List Position in Android -

i have 1 string array hold options , 470 string array hold option's values use spinner populate options string array. want select array between 470 arrays according selected option. example if select 2. option want print values2 array screen. how can do. dont want use 470 if else blocks. final string[] options={"option0","option1","option2","option3"...}; final string[] values0={"kjhk","kjhkhkhk","asfasd"}; final string[] values1={"gvctc","ononnnın","njbsalna"}; final string[] values2={"aasd","qwert","asadad"}; . . final string[] values470{"ljlj","ljljl","opıuo"}; spinner1.setonitemselectedlistener(new onitemselectedlistener() { public void onitemselected(adapterview<?> parent, view view, final int position,long id) { } if want setup data hand. here's quick & dirty solution base

c++ - Visual Studio 2015 "cannot instantiate abstract class" compile failures building openFrameworks 0.9.0 -

i trying build openframeworks 0.9.0 using visual studio 2015 , getting "cannot instantiate abstract class" compile failures. however, feel more vs2015 syntax issue versus openframeworks issue. code built using visual studio 2012 , openframeworks 0.8.4. know how implementing class's syntax should satisfy vs2015 should look? the errors vs2015 compile are: ofx*.cpp(46): error c2259: 'ofx*': cannot instantiate abstract class 1> ......\addons\ofx*i\libs\src\ofx*.cpp(46): note: due following members: 1> ......\addons\ofx*i\libs\src\ofx*.cpp(46): note: 'void ofbasedraws::draw(float,float,float,float) const': abstract 1> ...of_v0.9.0_vs_release\libs\openframeworks\types\ofbasetypes.h(75): note: see declaration of 'ofbasedraws::draw' 1> ......\addons\ofx*i\libs\src\ofx*.cpp(46): note: 'void ofbasedraws::draw(float,float) const': abstract 1> ...of_v0.9.0_vs_release\libs\openframeworks\types\ofbasetypes.h(67): note: see declar

ios - How to use CMDeviceMotion to detect how fast my device is traveling? -

i writing ios app , don't want start detecting shake events until after device has reached speed. know how use cmmotionmanager cmaccelerationdata detect shake events know should use detect how fast device moving? either cmdevicemoting/useracceleration/gps... cannot find should do. writing app in swift answers in objective-c suffice well. thank help you use corelocation , use cllocation 's speed property. requires device's gps, , work large speeds.

angularjs - Update Angular View dynamically when MongoDB collection length changes -

i wondering how angular watches database collection changes in mongo db. have variable tracking number of items in mongodb collection , front end view interpolate number whenever new item added collection front end. possible? example: var item = $resource('/api/items'), allitems = item.query(function(results) { return results; }); $scope.alltodos = allitems.length; front end: <p ng-show="alltodos > 0">total items: {{alltodos}}</p> let's assume had way of adding items via form on front end, submitting them database. how {{alltodos}} number dynamically increase (++) when add new item? in backbone.js, know there collection watch events, ie: var collection = backbone.collection.extend({ //code... }), c1 = new collection(); c1.bind("add", function() { //do when add collection }); is possible angular? i'm sure is, please excuse green-ness. thanks! $resource.query returns empty

html - input[type="file"] check existence of file attachment with css -

it's not js question, looking clear css solution if it's possible. for radio button or checkbox can use :checked pseudo class: input{ % styles % } input:checked{ % styles % } are there tricks checking if file attachment exists css? (updated, due misunderstanding question) it possible check if file attached using attribute required . see: http://jsfiddle.net/1ua59jt1/1/ html: <input id="file" type="file" name="fileselect" required="required" /> css: #file:valid { color: green; } #file:invalid { color: red; } but can never validate, if "correct" file selected way. can check if or if not file selected @ all. // completion update: the required attribute html5. please aware not browsers support this: http://www.w3schools.com/tags/att_input_required.asp that means trusted way client side validation using javascript. if want so, recommend using novalidate attribute on form disable

list - [Python ]Using variables defined inside a class (before __init__) in its own methods (__init__, etc.) -

i'm trying make basket can put fruit. basket class, called basket , has internal list called contents . every time basket fruit instance created, it's self.name property appended contents . anyhow, doesn't work. contents = [] class basket: ## want define list "contents", ## doesn't work. def __init__(self,name): self.name = name global contents if name not in contents: contents.append(name) for reason, works if define list contents outside class altogether, affect order , debugging in bigger projects. is there way make code work, lets me define list inside class? if make class-specific "global"variable , valid methods/variables inside class. note: class supposed 1 basket! each fruit called basket itself, fruit. want them inside 1 basket. this whole answer lengthy explanation why shouldn't doing you're trying do... "note: class supposed 1 basket! each fruit called ba

ios - Game for Apple TV appears tilted on the big screen -

since few years have "iphone controller, game screen displayed on tv way of apple tv , air play" project going. it's space-shooter-maze kind of game, except there no shooting , objective steer spaceship find boss (which pic of ~1 year old son). nes game without nes. now when run stuff first time in year or so, controller, using spritekit scene down line, tilted 90 degrees in right or left direction. "or" depends on orientation iphone 6 plus in when app starts. game takes half of tv screen - because it's tilted - , lay man can see fishy going on because text not normal horizontal text reading now, it's tilted. did change recently, ios 8 , how hooking additional uiscreen:s work? touch project, forget how work of time again after long hiatus. experienced , know start digging? poking around, seems app , displayed on handheld device/controller (the iphone) must/should portrait only. if app launched in landscape mode, screen display on tv &quo

java - Confusion with an infinite while loop, concerning Scanner.nextInt(); -

i having problems understanding why code not working. objective keep reading input of user until user enters "5", code continue. appreciate there better ways, , open suggestions of more concise ways go (trying parse string, perhaps), question more curious why method not work opposed looking better method. the code works when integer input, if enter string, code loops continuously, , catch block started without input required. presume it's feature of scanner retaining input, i'm not sure. my code following: import java.util.scanner; import java.util.inputmismatchexception; public class app { public static void main(string[] args) { int temp = 0; system.out.println("enter number 5: "); while (temp != 5) { try { temp = sc.nextint(); } catch (inputmismatchexception e) { system.out.println("try again!"); } } system.out.println(&qu

Scrolling an android screen automatically with dynamic addition of widgets -

i want scroll android screen dynamically clicking button. scrollable content added dynamically. screen shot have attached. shown in screen shot want scroll screen "car details" label should @ top of screen. sv.post(new runnable() { @override public void run() { sv.fullscroll(view.focus_down); vehicle_no.setfocusableintouchmode(true); vehicle_no.requestfocus(); inputmethodmanager imm = (inputmethodmanager) getsystemservice(context.input_method_service); imm.showsoftinput(vehicle_no, inputmethodmanager.show_implicit); } }); this code using scroll screen. it's not solving problem. please suggest me solution problem. thank you. add car details first add view , call sv.postdelayed(new runnable() { @override public void

java - Grails spring security signup with moderation -

is possible in grails spring security allow signup attempts first approved moderator? if yes, can't seem figure out in docs. how do it? if no, way go it? other plugin provide feature built itself. standard prefer going spring security way. if that's not possible, have go possible. i create user object defaults enabled false (make sure can't set enabled client): class user { // ... boolean enabled = false // .... } then have moderator protected view can enable users. spring security ui able part.

python - Remove an attribute from shelve -

i started using shelve module when needed save lot of variables changed each time script ran. sadly, i'm inexperience python in general, , less how shelve works. removed function script, , shelved file no longer works. i want fix issue , retain shelved file, or @ least salvage variables need file.

html - PHP Header Include (nav bar) not showing up -

clarification: being i've never used php, unclear how format php file, when include in index, header(nav bar) show up. no posts explained why had change index.html index.php make work. , again, being haven't used php, under impression changing extension meant have convert html code php commands. trying avoid having change whole code around. that's confusion was. i going delete question once got figured out. again, i'm sure i'm not person may run while making first website. solution. save nav code in html language php extension (header.php). change index/home file .html .php extension (don't have modify code. accepts include prompt). then, include header.php in index.php. same goes footer. everyone. *original post: through post, told easier use nav/footer on multiple pages using php. i created file , tried including , not displaying. i'm not sure doing wrong. there css in nav bar well, need import css file in php file? or index.html file automat

android - jar file under res/raw folder -

Image
i need place 3rd party jar file raw resource under res/raw in apk. android studio (im using 1.3.1), seems file disappears final apk. presumably because of extension of 'jar'. i cannot rename , not want included dex classes. app needs access jar runtime raw resource. any advice (maybe modification gradle tasks can do) of how achieved? according official android documentation should put .jar files under /libs folder only. see official documentation , raw/ for arbitrary raw asset files. saving asset files here same saving them in assets/ directory. difference how access them. these files processed aapt , must referenced application using resource identifier in r class. example, place media, such mp3 or ogg files. libs/ contains private libraries. stored in main application module. once have placed .jar file inside /libs folder, can reference via gradle.build file, for example i've places acra-4.6.2.jar file insid

ios - How to catch an event when iPhone is rebooted in Objective-C? -

what trying setup local notification. code working expected if phone switched off? after reading article on uilocalnotification when iphone switched off need recreate each local notification had been made go through how check if ios device has been rebooted since launch , , how can detect whether iphone has been rebooted since last time app started , , still not reach target. what want know is: there event launched when iphone rebooted ? you misread sources. local notification won't fire when phone off (normal it's off). however, if have notification @ 3pm, reboot phone @ 2pm, notification fire normally.

javascript - What Express websocket events exist? -

i wondering web socket events exist? far have been using ws.on('message') event, use event triggered when connection established , closed. tried adding ws.on('connection') , didn't triggered. why isin't there list of events in websocket modules documentation? https://www.npmjs.com/package/express-ws my code: app.ws('/', function (ws, req) { ws.on('message', function (textchunk) { //do stuff } }); }); do need client side programming this? edit: tried adding this, didn't trigger when connected client. ws.on('request', function () { console.log("request"); }); after looking @ source code express-ws looks can following. var express = require('express'); var app = express(); var expressws = require('express-ws')(app); // websocketserver instance getwss() // https://github.com/henningm/express-ws/blob/5b5cf93bb378a0e6dbe6ab33313bb442b0c2

php - Merging 2 mysql table at specified positions -

i have 2 mysql tables listed below, //first table (db_event) id || name || publish 1 1 2 b 1 3 c 1 4 d 1 5 e 1 6 f 1 //second table (db_ads) id || images || publish 1 a.jpg 1 2 b.jpg 1 i want merge second table db_ads first table db_event @ specified position ie, @ 5th position respectively. my required result should below table, //resulting table id || name || images || publish 1 {null} 1 2 b {null} 1 3 c {null} 1 4 d {null} 1 5 e {null} 1 1 {null} a.jpg 1 6 f {null} 1 2 {null} b.jpg 1 is there method achieve result in php or mysql. don't need results in json. if use, while($event_rows = mysql_fetch_array($event)) { $name = $event_rows["n

html - Javascript setting width for <li> tag not working -

this question has answer here: css list item width/height not work 6 answers setting width <li> tags not working. width changing based on content <li> tag below html code without using display: block/table/inline-block; <!doctype html> <html> <head> <style> .menu { padding: 0px; } .menu li { display: inline; } .menu li { background-color: black; color: red; padding: 10px 50px 0px 0px; border-radius: 4px 4px 0 0; } </style> </head> <body> <h2>horizontal list</h2> <ul class="menu"> <li>java script</li> <li>java script css</li> </ul> <ul class="menu"> <li style="width:80%">script</li> <li>width changed based on content </

How do I set the path to a DLL file in Visual Studio? -

i developed application depends on dll file. when debug application, applicationwould complain that: "this application has failed start because xxx.dll not found." so have copy dll file same directory .vcproj file. is there way set project dll file in (preferably) relative path or (not preferred) absolute path? similar concept how set include , library path in project settings. i mean when debug application (hitting f5 ) above error pop up. go project properties (alt+f7) under debugging, right there's environment field. add relative path there (relative vcproj folder) i.e. ..\some-framework\lib appending path=%path%;$(projectdir)\some-framework\lib or prepending path path=c:\some-framework\lib;%path% hit f5 (debug) again , should work.

c# - WCF Rest API to Upload Images -

i trying implement wcf rest service method upload images/ files mobile. primary requirement method should able related information (id & etc) image uploading. i found below example url. https://github.com/danialfarid/ng-file-upload/tree/master/demo/c%23 could me convert below method wcf rest service post method public void processrequest(httpcontext context) { if (context.request.files.count > 0) { httpfilecollection files = context.request.files; var username = context.request.form["name"]; (int = 0; < files.count; i++) { httppostedfile file = files[i]; string fname = context.server.mappath("uploads\\" + username.toupper() + "\\" + file.filename); file.saveas(fname); } } context.response.contenttype = "text/plain"; context.response.write("file/s uploaded successfully

asp.net mvc - post back the checkbox value in MVC -

Image
i have model below public class security { public long id { get; set; } public long user_id { get; set; } public long submenu_id { get; set; } public long module_id { get; set; } public long flag { get; set; } public string module { get; set; } public string submenu { get; set; } } in flag 1 if user has access menu else 0 i able show in view using pagedlist @foreach (var item in model) { <tr class=""> <td> @if (item.flag == 1) { <input type="checkbox" name="flags[]" checked="checked" id="@item.id" value="1" /> } else { <input type="checkbox" name="flags[]" id="@item.id" value="0" /> } </td> <td>@html.displayfor(modelitem => item.module) </td> <td> @html.displayfor(modelitem => item.submenu)</td> </tr> } it give below output here user has access 5 menus , no access

mysql - Putting several values into one column but different rows in php -

i have 3 variables: $title, $pubdate , $link and in variables, there several values this: $title = aa, bb, cc, dd, ee, ff $pubdate = aa, bb, cc, dd, ee, ff $link = aa, bb, cc, dd, ee, ff like this. have table columns (title, pubdate , link). have tried: $sql = "insert ytable (title, pubdate, link) values ('$title', '$pubdate', '$link')"; mysql_query($sql,$db_con); although no error pops up, not perform want do. puts of values(aa, bb, cc, dd, ee, ff) 1 column(title) , 1 row(id = 1), meaning of values squished 1 box, , not want :( want put 1 column, in different rows (1,2,3,4,5,6). i've searched web answer, seems answering if want values in 1 box opposite want. perhaps 1 one, therefore insert ytable (title)values($title); , , puts of values in different rows in 1 column. you going have split strings array, can 'loop' through them. $title = "aa, bb, cc, dd, ee, ff"; $pubdate = "aa, bb, cc, dd, ee, f

jquery - Click to show multiple element ref by id using javascript -

click show multiple element ref id using javascript this code, click link click here show elements. on first click click here want show one , 111 (it's same id number show_1 ) and second click click here want show two , 222 (it's same id number show_2 ) and third click click here want show three , 333 (it's same id number show_3 ) and fourth click click here want show four , 444 (it's same id number show_4 ) and fifth click click here want show five , 555 (it's same id number show_5 ) but when test code, it's not work good. it's show only one 2 3 4 5 how can ? http://jsfiddle.net/x53eh96o/12/ <style type="text/css"> div{ display: none; } </style> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tbody> <tr> <td valign="top" style=" width: 17%; "> <d

javascript - Don't use jQuery DOM changes when printing -

update: css solution below. i'm using fullpage.js jquery plugin unfortunately affects printing of webpage, displaying current viewport display , sibling. the problem have print command uses dom (obviously), plugin has made inline css changes in dom. there way disable dom changes print ? this doesn't work, here's idea: $(document).ready(function() { if(@media !print) { // ps: not real code! $('#fullpage').fullpage(); } }); ------ css solution ------- praveen's reply led me on right course. css needed override fullpage.js inline styles are: /* override javascript inline styles */ html, body { overflow: visible !important; height: auto !important; } .fullpage-wrapper { height: auto !important; transform: none !important; transition: none !important; } .fp-section { height: auto !important; } .fp-slidescontainer { width: auto !important; transition: none !important; transform: none !importan

mysql - How to add permalinks in wordpress database with PHP script? -

i want insert in database custom php script server, posts need insert permalinks , don't know how. in wordpress platform have permalink structure localhost/%postname%/ . when post script in wordpress database, title , description ok when want access new post can't because have no permalinks. i have try insert in wp_posts->post_name(in database) custom permalinks directly post-test-post. now can access post localhost/post-test-post/ , ok if want update post wordpress site new post have scheduled status , in edit area permalink ok http://localhost/post-test-post/ after press view post, see in browser shortpermalink localhost/?p=313 want same localhost/post-test-post/ can me ? thank you!

html - Align vertically an image and two lines of text -

i read many articles, many posts here, unfortunately can't center 2 lines of text , image vertically. <a class="button" href=""> <img src="http://dummyimage.com/30x30/cf97cf/fff"> button <span>button alt</span> </a> i 2 lines next image (centered), , center whole content vertically in .button . body { padding: 20px; } .button { background: #000; color: #fff; text-decoration: none; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; height: 120px; padding: 30px 50px; display: inline-block; } span { font-size: 11px; color: #ccc; display: block; } img { vertical-align: middle; } at css-tricks found article, don't want use position:absolute center. there clean way center texts/image in <a> ? jsfiddle: http://jsfiddle.net/7fx3eozd/ you can wrap text , span inside div wrap div , img inside div add t

python - python3 memoryerror when producing a large list -

i'm beginner. see mandelbrot set fantastic, decide draw set python. there problem,i got 'memoryerror' when run code. this statement num_set = gen_num_set(10000) produce large list, 20000*20000*4 = 1600000000. when use '1000' instead of '10000', can run code successfully. my computer's memory 4gb , operating system window7 32bit. want know if problem limit of computer or there way optimize code. thanks. #!/usr/bin/env python3.4 import matplotlib.pyplot plt import numpy np import random,time multiprocessing import * def first_quadrant(n): start_point = 1 / n n = 2*n return gen_complex_num(start_point,n,1) def second_quadrant(n): start_point = 1 / n n = 2*n return gen_complex_num(start_point,n,2) def third_quadrant(n): start_point = 1 / n n = 2*n return gen_complex_num(start_point,n,3) def four_quadrant(n): start_point = 1 / n n = 2*n return gen_complex_num(start_point,n,4) def gen_