Posts

Showing posts from May, 2012

what does this syntax of switch case mean in C? -

i saw c code this: int check = 10: switch(check) { case 1...9: printf("it 2 9");break; case 10: printf("it 10");break; } what case 1...9: mean? standarded? it's gnu c extension called case range . http://gcc.gnu.org/onlinedocs/gcc/case-ranges.html as noted in document, have put spaces between low , high value of range. case 1 ... 9: statement; is equivalent to: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: statement;

php - Mandrill ValidationError -

very excited asking first question on stackoverflow. i've been relying on teach myself quite lot on years! my question this. getting following error when trying send mail through mandrill's api: {"status":"error","code":-1,"name":"validationerror","message":"you must specify key value"} the code follows using try send mail: <?php $to = 'their@email.com'; $content = '<p>this emails html <a href="www.google.co.uk">content</a></p>'; $subject = 'this subject'; $from = 'my@email.com'; $uri = 'https://mandrillapp.com/api/1.0/messages/send.json'; $content_text = strip_tags($content); $poststring = '{ "key": "rr_3ytmxxxxxxxx_pa7gq", "message": { "html": "' . $content . '", "text": "' . $content_text . '", "subject": "...

python - Reading data from a Tenma 72-7732 multimeter using PyUSB -

i'm trying read voltages tenma 72-7732 multimeter hid usb connection using pyusb , libusb. code far: def main(): import usb.core import usb.util import usb.backend import sys #find device dev = usb.core.find(idvendor=0x1a86, idproduct=0xe008) # did find it? if dev none: raise valueerror('device not found') else: print "device found" dev.set_configuration() endpoint = dev[0][(0,0)][0] data = dev.read(endpoint.bendpointaddress, endpoint.wmaxpacketsize, 0, 100000) print data main() this finds device, when tries read data, gives timeout error. multimeter has bad documentation , support, can't go there help. how can read device successfully? i use simple ir rs232 adapter consists of ir detector strapped anode pin 4 , cathode pin 2 (rx data). when hooked pc simple terminal set 2400 baud, 7 data 1 stop, no parity, no handshake produces following string 013651211 whic...

android - Check for root freezes -

i'm creating application, in time check root freezes every single time press "check root" button. ideas? here "check root" code: process p; try { // perform su root privileges p = runtime.getruntime().exec("su"); dataoutputstream os = new dataoutputstream(p.getoutputstream()); os.writebytes("remount rw"); os.writebytes("echo root test > /system/rootcheck.txt"); os.writebytes("exit\n"); os.flush(); try { p.waitfor(); if (p.exitvalue() != 255){ //phone rooted toast.maketext(getapplicationcontext(), "your device rooted\r\n\r\n(long press know how root acess)", 0).show(); break; } else { //phone not rooted toas...

javascript - Android: Playing html videos in full screen -

i loading html page on webview, has list of videos. when try play videos, playing unable make them play in full screen. have used below code in html file, , on debugging found 'element.webkitrequestfullscreen' says 'undefined'. on searching web , found videoel.webkitenterfullscreen();, read not working on android 4. possible this? or shall drop idea? function launchfullscreen(element) { alert("launchfullscreen"+element.webkitrequestfullscreen); if (element.requestfullscreen) { element.requestfullscreen(); } else if (element.mozrequestfullscreen) { element.mozrequestfullscreen(); } else if (element.webkitrequestfullscreen) { element.webkitrequestfullscreen(); } } if ok solving in java/android, try guy's solution . adapted needs , must works fine. remember call onhidecustomview manually when exiting fullscreen means of button. not work on devices (like s3). but if looking element.webki...

java - Syntax error on token "(", ; expected Syntax error on token ",", ; expected Syntax error on token ")", ; expected -

i working on project test out eclipse ide java developers. new @ java want know why isn't working because know do. here code: public class eclipse { public static double main(string[] args) { // todo auto-generated method stub final double average(double number, double number2) { double number3 = (number + number2)/2; return number3; } final double suk(double number4, double number5) { double number6 = number4 + number5; return number6; } final double differenck(double number7, double number8) { double number9 = number7 - number8; return number9; } final double produck(double number10, double number11) { double number12 = number10*number11; return number12; } } } here error comes up: exception in thread "main" java.lang.error: unresolved compilation problems: syntax error on token "(", ; expected syntax error on token ",...

javascript - Dynamically Load Content -

i want load content using ajax , keeping header being reloaded, similar site . so far have don't know else add same effect. noticed on website url changes content apart header, want. after looking through source code can't find he's using apart noticing .php extension in url. $('nav li a').click(function(){ // var pageurl = $(this).attr(href); var pageurl = $(this).attr('href'); $('#wrap').load(pageurl); }); what doing wrong? update sorry, did miss out quotes on href although still doesn't work me. $('nav li a').click(function(e){ var pageurl = $(this).attr('href'); $('#wrap').load(pageurl); e.preventdefault(); }); you need add quotes around attr , stop link changing page adding preventdefault(). edit: i noticed selector is: $('nav li a') are sure it's not meant #nav or .nav (for id or class)?

entity framework - Convert SQL query into linq to entities -

