Posts

Showing posts from July, 2014

Is there a C# String.Format() equivalent in JavaScript? -

this question has answer here: equivalent of string.format in jquery 19 answers c# has powerful string.format() replacing elements {0} with parameters. javascript have equivalent? try sprintf() javascript . or // first, checks if isn't implemented yet. if (!string.prototype.format) { string.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); }; } "{0} dead, {1} alive! {0} {2}".format("asp", "asp.net") both answers pulled javascript equivalent printf/string.format

java - Running caliper from eclipse in maven's test scope -

i have java project in eclipse, junit tests in src/test directory. i've added class tests caliper microbenchmarks, , i'd able run these tests within eclipse. as caliper code test code, i've added caliper dependency in maven in test scope. makes show in classpath when run junit tests, can't see way run arbitrary class test dependencies in classpath. tried doing adding new run configuration java application, thinking launch calipermain right class parameter, caliper jar not on classpath , can't see how add it. i don't want move benchmark code , dependency main scope, it's test code! seems overkill move separate project. you should able maven exec plugin . project, opted make benchmark profile can run maven command mvn compile -p benchmarks . to configure this, can add along lines of following pom.xml , specifying scope of classpath test using <classpathscope> tag: <profiles> <profile> <id>benc

if statement - Common If Structure -