i need converting sql query linq entities query. so, in project use entity framework , i've created dbcontext based on existing database. sample db structure below: table 'a' - id, - name, - id_c - relationship between 'c' , 'a'. table 'b' - id, - name. table 'a_b' - many-to-many relationship between 'a' , 'b' - id_a, - id_b. table 'c' - id, - name. table 'b_c' - many-to-many relationship between 'b' , 'c' - id_b, - id_c. table 'd' - id, - name - id_a - relationship between 'a' , 'e'. table 'e' - id, - name - id_d - relationship between 'd' , 'e'. and below sql query use retrieve data table 'e': select _e.* e _e, d _d, _a inner join a_b _a_b on _a_b.id_b = 4 , _a_b.id_a = a.id left outer join b_c _b_c on _b_c.id_b = 4 , a.id_c = _b_c.id_c _e.id_d = _d.id , _d.id_a = _a.id i hope above query clear :) unfortuna...

node.js - How to identify request (by ID) through middleware chain in Express. -

i developping restful server in node.js, using express framework, , winston, moment, logger module. server handle big amount of simultaneous request, , useful me able track log entries each specific request, using 'request id'. straight solution add id piece of logging information each time want make log entry, mean pass 'request id' each method used server. i know if there node.js/javascript module or technique allow me in easier way, without carrying around request id each specific request. you can use req object comes every request in express. first route in application be: var logiditerator = 0; app.all('*', function(req, res, next) { req.log = { id: ++logiditerator } return next(); }); and anywhere within express, can access id in req object: req.log.id ; still need pass data functions want create logs. in fact might have logging function within req.log object, way guaranteed logging happen when there access req.log obj...

module - Change form field style in Drupal 7 -

i creating drupal 7 module. i have textfield : $form['gestionvideos_videos']['input'] = array( '#type' => 'textfield', '#prefix' => '<div id="customsearch">', '#suffix' => '</div>', '#attributes' => array('onkeyup' => 'search();'), ); and want put image in front of it, , align both of them on right of container. have no clue how ? thanks help $form['gestionvideos_videos']['input'] = array( '#type' => 'textfield', '#prefix' => '<img src="/image.jpg" align="left" width="20px" height="20px"/><div id="customsearch">', '#suffix' => '</div>', '#attributes' => array('onkeyup' => 'search();'), );

sql - Combining SUM and CASE returns 0? -

against sql server, i'm trying calculate value based on year date, want sum values july 16, 2012 , prior , display them. i'm using following query (note i've replaced parameters simple integers calculate value today): select sum(case when ( ( dns.oday <= 16 , (dns.fiscalyear + 1) = 13 , dns.omonth = 7 ) or ( (dns.fiscalyear + 1) = 13 , dns.omonth < 7 ) ) dns.qtyshipped else 0 end) shipped_units mytable dns however, query returning 0 rows. if replace dns.qtyshipped integer, 1, still returns 0. case statement isn't being evaluated correctly. logic flawed? or syntax issue (e.g. need more parentheses)? thanks! additional comments: to test, i've ran following query: select sum(dns.qtyshipped) mytable dns (dns.oday <= 16 ...

internet explorer - why jquery not working in IE8 , but in chrome/firefox -

i have problem jquery code in ie 8. have script constructs ui dynamically div on load. works fine in chrome , firefox, in ie not load. not log when comes second line below. av.console.debug("start customer ui"); e = $("<div></div>").addclass("av-webassist-main").hide(); av.console.debug("customerui added main container"); it logs first debug in console , nothing after that. page stays blank. if try run second line in console, e = $("<div></div>").addclass("av-webassist-main").hide(); it throws error 'null' null or not object clueless how debug this. using jquery-1.9.1.js. remove or comment out console.debug lines. ie chokes on them unless console open.

python - Finding whether a list contains a particular numpy array -

import numpy np = np.eye(2) b = np.array([1,1],[0,1]) my_list = [a, b] a in my_list returns true , b in my_list returns "valueerror: truth value of array more 1 element ambiguous. use a.any() or a.all()". can around converting arrays strings or lists first, there nicer (more pythonic) way of doing it? the problem in numpy == operator returns array: >>> == b array([[ true, false], [ true, true]], dtype=bool) you use .array_equal() compare arrays pure boolean value. >>> any(np.array_equal(a, x) x in my_list) true >>> any(np.array_equal(b, x) x in my_list) true >>> any(np.array_equal(np.array([a, a]), x) x in my_list) false >>> any(np.array_equal(np.array([[0,0],[0,0]]), x) x in my_list) false

Angularjs - use $watch on an element with no ng-model -

i trying recaptcha working (cleany) angularjs. the recaptcha being created in directive. callback function, trying $watch changes in inputs (recaptcha_challenge_field, recaptcha_response_field) i can pass values scope : scope.recaptcha_challenge_field = "value_taken_from_input_after_creation" my problem recaptcha code being created without me can not add ng-model inputs. when scope.$watch('recaptcha_response_field', function(newvalue, oldvalue) { console.log('recaptcha_response_field ' + newvalue); }); nothing happens because scope.recaptcha_challenge_field not linked <input name="recaptcha_response_field" id="recaptcha_response_field" type="text"> my ideas : add dynamically ng-model inputs can't figure 1 out bind values input element , watch them open suggestion. thanks without knowing recapthca library using, can shoot in dark. is get var recaptchaelement = angular.element(......

php - Implementing Custom user login module in wordpress -

i want implement custom login module inside wordpress. in home page, have form users register , form users can login website. is better idea write custom code inside wordpress accomplish goal? what other alternative suggest ? nothing wrong writing custom code if need specific happen when user logs in. other writing custom code built plugin!

c# - Local variables or class fields? -

i read today post performance improvement in c# , java. i still stuck on one: 19. not overuse instance variables performance can improved using local variables. code in example 1 execute faster code in example 2. example1: public void loop() { int j = 0; ( int = 0; i<250000;i++){ j = j + 1; } } example 2: int i; public void loop() { int j = 0; (i = 0; i<250000;i++){ j = j + 1; } } indeed, not understand why should faster instantiate memory , release every time call loop function done when simple access field. it's pure curiosity, i'm not trying put variable 'i' in class' scope :p true that's faster use local variables? or maybe in case? stack faster heap. void f() { int x = 123; // <- located in stack } int x; // <- located in heap void f() { x = 123 } do not forget the principle of locality data . local data should better cached in cpu cache. if data close, loaded ...

UPDATE c# MySQL syn -

i want update table time difference between 2 events. i've implemented code: timespan ts = vett[0] - vett[1]; mysqlcommand cmdup = new mysqlcommand(); cmdup.commandtext = "update event_move set diff_time=" + ts + "where id_event_move=" + id_move[0]; cmdup.connection = myconn; myconn.open(); cmdup.executenonquery(); myconn.close(); my visual studio 2010 indicates syntax error @ line cmdup.commandtext = ... might me? in advance the source of mistake missing space giovanni says. tip use string.format method. cmdup.commandtext = string.format("update event_move set diff_time={0} id_event_move={1}", ts, id_move[0]); have used this, spot missing space immediately.

file io - Reading a specific text in Java -

this kind of followup other question simple java regex read between two now code looks this. reading contents of file, scanning whatever between src , -t1. running code return 1 correct link source file contains 10 , can't figure out loop. thought way might write second file on disk , remove first link original source can't code either: file workfile = new file("page.txt"); bufferedreader br = new bufferedreader(new filereader(workfile)); string line; while ((line = br.readline()) != null) { //system.out.println(line); string url = line.split("<img src=")[1].split("-t1")[0]; system.out.println(url); } br.close(); i think want like import java.util.regex.*; pattern urlpattern = pattern.compile("<img src=(.*?)-t1"); while ((line = br.readline()) != null) { matcher m = urlpattern.matcher (line); while (m.find()) { system.out.println(m.group(1)); } } the ...

sqldatareader - C# retrieve data from database - unknown datatype and unknown column name -

i'm trying retrieve user selected data database. user can select 5 fields show in report , fields mixture of strings, dates , numbers. cannot convert data strings in sql code due other reports being run. since don't know datatype, can't datareader.getsqlstring(column), , since don't know name of column user may have selected, can't datareader.getstring(datareader.getordinal(columnname)). ideas on how retrieve values database without knowing either datatype or column name? thanks in advance. you can use reader.getschematable() table of schema of data reader or reader.gettype(n) or reader.getproviderspecifictype(n) datatype of particular field. you can use information decide method call: if (reader.gettype(n) == typeof(string)) { string value = reader.getstring(n); }

indexing - SQL Server 2012 Avoiding Index Scan for Aggregate? -

i have large select statement, index scan taking 83% of time, , takes many seconds return when there 700k rows. made subset of here: set nocount on create table #scanme ( lookid int identity primary key , stateid tinyint ) create nonclustered index scanstateid on #scanme (stateid) stateid in ( 0 ) go insert #scanme values ( 0 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 2 ) ; insert #scanme values ( 2 ) ; insert #scanme values ( 2 ) ; insert #scanme values ( 2 ) ; insert #scanme values ( 2 ) ; insert #scanme values ( 2 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 0 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 2 ) ; insert #scanme values ( 0 ) go insert #scanme values ( 0 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 1 ) ; insert #scanme values ( 2 ) ; i...

xml - Nunit loads all test Test data for all the test before the test gets executed -

i using nunit. loads test test data test before test gets executed.i want why happening . want if there other effective way load data.i have posted code use below , data source xml private ienumerable example { { return getexample; } } private ienumerable getexample() { var doc = xdocument.load("example.xml"); return examples in doc.descendants("example") let example1 = examples.attribute("example1").value let example2 = examples.attribute("example2").value let example3 = examples.attribute("example3").value select new object[] { example1, example2, example3}; } [testcasesource("example")] public void shouldlogin(string username, string password, bool expected) { // test uses data above } <?xml version="1.0" encoding="utf-8" ?> <examples> <example example1="fsse" example2="dj7sihfs" example3="true...

javascript - fadein fadeout jquery on mouse-over -

i have 3 sections default logo...left,middle , right..on mouse on sections changing 1 one own respective logo. when mouse-over left section has changed logo problem when mouse-over logo on left section turned default section ( means left section vanished along logo)that don't want. i need mouse effect off when mouse-over left section logo, same thing applicable on other 2 section.. the html : <div id="container"> <div class="logo"> <img src="http://wphooper.com/svg/examples/circle_filled_with_pattern.svg"> </div> <div class="main" id="left"> <div class="dot1-top"> <img src="http://www.subblue.com/assets/0000/2881/circle-guide_square.gif" width="53" height="52" alt=""> </div> <div class="showhide"> <div class="main1 hide" style=...

List accessing in Python -

i have 2 list this nodelist1=[[['b', 10], ['in', 1000]], [['c', 15], ['out', 1001]], [['f', 30], ['in', 1100]]] nodelist2= [[['g', 20], ['in', 1000, 'out', 1111]], [['d', 25], ['inward', 1]]] what trying comparing these 2 lists if len(nodelist1[i][1])==len(nodelist2[j][1]) if condition true want remove nodelist1[i][0] ['b', 10] , nodelist1 , nodelist2[j][1] ['d', 25] nodelist2 . then should have nodelist1 [[['c', 15], ['out', 1001]], [['f', 30], ['in', 1100]]] nodelist2 [[['g', 20], ['in', 1000, 'out', 1111]]] my code this: if len(nodelist1)>len(nodelist2): in range(len(nodelist1)): j in range(len(nodelist2)): if len(nodelist1[i][1])==len(nodelist2[j][1]): if nodelist1[i][1]==nodelist2[j][1]: nodelist1.remove(nodelist1[i]) ...

Stop jQuery anitmation with media query -

hello guys have simple jquery animation $(window).load(function() { //top header logo expand $("#logo-expand").mouseenter(function() { $(this).animate({ width: "170px" }, 300 ); }); $("#logo-expand").mouseleave(function() { $(this).animate({ width: "56px" }, 300 ); }); }); now want disable animation when in phone resolution, how can jquery media queries, idea? here's http://jsfiddle.net/myknb/5/ thank in advance you can use window.innerwidth determine width of screen , perform animation if greater width $(window).load(function() { if (window.innerwidth > 700){ //top header logo expand $("#logo-expand").mouseenter(function() { $(this).animate({ width: "170px" }, 300 ); }); $("#logo-expand").mouseleave(function() { $(this).animate({ width: "56px" }, 300 ); } }); });

php - connect to existing database in laravel 4 -

i have started using laravel 4 , have been reading "code bright". attempting migrate 1 of applications laravel framework. have seen how create new database using schema builder , migrations, have database few tables , hundreds of rows. how use models in laravel 4 query database? have added connection in config. you have create models each table. if table name plural, best use it's singular name class name model. for cases doesn't work (where name may not plural or ends in 'ies' may confuse laravel), set property protected $table = 'tablename'; coincide table wish create model for. after that, follow documention on eloquent setting relationships may need make. it may possible, , idea, make migrations each of tables, though may quite time consuming. you'd have make each migration file fill out migrations table laravel uses hand.

In SharePoint How to create a form that changes based on a drop down selection -

i need create dynamic form/workflow in sharepoint. trying create form has drop-down selector 2 options projects , proposals . depending on of 2 submitter chooses form change fields displayed in form below them. the goal have form populate 1 list , populate different fields depending on form type chosen. is doable? our sharepoint environment being provided microsoft's office365 solution. did try content types ? you'll not drop-down (however i've seen drop-down document libraries content types), can achieve target: when creating new item can select type of item create (project or proposal) , when you'll fields according content type. data stored in same table.

windows - String manipulation using batch -

below crud output of batch script "kxip12","triss-s16-vm","","triss-db02-vm","false","true","false","mysql","false"," "," ","ptroweutil","ptrowetp","false","172.17.6.167:7081,172.17.6.248:7081,172.17.1.93:7081,172.17.6.167:7081","64","18","18","512"," "," ","true","foo","bar","raid:12345",""," ","","tp.cfg:tp.remotedinterface.active=false","tp.cfg:tp.loopbackdestination.count=1","tp.cfg:tp.trading.orderhistoryreflected=true","tp.cfg:tp.glueinterface.acceptorservice_tcp=gatedev28z3.itgssi.com:32101","","","","","","","","","","","","","",...

html5 - Drop Down Menu not pushing the contents down in IE7 -

i new on forum. i developing website using html5 , css responsive design. have navigation menu behaves simple drop down menu desktop , laptop but tablet , mobile has menu button by clicking on menu button, alternatively appear , disappear display:blocks otherwise display:none , pushes contents of main area downward all works fine in firefox, chrome , ie not pushing contents down in ie7 i stuck here since 2 days here html code <div id="wrapper"> <header id="topheader"> <div id="topdiv"> <div id="maindiv"> <div id="logo"> <div itemscope itemtype="http://schema.org/organization"> <a itemprop="url" href="/default.aspx"> <img itemprop="logo" src="/app_themes/default/images//logo.png" alt=""> </a> </div> </div> <div id="navdiv"> <nav id="nav"> <u...

in app purchase - In-App Coins purchased through web browser -

i working develop ios mobile app version of online game uses in-game coins enhance game play. ideally, sell these coins through both iap , through user's account on web version of game. having difficult time parsing whether or not allowed apple , wondering if has similar experience. according apple's terms: 11.2: apps utilizing system other in app purchase api (iap) purchase content, functionality, or services in app rejected but also: 11.14 apps can read or play approved content (specifically magazines, newspapers, books, audio, music, , video) subscribed or purchased outside of app, long there no button or external link in app purchase approved content. apple not receive portion of revenues approved content subscribed or purchased outside of app. [this last earlier version of rules, still seems case -- can purchase subscription pandora on web or through iap, right?] i know can't put link web version in app, , can't advertise within app can purchase co...

Symfony - translations stop working after rendering controler in another's view -

i'm building webiste, there lots of "widgets" displayed on front page. 1 of them calendar. wanted make new controller each "widget", , render them (like example below), in homepage view. hovewer - translations stop working after that. if visit mywebpage/calendar , work, not when got mywebpage/home . this code have homepage view. {% block calendar %} {{ render(controller('mywebsite:calendar:index')) }} {% endblock %} am approaching correctly or not? , why translations stop working? - hope understand issue :) thanks! i surprised doesn't work, have else in app interfering request object? maybe passing locale request argument controller may work (although bit of hack)? {% block calendar %} {{ render(controller('mywebsite:calendar:index', { _locale: app.request.locale })) }} {% endblock %}

php - Confusion- Should I use CodeIgniter or something else for below case -

as have never develop web-app scrach. want know that: background: i have develop web-app database on other machine [say server], , every communication database has done using soap web service [database on server]. i'm looking forward use codeigniter framework achieve this. as codeigniter mvc based, has divided module - can storage view - can output controller - can communicator between view , module confusion: can use condigniter app database remote. as have seen tutorials , examples, of based on local database. so can guide me, possible have communication database in same framework. as have followed tutorials, flow like(for local database) request: view -> controller -> module response: module -> controller -> view so please tell me,how in codeigniter framework? possible? can done? i'm confused,how run app without local database/how can communicate soap services using model class. or do? or should move core php,if not possible in c...

c++ - Find string using a bisectional search in linked list -

i have find function searches linked list of strings sequentially. find functions finds string , returns it. have remove function uses find function , removes string linked list. both of functions work. however, im trying test way search linked list , wondering if possible bisectional search in linked list. heres code: find stringlist::stringlistnode *stringlist::find(const string &s) //basic search function { stringlistnode *sp = ptop; // search while (sp != 0 && sp->data != s) sp = sp->pnext; return sp; } here remove function: void stringlist::remove(string s) { stringlistnode *curr = this->find(s); if (curr->pprev != 0) { curr->pprev->pnext = curr->pnext; } if (curr->pnext != 0) { curr->pnext->pprev = curr->pprev; } if (ptop == curr) { ptop = curr->pnext; } if (pbottom == curr) { pbottom = curr->pprev; }...

Post javascript variables to separate .PHP file (Using Ajax?) -

i have 2 files, 1 runs calculations in php once , stores them variables in javascript. second file holds mysql query sent database. how can send javascript variables first file, second file , store them variables. -i loading second .php file using .load() function. not refreshing , re- directing second .php file. is possible out ajax? if possible ajax, how set (new ajax) ? $("#st").click(function() { var s = $("#st").val(); var = $("#aa").val(); var t = ((s*1)*(a*1)+(a*1)*(1/3)).tofixed(2); var c = (t*95).tofixed(2); var text = $('#st').children("option:selected").text(); document.getelementbyid('tim').innerhtml ='<p>'+ t +' </p>'; document.getelementbyid('obj').innerhtml ='<p>'+ text +'</p>'; document.getelementbyid('tot').innerhtml ='<p>$'+ c +'</p>'; }); var customer = <?php echo json_encode($q);?>; var dr= <...

c# - failed to publish: could not find required file 'setup.bin' -

Image
this question has answer here: could not find required file 'setup.bin' 4 answers i have sample console application testing mysql connectivity. code below. using system; using system.collections.generic; using system.linq; using system.text; using mysql.data; using mysql.data.mysqlclient; namespace mysqlconnection { class program { static void main(string[] args) { string connstr = "server=localhost;user=root;database=world;port=3306;password=password;"; using (mysqlconnection conn = new mysqlconnection(connstr)) { conn.open(); string sql = "select count(*) country"; mysqlcommand cmd = new mysqlcommand(sql, conn); object result = cmd.executescalar(); if (result != null) { ...

jquery - if else statement has no effect - javascript -

i have bootstrap modal box contains signup form. i've added code makes modal box disappear when submit button pressed: $(".dismiss-signup-modal").click(function () { jquery('#signup_modal').modal('hide'); } }); this works fine want make modal box stay if phone number field of signup form blank , disappear if phone number field has value, this: $(".dismiss-signup-modal").click(function () { if ($('.signup-phone').length > 0) { jquery('#signup_modal').modal('hide'); } else {} }); but above code doesn't anything, modal box still disappears if phone number field left blank. i've tried every combination can think of placing if else statement outside function or creating new function or making .signup-phone var nothing works, ideas? thanks you need check length of value .. but checking existence of jquery object (if element exists or not) supposed if...

objective c - AppLovin FullScreen ad not working in Cocos2d iOS -

Image
i followed applovin sdk integration guide here: https://www.applovin.com/integration code: [alsdk initializesdk]; [alinterstitialad showover:viewcontroller.view.window]; not getting part of doc: its working now. need add right bundle id , applovinsdkkey in info.plist

Possible to move <menu <item android:onClick=method>> to different class? -

my main activity class contains oncreate(bundle), oncreateoptionsmenu(menu menu), onprepareoptionsmenu(menu menu) methods, , of android:onclick= methods (there many). i reduce number of methods in main activity class, if possible. "is possible move onclick methods different class"? thanks help. you can create different class implements view.onclicklistener . in main activity code can use setonclicklistener on components want move click listener of , give class implements view.onclicklistener parameter. edit: here link view.onclicklistener page on android developer website http://developer.android.com/reference/android/view/view.onclicklistener.html

android - Is there a way to specify a URI other than localhost for webbit? -

so trying create server in android application onto remote uri , tried using createwebserver(), seems doesn't work because cannot access address on computer. server = webservers.createwebserver(executors.newcachedthreadpool(), new inetsocketaddress(hostname,port), uri.create(hostname + ":" + port)); does know how using webbit?

How can I set a flag in javascript for a google chrome extension -

i have twitter scanner (a google chrome extension), want execute if statement once. after still want able scan other shoename , flag set keeps getting reset. here code: function twitterscan() { (var = 0; < 4; i++) { tweetname[i] = document.getelementsbyclassname("fullname js-action-profile-name show-popup-with-id")[0].innerhtml; tweet[i] = document.getelementsbyclassname("js-tweet-text")[i].innerhtml; } var flag = true; var flag1 = true; //if (document.getelementsbyclassname("fullname js-action-profile-name show-popup-with-id")[0].innerhtml; if (tweet[0].match(shoename) == shoename && flag == true||(tweet[0].match(shoename1) == shoename1 && flag1 == true) { if(tweet[0].match(shoename) == shoename) flag = false; if(tweet[0].match(shoename1) == shoename1) flag1 = false; document.getelementsbyclassname("twitter-timeline-link")[0].cl...

javascript - Hide Image when another image is clicked -

this seems simple.. bit noobish jquery, maybe doing silly wrong? i want click image, , on click, hide image right next it. <script type="text/javascript"> $("#butshowmesomeunits").click(function() { $('#arrowunitspic').hide(); }); </script> id's correct per 2 images. missing? debugging it, code never gets fired... thanks edit i had control nested control on asp masterpage, , id being rewritten. have fixed id, still cant joy... see markup being rendered "input", make difference? <head> <script src="js/jquery.min.1.5.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("#butshowmesomeunits").click(function () { $('#arrowunitspic').hide(); }); }); </script> </head> <body> <input ty...

html5 - CLOSED - Drag and Drop in HTML - Drop Between Boxes JavaScript -

greeting. working on slideshow creator uses html5 drag , drop api. these api have been able create grid of user uploaded images. these images can rearranged in order like, swapping 1 one. able able drop image on top of image, causing images in front of moved right. i.e insert new image, , drop on image 5. wasnt excisting image 5 moved box 6, 6 7, 7 8, , on , forth. able insert images way, verses swapping them.. cant figure out how accomplish this. here code var dragsrcel = null; var cols = document.queryselectorall('#columns .column'); [ ].foreach.call(cols, function (col) { col.addeventlistener('dragstart', handledragstart, false); col.addeventlistener('dragenter', handledragenter, false) col.addeventlistener('dragover', handledragover, false); col.addeventlistener('dragleave', handledragleave, false); col.addeventlistener('drop', handledrop, false); col.addeventlistener(...

user interface - customizing UIStepper's layout (iOS) -

i'm writing ui ipad app , need create stepper widgets. traditional uistepper looks this: [value being changed][+][-] and need make stepper looks like: [-][value being changed][+] i guessing need roll own control, before that, i'd curious know if knows if traditional uistepper can changed need. it might possible using images doubt want that. roll own uicontrol. there few out there seem old , not maintained.

dbm - Use shell script wrapper to enter commands into a new shell -

to begin, don't know if have worded title correctly, here goes. i trying enter commands shell script in following mannger: #!/bin/sh dbm2 table the_table however, after command dbm2 run, current shell gets replaced dbm2 shell, , can no longer continue shell wrapper script. manually, done following: server_name% dbm2 dbm: no table> table the_table this bring the_table table dbm2. how can use shell wrapper script replace manual procedure entering commands new shell generated shell script? if sequence of commands fixed (does not change run run), might able use: #!/bin/sh dbm2 <<eof table the_table ...other commands... eof ls # demonstrate shell continues the <<eof notation here-doc. lines line containing eof input command dbm2 . if content of commands needs vary, may able pipe input dbm2 . in script, if manually enter commands dbm2 , quit, original shell script should continue. table the_table line treated shell command , wou...

c# - MVC 4 Web API + EntityFramework: Handling external resource dependencies -

so have situation lets i'm making 2 apis; car api , autoservice api. car api manages resources related car entities. autoservice api manages resources related auto service retail entities provide repair service cars. lets application uses both api. creates auto service entity particular car entity. uses car api create/edit car resource , passes autoservice api create service log particular car entity. means service log entity in autoservice api referencing entity external resource api. the question becomes, best practice handle dependency? original idea create 2 properties in service entity; externalowner , externalownerhost. externalowner entity map id of car entity. externalownerhost describe origin of external owner, lets /auto/car . association in place, create convention application client figure out on own how access external owner entity given externalownerhost. example, application should smart enough know use get /auto/car?fields= given knows host of resource. bes...

c++ - Error LNK1561: entry point must be defined- main() exists -

i know question has been posted elsewhere, , i've tried solutions, error lnk1561 , have no clue causing problem. program calculates , prints largest, smallest, average, , sum of sequence of numbers user enters. questions or if need more info, ask. #include <iostream> #include <climits> using namespace std; template <class t> t dataset(t &sum, t &largest, t &smallest, t avg); template <class t> int main(){ cout << "this program calculates , prints largest, smallest," << endl << "average, , sum of sequence of numbers user enters." << endl; t avg, sum, largest, smallest; avg = dataset(&sum, &largest, &smallest, avg); cout << "the largest of sequence entered is: " << largest << endl; cout << "the smallest of sequence entered is: " << smallest << endl; ...

assembly - How does the linker find the main function? -

how linker find main function in x86-64 elf-format executable? a generic overview, linker assigns address block of code identified symbol main . symbols in object files. actually, doesn't assign real address assigns address relative base translated real address loader when program executed. the actual entry point not main symbol in crt calls main. ld default looks symbol start unless specify something different . the linked code ends in .text section of executable , (very simplified): address | code 1000 somefunction ... 2000 start 2001 call 3000 ... 3000 main ... when linker writes elf header specify entry point address 2000. you can relative address of main dumping contents of executable objdump . actual address @ runtime can read symbol funcptr ptr = main; funcptr defined pointer function signature of main . typedef int (*funcptr)(int argc, char* argv[]); int main(int argc, char* argv[]) { funcptr ptr = main; printf...

c - Issue with array of pointers -

i'm writing program alphabetize inputted names , ages. ages inputted separately, know need use array of pointers tie ages array of names can't quite figure out how go doing it. ideas? so far, program alphabetizes names. /* program alphabetize list of inputted names , ages */ #include <stdio.h> #define maxpeople 50 #define strsize int alpha_first(char *list[], int min_sub, int max_sub); void sort_str(char *list[], int n); int main(void) { char people[maxpeople][strsize]; char *alpha[maxpeople]; int num_people, i; char one_char; printf("enter number of people (0...%d)\n> ", maxpeople); scanf("%d", &num_people); scanf("%c", &one_char); while (one_char != '\n'); printf("enter name %d (lastname, firstname): ", ); printf("enter age %d: ", ); (i = 0; < num_people; ++i) gets(people[i]); (i = 0; < num_people; ++i) alpha[...

jquery - YouTube Playlist Pagination -

i trying pull videos youtube playlist jquery , display them kind of pagination or perhaps next/prev links. based on code found here have figured out how pull first group of videos. can see working here on jsfiddle function loadvids(startindex){ if (typeof startindex === "undefined" || startindex===null) startindex = 1; var maxresults = 25; var playlisturl = 'http://gdata.youtube.com/feeds/api/playlists/pl3b8939169e1256c0?orderby=published&v=2&alt=json&&start-index=' + startindex + '&max-results=' + maxresults; var videourl= 'http://www.youtube.com/watch?v='; $.getjson(playlisturl, function(data) { var list_data=""; $.each(data.feed.entry, function(i, item) { var feedtitle = item.title.$t; var feedurl = item.link[1].href; var fragments = feedurl.split("/"); var videoid = fragments[fragments.length - 2]; ...

java - Hadoop MapReduce producing log files only after certain interval? -

so have been trying run hadoop mapreduce job while, , after started running (all errors sorted out), wanted check log files stdout captured in log files, somehow see log files aren't being generated every time. (some times comes, other time doesn't) i using output directory ( /user/hduser/output_dir ), , deleting contents , using again (to avoid keeping track of many output directories) log files indicate time when last change made it, , not match last time ran job. also, log files in /user/hduser/output_dir not match $hadoop_home/logs/userlogs known problem, , there solution this? did not find answer anywhere. help.! edit - found out log files being written after intervals of time, if job run twice within time new log files aren't written that. why so, , how can override using configuration changes, if it's possible?

python - Matplotlib figures not changing interactively - Canopy Ipython -

i trying use ipython in canopy matplotlib prepare graphs (backend set qt). wrote following code line line int terminal import matplotlib.pyplot plt fig = plt.figure() s = fig.add_subplot(1,1,1) after second line can see figure being made. after third line not see sub plot being created. if print fig, sub-plot can seen both inline , in figure window created. sub-plot magically appears if try zoom. similar thing happens every time plot on figure. old version displayed till either print figure or if try modify view using gui tools. annoying. great if tell me problem is. edit: tried using fig.show() not work. when use plt.plot() directly, there seems no problem. problem comes when use fig or of subplots type: fig.show() when need update it.

ibm mobilefirst - IBM Worklight - Can we create a desktop based application? -

Image
can create desktop application using worklight? for example, can create desktop based applications using adobe air, titanium, rcp, etc. what such type of applications can develop using worklight? if click on worklight icon, can create worklight environment associated worklight project. example on worklight 5.0.6 other information here

php - Using AJAX to send data to Coder Igniter controller function results in a 500 Internal Server Error -

i trying use ajax send data code igniter view controller handle data needed. i'm gathering data using jquery plugin (handsontable) , when user hits "save" button extracts required data table , executes ajax function. $.ajax({ url: "/survey/save", data: {"data": data}, type: "post", }); i able send regular .php file collects data $_post not controller. public function save() { $data = $this->input->post('data'); $myfile = "testfile.txt"; $fh = fopen($myfile, 'w') or die("can't open file"); ($i = 0, $size = count($data); $i < $size; ++$i) { fwrite($fh, $data[$i][0]."\t".$data[$i][1]."\t".$data[$i][2]."\n"); } fclose($fh); } the above code not want controller if can execute code, able wish. i have feeling has url of ajax function extremely new of these languages , overlooking simple. please let me know if...

python - Concurrent Remote Procedure Calls to C++ Object -

i have class written in c++ acts remote procedure call server. i have large (over gigabyte) file parse, reading in parameters instantiate objects store in std::map. rpc server listen calls client, take parameters passed client, appropriate value in map, calculation, , return calculated value client, , want serve concurrent requests -- i'd have multiple threads listening. btw, after map populated, not change. requests read it. i'd write client in python. server http server listens post requests, , client can use urllib send them? i'm new c++ have no idea how write server. can point me examples? maybe factors can affect selection. one solution use fastcgi. client sends http request http server has fastcgi enabled. htp server dispatch request rpc server via fastcgi mechanism. rpc server process , generates response, , sends http server. http server sends response client.

jquery: If statement not working inside ajax success function -

i have success function in ajax returns response text python script can either "success" or "empty". want place if-loop inside success function, if-loop not working. getting correct data python script because alert statement working fine , printing "success". not enter ifloop i have tried bunch of things control not entering if-loop, please tell me doing wrong: submithandler: function (form) { $.ajax({ type: 'post', url: '/cgi-bin/getdataworld.py', data: $(form).serialize(), success: function(data) { //document.write(result); console.log("result "+data); alert(data); if(data === "success"){ window.location = 'index.html'; } ...

Java generics wildcard entry -

in java generics, why not valid: list<?> l = new arraylist()<?>; considering valid: public interface somelist<?>{} there both unbounded wildcards. in mind both equivalent to: list l = new arraylist(); and public interface somelist {} where going wrong? list<?> means one type. programmer benefit typechecking designers desided need supply one type during instantiation. if want full flexibility, list<?> l = new arraylist<object>() way go. the wildcard ? means of saying, yes want generics don't care of type. unlike generic-less variant, still type checking , compiler warnings necessary.

c# - What can cause dictionary.ContainsKey(dictionary.Keys.First()) to return false? -

dictionary.keys.first().gethashcode() == dictionary.keys.first().gethashcode() returns true dictionary.keys.first() == dictionary.keys.first() returns true what's missing? why can't dictionary find object? type of dictionary: dictionary<exceptionwrapper<exception>, list<int>> . here implementation of exceptionwrapper.equals , exceptionwrapper.gethashcode : public override int gethashcode() { return (typeof(texception).fullname + exception.message + exception.stacktrace).gethashcode(); } public override bool equals(object obj) { return obj exceptionwrapper<texception> && (obj exceptionwrapper<texception>).gethashcode() == gethashcode(); } the key first added dictionary<,> when had 1 hash code. after object "mutated" give state hash code new number. the dictionary<,> therefore in invalid state. do not mutate object might key in hashtable somewhere, in way changes hash code of obje...

javascript - replace only some value from json to json -

here example: i have jsona { "a":"1", "b":"2", "c":{"a":"1", "b":"2"} } and jsonb { "b":"2new", "c":{"a":"1new"} } i want update first jsona new value in jsonb and, @ end, have result: { "a":"1", "b":"2new", "c":{"a":"1new", "b":"2"} } manually set every value, like: jsona.b = jsonb.b; jsona.c.a = jsonb.c.a; there way automatically without check every valule foreach? i wrote this: jsona = { "a":"1", "b":"2", "c":{"a":"1", "b":"2"} } jsonb = { "b":"2new", "c":{"a":"1new"} } (var j in jsona) { if(jsonb.hasownproperty(j)) { if (typeof jsona[j] === 'object') { ...

windows server 2008 - Group Policy Object Creation Failed - This security ID may not be assigned as the owner of this object -

we have windows sbs 2008 domain controller (the 1 in our domain) , i'm trying create new group policy object handle printers. every time attempt create new gpo, either in group policy folder directly or linked in 1 of organizational folders receive following message - "this security id may not assigned owner of object." i've been looking around haven't found works. results search indicate people having trouble folder redirection policies. have folder redirection enabled, every workstation in domain running windows 7 professional, , no 1 having trouble redirection policy. i've double-checked sysvol directory , both system , administrators have appropriate rights. i've added sysadmin account group policy creator owners group (which again, has rights sysvol) still nothing. i've been @ day , i'm coming empty. there's nothing in event view logs, , created administrative level user or copy/pasting existing gpo. same message everytime. started hap...

php - readimageblob: Fatal Error when converting SVG into PNG -

i'm trying use image-magick php convert svg text png image. svg chart generated nvd3 , i'd allow users download image. basically, i'm sending svg data, encoded json php handler supposed output png image. but, throws following error: fatal error: uncaught exception 'imagickexception' message 'no decode delegate image format `' @ blob.c/blobtoimage/347' in svg2png.php:4 stack trace: #0 svg2png.php(4): imagick->readimageblob(' the php script converting image: <?php /* derived in part from: http://stackoverflow.com/a/4809562/937891 */ $svg=json_decode($_request["svgdata"]); $im=new imagick(); $im->readimageblob($svg); $im->setimageformat("png24"); header("content-type: image/png"); $thumbnail = $im->getimageblob(); echo $thumbnail; ?> html: <form id="exportspendtrendtrigger" method="post" action="svg2png.php" target="_...

Rails 4 - saving object with nested attributes -

i have parent model has 1 child model nested attributes. have single form updates both parent , child. here models: class parent < activerecord::base has_one :child accepts_nested_attributes_for :child end class child < activerecord::base belongs_to :parent end form view: <%= form_for @parent, |f| %> <%= f.text_field :parent_name %> <%= f.fields_for @parent.child |c| %> <%= c.text_field :child_name %> <% end %> <%= f.submit "save" %> <% end %> parent controller: class parentscontroller < applicationcontroller def update @parent = parent.find(params[:id]) @parent.update(params.require(:parent).permit(:parent_name, child_attributes: [:child_name])) redirect_to @parent end end when save form, parent updates child doesn't. doing wrong? you have problem in nested part of form code, should be <%= form_for @parent, |f| %> <%= f.text_field :pare...