more , more find myself writing structure of if statements looks this: if(something) { if(somethingelse) { // if both evaluate true. dosomething(); } else { // if first if true second not. dosomethingelse(); } } else { // if first evaluates false. dosomethingdifferent(); } now, me, looks horrific. have cleaner way of representing logic? the question as-is has 3 cases: something & somethingelse , something & !somethingelse , , !something . alternative break out if-else 3 branches: if(something & somethingelse) { // if both evaluate true. dosomething(); } elif(something) { // explicit test of somethingelse falsity not required // if first if true second not. dosomethingelse(); } else { // if first evaluates false. dosomethingdifferent(); } for such simple case, prefer flatten structure above. more complex cases, can end being simpler nest, or better reduce tests kind of structure (a l

json - Preserve column names when converting the results of a query to hstore -

i have table users columns user_id , user_name , user_phone example. if do: select hstore(u) users u the result is: "user_id" => "1", "user_name" => "mcenroe", "user_phone" => "xxx" if do: select hstore(u) (select user_id, user_name, user_phone users) u the result is: "f1" => "1", "f2" => "mcenroe", "f3" => "xxx" i lose name of columns. how can use 2nd example , having correct column name? this shortcoming fixed postgres 9.2 . quote release notes 9.2 here : e.5.3.3. queries (...) retain column names @ run time row expressions (andrew dunstan, tom lane) this change allows better results when row value converted hstore or json type: fields of resulting value have expected names. also, don't use user table name, if it's demo. reserved word in every sql standard , in postgres

Struts2 json model -

i following problems when enter action: struts problem report struts has detected unhandled exception: messages: java.lang.reflect.invocationtargetexception org.apache.struts2.json.jsonexception: java.lang.reflect.invocationtargetexception org.apache.struts2.json.jsonexception: org.apache.struts2.json.jsonexception: java.lang.reflect.invocationtargetexception file: model/empresa.java line number: 34 //action private static final long serialversionuid = 1l; private sincronizaservice service = new sincronizaserviceimp(); //your result list private list<sincroniza> gridmodel; //get how many rows want have grid - rownum attribute in grid private integer rows = 0; //get requested page. default grid sets 1. private integer page = 0; // sorting order - asc or desc private string sord; // index row - i.e. user click sort. private string sidx; // search f

java - Dynamically build table from bean -

i'm building application lot of tables (or forms) representing details of given data row. quite big , not nice have add fields (with handler, logic, etc.) 1 one. what have factory able build form (or table) given bean. created pretty nice factory using java reflection discover gwt not support it... is there suit needs? because gwt's compilation monolithic (there can no class that'd unknown @ compile-time used @ runtime), means code generated. because can generated, means can during gwt compilation using so-called deferred binding . gwt generator can use reflection on classes known @ compile-time, it'll distinct api java.reflect (just java annotation processors use distinct api). you common-denominator identify classes need taken account in generation (e.g. implement same marker interface, or extend same base class) , generate 1 table/form each, , either: an interface type parameter object edit/render, directly represent generated table/form; yo

Flash/ActionScript - Use .mp3 file in library in a movieclip -

Image
i've imported mp3 file library , made actionscript class, can't access in movieclip. edit: i'm using adobe air, because want compile android application set as linkage sound (in library panel) then paste code in movieclip (first keyframe) var snd:snd=new snd(); snd.play(); hope helps

winapi - How to detect Cameras attached to my machine using C# -

i able know sound devices , usb devices attached pc not getting way find cameras attached machine. used below code sound devices console.writeline("win32 sounddevices\r\n==============================="); managementobjectsearcher searcher = new managementobjectsearcher("select * win32_sounddevice"); foreach (managementobject sounddevice in searcher.get()) { //console.writeline("device found: {0}\n", sounddevice.tostring()); console.writeline("device found: {0}\n", sounddevice.getpropertyvalue("productname")); } console.writeline("search complete."); this tool prove helpful: http://www.microsoft.com/en-us/download/details.aspx?id=8572 i'm there's no equivalent string can send managementobjectsearcher() webcams specifically. there "win32_usbcontrollerdevice" can determine if webcam or not. a better

Booleans in Java -

i beginner , started learn java language. encountered problem in book booleans. don't know how find value of questions , wondering if can give me sample of how code supposed like. appreciated. question in book: suppose value of b false , value of x 0. value of each of following expressions a) b && x == 0 b) b || x == 0 c) !b && x == 0 d) !b || x == 0 e) b && x != 0 f) b || x != 0 g) !b && x != 0 h) !b || x != 0 i don't know how execute problem, help! here how approach problem: recall && , || need boolean on both sides recall ! inverts value of boolean recall binary operations != , == convert pairs of int s boolean s start right side; decide if it's true or false put result line above in expression compute result using truth table corresponding logical operator. let's use first couple of exercises examples: b && x == 0 you know b false , result of and known

python - How to extract and download all images from a website using beautifulSoup? -

i trying extract , download images url. wrote script import urllib2 import re os.path import basename urlparse import urlsplit url = "http://filmygyan.in/katrina-kaifs-top-10-cutest-pics-gallery/" urlcontent = urllib2.urlopen(url).read() # html image tag: <img src="url" alt="some_text"/> imgurls = re.findall('img .*?src="(.*?)"', urlcontent) # download images imgurl in imgurls: try: imgdata = urllib2.urlopen(imgurl).read() filename = basename(urlsplit(imgurl)[2]) output = open(filename,'wb') output.write(imgdata) output.close() except: pass i don't want extract image of page see image http://i.share.pho.to/1c9884b1_l.jpeg want images without clicking on "next" button not getting how can pics within "next" class.?what changes should in findall? if want pictures can download them without scrapping webpage. have same url: http

c++ - Double click, how handle it? -

i trying find out how handle double click left(or any) mouse button. can't find information it. can me? don't want write own double click handler. glfw_repeat doesn't work mouse buttons. what's wrong writing own double click handler? just save time mouse click happens, e.g. std::chrono::high_resolution_clock::now() , , when next mouse click happens, compare times. if under specific value, double click happened.

javascript - jQuery - update function with deprecated toggle() -

this question has answer here: jquery toggle 2 function not work in 1.10.1 7 answers i update website jquery 1.10 use function deprecated toggle() . i remember, having hard time make function works in first time, exists function replace toggle() without changing code. i not jquery expert , appreciated. css: fieldset.collapsed * { display: none; } fieldset.collapsed h2, fieldset.collapsed { display: block !important; } fieldset.collapsed h2 { background-image: url(../img/nav-bg.gif); background-position: bottom left; color: #999; } fieldset.collapsed .collapse-toggle { background: transparent; display: inline !important; } jquery: var spath=window.location.pathname; (function ($) { $(document).ready(function () { function show () { // show $(this).text(gettext("hide")) .

c# - Win32_Service is missing -

i have c# code tries load property wmi object - win32_service. returns me 'system.management.managementexception: invalid class ' error. my simplified code: static void main(string[] args) { string servicename = "appfabriceventcollectionservice"; string propertyname = "startname"; var obj = getproperty(servicename, propertyname); } private static string getproperty(string servicename, string propertyname) { using (managementobject obj2 = getwindowsservicemanagementobject(servicename)) { return (obj2.getpropertyvalue(propertyname) string); } } public static managementobject getwindowsservicemanagementobject(string servicename) { return new managementobject(string.format("win32_service.name='{0}'", servicename)); } also i've tried load list of wmi objects powershell command - get-wmiobject -list | select name it returns 91 objects, misses win32_service object. googled how reinstall it, d

jquery - .each() function showing first object 3 times, instead of all 3 objects -

a query of wordpress custom fields, generates array: array ( [genre] => rock [concert_city] => new york [concert_date] => 01-16-2014 [start_time] => 8:00 pm ) array ( [genre] => jazz [concert_city] => chicago [concert_date] => 12-12-2013 [start_time] => 7:00 pm ) array ( [genre] => pop [concert_city] => los angeles [concert_date] => 11-16-2013 [start_time] => 8:00 pm ) this array stored in: $array = array(); need data jquery. $(document).ready(function() { var event = <?php echo json_encode($array) ?>; $.each(event,function( index, value ){ console.log(event); }); }); this shows me first object 3 times, instead of 3 objects. how can iterate across 3 objects? and need change them index:value, value(concert_date) : value(concert_city), right i'm stuck getting first object in array 3 times, instead of 3 objects. edit : ran console.log(value), , printed v

c# - Enyim Memcached client getting cluster cached item count -

is possible this? think using getvalue method off of stats can request curr_items single server. does know of way through enyim's memcached client in .net retrieve count of items in cache in entire cluster?

Why can't arrays be compared with === in Javascript? -

this question has answer here: how check if 2 arrays equal javascript? [duplicate] 16 answers why isn't code correctly pushing words answer array? when change loop to: (var k in testdict) { console.log(testdict[k].split("").sort()); } it correctly prints i'm expecting, array of split, sorted characters words. i'm not sure why it's not evaluating equal , pushing answer. thanks! function word_unscrambler(word, dict) { var testdict = dict; var answer = []; var word_scrambled = word.split("").sort(); (var k in testdict) { if (word_scrambled === testdict[k].split("").sort()) answer.push(testdict[k]); } console.log(answer); } word_unscrambler("kevin", ["trees", "but", "ankle", "nevik", "knive

jquery - pass two selectors into .parents() method -

there 2 containers 'cont1' , 'cont2'. within each there 1 html element can clicked. want know under container element clicked want check whether clicked element has parent 'cont1' or 'cont2' , one. tried pass these both containers identifiers jquery selector didn't return elements: $(html_elem).click(function(e) { var parent = $(e.currenttarget).parents('#cont1', '#cont2'); //parent undefined }); however, when test whether 1 particular parent there, works $(html_elem).click(function(e) { var parent = $(e.currenttarget).parents('#cont1'); //parent found }); am right assume .parents() method doesn't work multiple selectors? use 1 string, comma contained within. var parent = $(e.currenttarget).parents('#cont1, #cont2');

compiler construction - Using a variable to store a function call? -

let's had pure function takes considerable amount of time run. , in main wanted call function same arguments multiple times. my ultimate question is, should store return value in variable , use or call function multiple times? way take less computations? are compilers modern languages (if any) able tell whether function pure or not? if yes, compilers able optimize away multiple calls in same block? if yes, makes more sense me call functions use placeholder variable (since wasting computation doing assignment/binding names)? edit: here example if mypurefunction(a,b) == 1: print(1) elif mypurefunction(a,b) == 2: print(2) elif mypurefunction(a,b) == 3: print(3) else: print(4) vs. var = mypurefunction(a,b) if var == 1: print(1) elif var == 2: print(2) elif var == 3: print(3) else: print(4) thanks in advance. your answer depends optimization of compiler. if body of function 'mypurefunction()' in same translation unit

go - How to compare two version number strings in golang -

i have 2 strings (they version numbers , version numbers) a := "1.05.00.0156" b := "1.0.221.9289" i want compare 1 bigger. how in golang? convert "1.05.00.0156" "0001"+"0005"+"0000"+"0156", int64. convert "1.0.221.9289" "0001"+"0000"+"0221"+"9289", int64. compare 2 int64 values. try on go playground

sql - FM ExecuteSQL returns different results than direct database query -

i wondering if can explain why different results same query string between using executesql function in fm versus querying database through database browser (i'm using dbvisualizer). specifically, if run select count(distinct imv_itemid) imv in dbvis, 2802. in filemaker, if evaluate expression executesql ( "select count(distinct imv_itemid) imv"; ""; "") then 2898. makes me distrust executesql function. inside of fm, imv table odbc shadow, connected central mssql database. in dbvis, application connects via jdbc. however, don't think should make difference. any ideas why different count each method? actually, turns out when fm executes sql, factors in whitespace, whereas dbvisualizer (not sure other database browser apps, assume it's same) not. also, since trim() function isn't supported mssql (from i've seen, @ least) necessary make query inside of executesql statement like: select count(distinct(ltrim(

iphone - App Store does not show my app after approval -

Image
i developed ios app, , uploaded binary of app on 19th august 2013. today(23rd august 2013) got mail apple saying "your app ready sale " green dot in itunes connect. doesnot show links app in in app store in itunes connect account this first version of app, here screenshot of rights , pricing section itunes connect account. how should live app in app store or automatically live in store ? : thanks in advance. i might wrong, can't remember connect well, been few months since last published app. check following: price tier selected that have selected countries stores app sold (distributed) lastly might take 24 hours app propagate app stores. check again tomorrow on store. release date in order since historic date.

mysql - Create Stored Procedures with PDO in PHP -

i reading text file php , trying execute commands it, creating db , tables , procedures has. code creates tables not create stored procedures given in file. delimiter $$ drop procedure if exists `add_hits`$$ create definer=`root`@`localhost` procedure `add_hits`( in id varchar(255)) begin select hits @hits db_books book_id = id; update db_books set hits=@hits+1 book_id = id; end$$ the pdo not creating sps, how able accomplish task? have tried executing code part , line line, nothing works. trying make db installer script. well, pma helped me answering question of own. overcome need remove delimiter part of procedure, queries become like: drop procedure if exists `add_hits`; create definer=`root`@`localhost` procedure `add_hits`( in id varchar(255)) begin declare hits_bk int; select hits hits_bk db_books book_id = id; update db_books set hits=hits_bk+1 book_id = id; end; now queries work. @your common sense , @riggsfolly helping out.

PHP - Grouping Duration based events / rows into single html blocks -

so i've got bunch of 'events' in table in have start , end column (both datetime). i'm fetching every event single day , somehow need group them can displayed single html block. for example... row #1: has duration of 30 minutes, starts @ 09:00:00 , ends @ 09:30:00 row #2: has duration of 30 minutes, starts @ 09:30:00 , ends @ 10:00:00 row #3: has duration of 90 minutes, starts @ 12:00:00 , ends @ 13:30:00 what best way know need 2 html blocks... 1 div has 60px height (for rows 1 , 2), , because there's break between 10:00:00 , 12:00:00 have div 90px height (row 3). can done mysql somehow? or have php loop check empty spaces of time in order know when should close div , begin new one? any beneficial. this more of logic question code question. you can in mysql. 1 way using correlated subquery determine when "event periods" begin. new event period begins when not overlap others. use information assign "event period id" ea

http - How can I use .htaccess to load index.html for any URL without redirecting? -

i use .htaccess take urls this: mydomain.com/hello-world and have webserver load index.html - keep hello-world url intact. wouldn't redirect, assume. ideally, not give 404 error either. is possible? thanks!! update: think i'm looking works url, or without trailing slash. so... mydomain.com mydomain.com/hello-world mydomain.com/anything-else/ would load index.html, without changing url or giving 404 error. thank you as per apache documentation , need add directoryindex directive .htaccess file. this directive points 1 or more files, allows have redundancy in index files. here example: directoryindex index.php index.html index.htm to keep simple, though, need .htaccess file in directory called "hello-world", users type http://example.com/hello-world/ (note trailing slash) additional rules (using mod_rewrite module), may redirect urls add trailing slash lack one.

html5 - Responsive dropdown CSS fix -

here fiddle >> http://jsfiddle.net/fpcpc/`"> jsfiddle issue when scroll down on dropdown navigation top part doesn't stay active - took screenshot make clear! screenshot please hint full! thank you. on block of styles: .dd_menu_wrapper a:hover, .dd_menu_wrapper label:hover { color:#000; background-color:#eff0f1; font-family:arial, helvetica, sans-serif; font-size:14px; font-weight:bold; } you need add: .dd_parent:hover label fiddle: http://jsfiddle.net/fpcpc/1/

c# - appending a dataset to a session variable -

i know how add dataset session dataset ds = getresults(); session["xyz "] = ds; is there way can append dataset session ? i trying session["xyz"] = ds + ds1; //ds1 dataset or session["xyz"] = ds + (dataset)session["xyz"]; it throws error .. there way ? dataset objects have merge method ((dataset)session["xyz"]).merge(ds1) ;

php - Can't get length of json javascript -

i have code: $.ajax({ url: 'carrinho/fretecheckout/', data: {cep: cep, peso: peso, valor: valor, dimensoes: dimensoes, ids: ids}, datatype : 'json', complete: function() { $('#checkoutbody').removeclass("loadingfrete"); }, success: function(data) { $('#carrinhocep').val(cep); var frete = data; $('.segundopassofrete').html(''); $('#freteselecionado').remove(); (var = 0; < frete['frete'].length; i++) { this code return me it(localhost): {"frete":[{"peso":"49300","classificador":"retira","fk_frete":"15","prazo":"prazo de entrega at\u00e9 2 dias","fk_classificador":"445","fator_cubagem":"4800","peso_real":"1"

javascript - PHP MySQL jQuery/AJAX issue -

i have problem jquery. this jquery code: function updaterecord(id) { jquery.ajax({ type: "get", url: "index.php", data: 'id='+id, cache: true, success: function(data) { $('#output').html(data); } }); } updaterecord(id) data here : echo"<select>"; foreach($products->fetch_products($id) $product) { $price = $product->price; echo"<option value = $product->id onclick=\"updaterecord($product->id)\">$product->p_name</option>"; } echo"</select>"; this piece of html , php code new result should < div id="output"></div> : $i = 0; foreach($products->fetch_products($id) $pricer){ if ($i==1) break; echo"<td>"; echo"<center>"; echo("<div id=\"output\"><p>$pricer-

Configuration vs Database storage -

i keep short, looking store product plan data, these plans users pick payment options. data include how plan cost , unit details of plan are, makes unit (day/week/month) , simple data plan. these plans may or may not change once month or once year, company start , things changing on 11th hour , contently there no real way predict when change. co-worker , discussing whether these values should stored in web.config (where are) or move them database. i have done googling , have not found resource draw clear line of when should in database or in web config. wanted know thought on , see if define when data should stored in config or in database. thanks help! from brief description provide, seems me configuration data, eventually , may accessed not web server-based application running on 1 computer, other supporting applications, such end-of-month batch jobs, may want run on other computers. support possibility, idea store data in sort of centralized repository can accessed

jasper reports - iReport: @ sql variable is not recognized -

i using sybase 15 , have sp returns result set this: select foo, bar, etc, xyz, ... @temp_id #table order 2,3 desc when gets ireport query shows field name blank. knows field type java.lang.integer can see no way create field in report. if give name - @temp_id error telling me field isn't found. same thing if try in jasperreports . the strange thing - me anyway - in eclipse data explorer shows no label column. nor jasperreports dataset , query dialog when ask read fields. i tried calling column_15 didn't work either. what missing?

java - How to Write a generic method to find the maximal element and invoke that method? -

while trying solve exercise from generics tutorial q&a answers different my answers public static <t extends comparable<? super t>> t max(list<? extends t> list, int begin, int end) //option1 public static <t extends comparable<t>> t max(list<? extends t> list, int begin, int end) //option2 from quoted answer below so question option1 :would make difference if t extends object & comparable<? super t> replaced t extends comparable<? super t> . isn't extends object implicit ? option2 :would make difference if comparable<? super t> replaced comparable<t> ? if how ? eclipse code completion creates local variable list<? extends comparable<? super comparable<? super t>>> list; on ctrl+1 max(list, 1, 10); bit lengthy. how define classes (hierarchy) extends comparable<? super t> , create list , add instances list , invoke below method ? want know how invoke max()

.net - Is Visual Studio C++ interpreted like C#? -

are assemblies compiled visual studio .net c++ projects interpreted code c# is? (hence de-compiled full source code many tools out there) so, answer question meant ask: if compile c++ code /clr , compiler produce msil instead of machine code, .net metadata describing program structure. that's enough disassembler produce editable c# 1 code same thing. if have ordinary c++ code in c++/cli project (so need /clr ) can still use #pragma managed(off) make parts of program compile (less reversible) machine code. parts aren't using .net, though. or c++/cli... msil -> c++/cli converter in .net reflector quite buggy, , assume same true other decompilers, if try support it.

.htaccess - PHP Multiregional Site - Mod rewrite - Read $_GET variables -

i te start new php project, i'm looking answers first before start since have little php experience. here's case: i have website targets multitple regions in eu. i use php $_get variables 'indicate' region . @ same time have clean url's vissitors netherlands redirects http://mywebsite.eu/nl/subject visitors belgium redirects http://mywebsite.eu/be/subject i use simple php $_get variables include more information in url. http://mywebsite.eu/subject.php?region=nl goes http://mywebsite.eu/nl/subject http://mywebsite.eu/subject.php?region=be goes http://mywebsite.eu/be/subject http://mywebsite.eu/subject.php?region=global goes http://mywebsite.eu/subject my questions: + how create clean urls example above + how can retrive variables cleaned url (reverse) http://mywebsite.eu/nl/subject $_get['region'] + if know way figure out visitors country code. let me know :d i hope explanation makes sense. --i know there're lots of s

xml - XSLT Select using or? -

i wondering "|" in apply template mean in xslt. <input type="{@type}" id="{@id}" name="{$calculatedname}" class="input-small" > <xsl:apply-templates select="displayoption1 | displayoptions2"/> </input> i thinking pick 1 or other not. applied both. if "|" not represent or (bitwise) here mean? small snippet of xml <datafield type="dropdown" id="65" name="propertystatus"> <displayoptions1 column="1" /> <displayoptions2 displayname="status:" lookuptype="propertystatus" readonly="false" required="true" visibilty="true" /> </datafield> the pipe used combine 2 expressions one, union of two.

Simple integration of Bing Maps into WPF application page -

how go integrating bing maps page or frame in wpf application? have found lot of resources bing maps development, don't need develop bing maps, add actual thing application without hyper-linking out website. windows 8 applications "contracts" other metro apps not see similar functionality wpf applications. thank you! just go here , download control :) http://msdn.microsoft.com/en-us/library/hh750210.aspx control in "bing maps wpf control sdk" if remember correctly need register api key. update: api key have register here https://www.bingmapsportal.com/

node.js - Nothing happen with bower install -

i'm trying setup angular app yeoman, following steps: http://yeoman.io/ works fine until do grunt test i got chrome 24.0.1312 (linux) error uncaught referenceerror: angular not defined @ /var/www/moviz-test/app/scripts/app.js:3 chrome 24.0.1312 (linux) error uncaught referenceerror: angular not defined @ /var/www/moviz-test/app/scripts/controllers/main.js:3 it's because bower install nothing, don't have folder app/bower_components .bowerrc { "directory": "app/bower_components" } bower.json { "name": "myapp", "version": "0.0.0", "dependencies": { "angular": "~1.0.7", "json3": "~3.2.4", "jquery": "~1.9.1", "bootstrap-sass": "~2.3.1", "es5-shim": "~2.0.8", "angular-resource": "~1.0.7", "angular-cookies": &

input background image oversized in IE8 -

i have issue input background image seems getting oversizes when opening in ie8 (this not happens in ie10 or chrome). this code input: <input class="search rounded" id="searchtext" style="background: url(/cat/images/search-icon-th.png) no-repeat 4% 50%; backgroundsize: 16px;" placeholder="search" jquery19107063960315369351="31"/> and images show difference between chrome , ie8 chrome http://img41.imageshack.us/img41/9963/q3cb.png ie8 http://img268.imageshack.us/img268/5109/0z49.png so, question how fix behavior in ie8? thanks in advance! please fix code. i add this: html: <img id="fix" src="imagelink" /> css: #fix { width: 100%; height: 100; } that should make image size of user's webpage.

Cannot connect to mongodb using machine ip -

installed mongo using homebrew . if type mongo on shell, gets connected test . when type ip address of local machine instead of 127.0.0.1 mongo --host 192.168.1.100 --verbose it gives me error message mongodb shell version: 2.4.6 fri aug 23 15:18:27.552 versionarraytest passed connecting to: 192.168.1.100:27017/test fri aug 23 15:18:27.579 creating new connection to:192.168.1.100:27017 fri aug 23 15:18:27.579 backgroundjob starting: connectbg fri aug 23 15:18:27.580 error: couldn't connect server 192.168.1.100:27017 @ src/mongo/shell/mongo.js:147 fri aug 23 15:18:27.580 user assertion: 12513:connect failed have tried modifying mongo.conf commenting bind_ip or changing ip address 127.0.0.1 0.0.0.0 no luck. should simple have no clue now. using mac. thanks update: requested. works after have made changes suggested. ifconfig output lo0: flags=8049<up,loopback,running,multicast> mtu 16384 options=3<rxcsum,txcsum> inet6 fe80::1%lo0 prefixlen

PHP Paypal IPN fails sometimes -

i have php script have been using 2 years , modified work when paypal changed http 1.1. has worked every transaction, failed , cannot figure out why. below code. it fails when trying @ response. invalid could have non standard characters in address? i have tried sending ipn request again , again , fails function paypal_ipn() { $req = 'cmd=_notify-validate'; foreach($_post $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&{$key}={$value}"; } $res = ''; $ch = curl_init(paypal_url()); curl_setopt($ch, curlopt_http_version, curl_http_version_1_1); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_returntransfer,1); curl_setopt($ch, curlopt_postfields, $req); curl_setopt($ch, curlopt_ssl_verifypeer, 1); curl_setopt($ch, curlopt_ssl_verifyhost, 2); curl_setopt($ch, curlopt_forbid_reuse, 1); curl_setopt($ch, curlopt_httpheader, array('connection:

javascript - Why does Function have both implicit and explicit prototype references, and can I set the implicit reference? -

Image
after reading documentation: http://es5.github.io/#x4.2.1 i confused 2 prototype references on cf, , statement: the property named cfp1 in cfp shared cf1, cf2, cf3, cf4, , cf5 (but not cf) much of literature on javascript points out functions first class objects, , such i'd expect able set implicit prototype reference object achieve prototypal inheritance (disclaimer: don't know i'd use inheritance for, occurred me see if it's possible). can set implicit prototype on function, or point function.prototype (i'm assuming that's default). , why function have both explicit , implicit prototypes? other types in javascript have both explicit , implicit prototype references or function unique in regard? consider diagram specification, , code below it, tries reproduce what's going on: function cf() {}; // constructor cf.p1 = 'foo'; // p1 own property of constructor; p2 same var cfp = { crp1: 'bar

objective c - Navbar Title Align Center -

Image
appdelegate.m navbar customization: [[uiapplication sharedapplication] setstatusbarstyle:uistatusbarstyleblackopaque]; [[uinavigationbar appearance] setbackgroundimage:[uiimage imagenamed:@"navbar"] forbarmetrics:uibarmetricsdefault]; [[uinavigationbar appearance] settitletextattributes: @{ uitextattributetextcolor: [uicolor colorwithred:(56/255.0) green:(61/255.0) blue:(63/255.0) alpha:1], uitextattributetextshadowcolor: [uicolor graycolor], uitextattributetextshadowoffset: [nsvalue valuewithuioffset:uioffsetmake(0.0f, 1.0f)], uitextattributefont: [uifont fontwithname:@"proximanova-bold" size:15.0f] }]; lviewcontroller.m navbar custom left/right buttons: // left button uibutton *leftbutton = [uibutton buttonwithtype:uibuttontypecustom]; [leftbutton setimage:[uiimage imagenamed:@"menu"] forstate:uicontrolstatenormal]; [leftbutton addt

youtube - Where can I find the latest /jsbin/www-widgetapi file? -

i'm loading youtube api so: $(function () { // code trigger onyoutubeplayerapiready $('<script>', { src: 'https://s.ytimg.com/yts/jsbin/www-widgetapi-vflwt8qcf.js', async: true }).insertbefore($('script:first')); }); i looking @ youtube demo page, https://developers.google.com/youtube/youtube_player_demo , , noticed in source using different url load widget api: <script src="https://s.ytimg.com/yts/jsbin/www-widgetapi-vfl4qcmf3.js" async></script> i thought might more up-to-date version of api. so, swapped out, receive error message: uncaught referenceerror: ytconfig not defined i'm left wondering of these correct location, if either, loading date widgetapi data from. there location info? to latest api version suggest use example yt reference: var tag = document.createelement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firsts

xml - XSLT transformation results in characters at the beginning of the document -

hi have xml doc like <?xml version="1.0" encoding="utf-8"?> <arrayofapifeedproduct xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <apifeedproduct> <code>c119x</code> <offercode>mjf*q*mj*13</offercode> <producttype>straight</producttype> <title>joseph perrier cuvée royale brut champagne</title> <sdesc>joseph perrier cuvée royale brut champagne</sdesc>... and xslt doc like <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <add> <xsl:for-each select="arrayofapifeedproduct/apifeedproduct"> <doc> <field name="code"> <xsl:value-of select="code"/> </field> <f

php json_encode and decode multi-dimension array -

i have php array structure array ( [car] => array ( [red] => 0.333 [orange] => 0.333 [blue] => 0.333 ) [truck] => array ( [white] => 0.333 [green] => 0.333 [blue] => 0.333 ) ) i have been using serialize save array text file, , unserialize array form. unfortunately, serialized array getting large, due float point (bug or design) conversion when serialized. example, instead of 0.333, serialized process converts .333 .3333333333333333333333333333333333333333333333333. made me want switch json_encode save array. when compare serialize json_encode, serialized file 40mb in size vs 8mb size json_encode. that great, except when try json_decode file, no longer in array form. tried json_decode($array, true), not work either. any idea how json_encode work example? tia ps, floating point number generated rounding off decimals. answer fou

php - Communicate a button click event with sockets -

desire: have device or micro-controller i'll call mc need communicate when web page button clicked using sockets. mc1 <button id ='on1' name='mc1'>on</button> <button id ='off1' name='mc1'>off</button> details: trying accomplish when button clicked pass info mc. what tried: can listens port , can write data mc receive data. im starting file though server php cli. file contains these basic socket functions. $socket = @socket_create_listen("port#"); $client = socket_accept($socket); socket_write($client, $msg); socket_read ($client, 256); the mc connect server @ port# problems: im having difficulties understanding how bridge gap between php web page button , passing data button has been clicked mc. attempt @ solution: can have file listens port run , in seperate file write client? additional notes : mc lan avoid setting port forwarding , external ip changes. these reason had choose have m

c++ - How to write a tester for a program that writes one bit at a time? -

i trying write tester following program see if functions correctly, however, i'm not sure if implemented flush() correctly , reason don't output. can suggest code test class see if implemented flush , writebit correctly? #ifndef bitoutputstream_hpp #define bitoutputstream_hpp #include <iostream> class bitoutputstream { private: char buf; // 1 byte buffer of bits int nbits; // how many bits have been written buf std::ostream& out; // reference output stream use public: /* initialize bitoutputstream * use given ostream output. * */ bitoutputstream(std::ostream& os) : out(os) { buf = nbits = 0; // clear buffer , bit counter } /* send buffer output, , clear */ void flush() { out.put(buf); // edit: removed flush(); stop infinite recursion buf = nbits = 0; } /* write least sig bit of arg buffer */ int writebit(int i) { // if bit buffer full, flush it. if (nbits == 8) flush(); //

c# - Unexplainable MySQL composite key issue with .NET Application -

i writing .net application interact mysql database using odbc connection. application create database schema , tables on database upon start up. however, encountered weird unexplainable case below: first application create following table create table if not exists `sample` ( `item_id` varchar(20) not null, `item_no` int(11) not null, `sample_col1` varchar(20) not null, `sample_col2` varchar(20) not null, primary key (`item_id`, `item_no`) ) engine=innodb; populate table with insert sample set item_id='abc', item_no=1, sample_col1='', sample_col2=''; insert sample set item_id='abc', item_no=2, sample_col1='', sample_col2=''; then execute select query within .net application using following code: dim query string query = "select item_id, item_no, sample_col1, sample_col2 sample" dim conn new odbcconnection("driver={mysql odbc 5.1 driver};server=localhost; port=3306;database=test; user=dbuser;password=dbpassw

node.js - How to check if socket.io is compatible with browser? -

the socket.io website says it's pretty compatible browswers cross browser compatibility . how can programmatically check if socket.io compatible browser? basically you'll have try separate tools each browser... i type out bunch of tools i've used in past, found awesome post notes of ways test browser compatibility...go guy. cross browser testing - 1 answer rule them all

Foreach string in php? -

im sure answer on web not sure of proper way search this. foreach ($sections $key => $inside) { foreach ($inside['fields'] $key => $field) { echo '<li>'.var_dump ($field['type']).'</li>'; } } this dumps list of strings. string(6) "switch" string(6) "switch" string(4) "text" string(4) "text" string(8) "textarea" string(6) "switch" string(9) "radio_img" string(9) "radio_img" string(10) "multi_text" i want add 1 more foreach , is, foreach "switch" or whatever string desired in above list of strings. so like foreach ($sections $key => $inside) { foreach ($inside['fields'] $key => $field) { foreach ($field['type']['switch'] $string) { //loop through switches } } } this new me , couldnt find answer google, not su