Posts

Showing posts from June, 2015

javascript - foreignObject div transform not working D3 -

at moment, d3 code animates svg circles along path, have svg 'name' labels moving alongside each. when circle hovered over, div (which have created foreign object in same group 'g2' labels) appears comment inside. i want these tooltips. problem cannot div transform along path in same way name labels - stick top left-hand corner of page. i not sure if problem how grouping things, or whether foreignobject should directly appended svg. have tried various things , suggestions other questions no success, appreciated! also, interested in making work in chrome. here jsfiddle: http://jsfiddle.net/yumip/q5jag/1618/ var greetings = ["hello","hi","howdy"]; var names = ["person a","person b","person c"]; var width = 960, height = 500; var n = greetings.length, m = 12, degrees = 180 / math.pi; var bubbles = d3.range(n).map(function() { var x = math.random() * width, y = math.random() *...

c# - How does html decoding work? -

in app compare strings. have strings same of them contain white space, , other contain nbsp, when compare them different. however, represent same entity have issues when compare them. that's why want decode strings compare. way nbsp converted space in both of strings , treated equal when comparison. here's do: httputility.htmldecode(string1)[0] httputility.htmldecode(string2)[0] but still string1[0] has ascii code of 160, , string2[0] has ascii code of 32. obviously not understanding concept. doing wrong? you trying compare 2 different characters, no matter how resembling might seem you. the fact have different character codes enough make comparison fail. easiest thing replace non-breaking space regular space , compare them. bool c = html.replace('\u00a0', ' ').equals(regular);

Bitwise operation alternative in Neo4j cypher query -

Image
i need bitwise "and" in cypher query. seems cypher not support bitwise operations. suggestions alternatives? want detect ... example 268 (2^8 + 2^3 + 2^2) , can see 2^3 = 8 part of original number. if use bitwise , (100001100) & (1000) = 1000 way can detect if 8 part of 268 or not. how can without bitwise support? suggestions? need in cypher. another way perform type of test using cypher convert decimal values collections of decimals represent bits set. // convert binary number collection of decimal parts // create index size of number convert // create collection of decimals correspond bit locations '100001100' number , [1,2,4,8,16,32,64,128,256,512,1024,2048,4096] decimals number , range(length(number)-1,0,-1) index , decimals[0..length(number)] decimals // map bits decimal equivalents unwind index number, i, (split(number,''))[i] binary_placeholder, decimals[-i-1] decimal_placeholder // multiply decimal value bits set collect(decimal_pl...

javascript - Get text value using name attirbute one by one -

i have 3 elements of html <h3 contenteditable class="education" name="education[index][university]>1</h3> <span contenteditable class="education" name="education[index][time]>2</span> <p contenteditable class="education" name="education[index][description]>3</p> so want text value order h3-span-p 1 one using name attribute javascript.after every value how can have new line follow after this 1 2 3 thanks in advanced try this: $(function() { var output = $('[name^="education[index]"]').map(function() { return $(this).html(); }).get().join('\n'); alert(output); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h3 contenteditable name="education[index][university]">1</h3> <span contenteditable name="education[index][time]">2</span>...

javascript - Using multiple selectors with each having different events -

this question has answer here: combining $('body').on('click') $(window).resize(function() in jquery 4 answers i need this: $("#household").children().change(function(){ alert("changed"); }); $('.ui-icon.ui-icon-closethick.delete').click(function(){ alert("changed"); }); turned this: $("#household").children().change || $('.ui-icon.ui-icon-closethick.delete').click(function(){ alert("changed"); }); i know bottom code isn't correct, hoping explains mean. want alert executed if #household.children() changed , .ui-icon.ui-icon-closethick.delete clicked, without writing code twice. you can achieve putting common logic in own function called both events: function changed() { console.log('changed') } $("#household").children().chan...

c# - ReSharper cannot resolve symbol -

Image
i'm building asp.net 5 (asp.net core 1.0) mvc application. i'm using visual studio 2015 resharper ultimate 10.0.2. i have 2-tier layer solution consists of www (web application) , services layer. www has reference services layer. when resharper suspended , classes within www layer able invoke objects services layer, shown here: however, when resharper enabled , following message: cannot resolve symbol 'services' , shown here: what i've tried: clearing caches tools -> options -> resharper ultimate -> options -> clear caches remove jetbrains folder %appdata% restarting visual studio 2015 reinstalling resharper suspending , resuming resharper adding , removing references rebuilding solution any appreciated. in visual studio 2017 solved in way: close solution delete ".vs" hidden folder reopen solution , rebuild it

nuget - Package Manager console ProjectItem.FileCodeModel returning null in VS 2015 but not in VS 2013 -

there seems there´s bug in package manager when using projectitem.filecodemodel property in vs 2015, returns null unlike vs 2013 expected object. we´re using vs 2013 ultimate update 3 when works , when using vs 2015 enterprise update 1 returns null. this how recreate problem. on vs 2013. file --> new --> project… choose templates --> visual c# --> web. pick asp.net web application. choose mvc template. open package manager console. insert package manager console: ((get-project).projectitems | foreach-object { $ .projectitems } | { $ .name -eq "routeconfig.cs" }).filecodemodel.codeelements this return codeelements expected. on vs 2015. file --> new --> project… choose templates --> visual c# --> web. pick asp.net web application. choose mvc template. open package manager console. insert package manager console: ((get-project).projectitems | foreach-object { $ .projectitems } | { $ .name -eq "routeconfig.cs" }).filec...

javascript - Chaining callbacks in a custom-made for-each loop, supporting both synchronous and asynchronous functions -

i have for_users function gets array of users web service, executes passed function f on received array, calls continuation f_then callback. // execute f on every user, f_then. function for_users(f, f_then) { // users database, in user_array db.get_all_users(function(user_array) { // execute f on every user user_array.foreach(f); // call continuation callback f_then(); }); } when calling for_users , passing asynchronous function f parameter, f callbacks end before calling f_then . not happening in current code, user_array.foreach(f) not wait f finish before starting next iteration. here's example of problematic situation: function example_usage() { var temp_credentials = []; for_users(function(user) { // credentials asynchronous function // call passed callback after getting credential // database database.get_credentials(user.id, function(credential) { ...

java - Maximum open cursors exceeded - with hibernate SchemaValidator -

our oracle 11g database contains 298 tables(10 added), (+100 sequences), declared 500 cursors. when starting our webapplication (tomcat 7.0, jdbc pool), @ sessionfactory initialization when hibernate validates schema uses cursors (cf below). is there known in order hibernate less greedy oracle cursors ? please note problem has nothing handling of prepared statements or hibernate entities not work of them @ step. caused by: org.hibernate.exception.genericjdbcexception: not table metadata: mytable @ org.hibernate.exception.sqlstateconverter.handlednonspecificexception(sqlstateconverter.java:103) @ org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:91) @ org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:43) @ org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:29) @ org.hibernate.tool.hbm2ddl.databasemetadata.gettablemetadata(databasemetadata.java:105) ...

angularjs - Filter works but throws error anyway -

Image
i'm filtering list based on user logged in. shows exact results in console still error: error: [filter:notarray] expected array received: {} angular: <div ng-repeat="q in questions | filter: {fields: {user: user.current}}"> <!-- --> </div> declaration of user.current $scope.user.current = fhauth.getcurrentuser().userid; each object in question array has array of fields; fields[ { 'questionid': 1, 'user' : 'person1' } ], fields[ { 'questionid': 2, 'user' : 'person2' } ] edit screenshot array:

javascript - Detect HTML video autoplay prevention -

mobile browsers prevent video autoplay understandable reasons. have video background on site, control buttons out of question, thought pop window info , button, user can accept background video (triggering manual play) or not, , change static pic. so question is: there way tell if autoplay interrupted browser? i tried onerror doesn't fire tried onsuspend well: html: <video id='bgvid' src='bgvid.mp4' type='video/mp4' autoplay loop onsuspend='video_suspended()'> javascript: function video_suspended() { $bgvideoelement=$("#bgvid").get(0); //check if reason suspend completion or browser interruption if($bgvideoelement.readystate<1) { //here comes pop-up window , button $bgvideoelement.play(); } } it works pretty on tablet (chrome), on desktop (chrome) onsuspend keeps triggering infinitely (firefox alright though). any ideas on chrome problem or alternatives? ...

Using GIT to manage develop enviroment -

on program developing using version control. however, have development mode , live mode, changed variable within program. is possible branch off of base development branch holds variable change, when have modified program push new commits master without pushing original changes switching dev mode? master --------master changes, not dev base variable change |-dev base ^ |-changes----| don't keep configuration related environment under git control. in simple case can 1 variable, set of parameters, such database name / user / password, external api credentials , on. don't store your passwords , credentials plain text in repository, right? two common ways handle are: 1) add configuration file in .gitignore. in repository can have configuration file example, easy setup new environment (just copy example , modify according local environment). 2) keep variable parameters environment variables.

python - pip upgrade fails - "No files were found to uninstall" -

something goes wrong pip installation on mac os x 10.11.3. when use pip -v following: ***:desktop ***$ pip -v pip 8.0.2 /library/python/2.7/site-packages (python 2.7) ***:desktop ***$ but when use pip list this: ***:desktop ***$ pip list ... pip (7.1.2) ... using pip version 7.1.2, version 8.0.2 available. should consider upgrading via 'pip install --upgrade pip' command. and when try update pip happens: ***:~ ***$ sudo -h pip install --upgrade pip collecting pip downloading pip-8.0.2-py2.py3-none-any.whl (1.2mb) 100% |████████████████████████████████| 1.2mb 344kb/s installing collected packages: pip found existing installation: pip 7.1.2 can't uninstall 'pip'. no files found uninstall. installed pip-7.1.2 using pip version 7.1.2, version 8.0.2 available. should consider upgrading via 'pip install --upgrade pip' command. any idea how can figure out goes wrong / how solve mess? can download pip 8.0.2 github install...

Read string up to a certain size in Python -

i have string stored in variable. there way read string size e.g. file objects have f.read(size) can read size? check out this post finding object sizes in python. if wanting read string start until size max reached, return new (possibly shorter string) might want try this: import sys max = 176 #bytes totalsize = 0 newstring = "" s = "mystringlength" c in s: totalsize = totalsize + sys.getsizeof(c) if totalsize <= max: newstring = newstring + str(c) elif totalsize > max: #string larger or same size max print newstring break this prints 'mystring' less (or equal to) 176 bytes. hope helps.

c - OpenGL - Rotating a 2D Asteroids Ship -

so i've been googling out wazoo , going through sorts of resources - texts, lectures, etc. - i'm either missing or not grasping correctly. class in opengl need design asteroids game, seems simple enough concept, i'm finding difficult movement of ship down right. know need translate our ship origin, perform rotation, , translate appropriate position - problem i'm facing understanding execution of it. code have drawing ship far: void drawship(ship *s) { glclear(gl_color_buffer_bit); glmatrixmode(gl_modelview); glloadidentity(); glpushmatrix(); mytranslate2d(s->x, s->y); float x = s->x, y = s->y; myrotate2d(s->phi); glbegin(gl_line_loop); glvertex2f(s->x + s->dx, s->y + s->dy + 3); glvertex2f(s->x + s->dx-2, s->y + s->dy - 3); glvertex2f(s->x + s->dx, s->y + s->dy -1.5); glvertex2f(s->x + s->dx + 2, s->y + s->dy - 3); glend(); mytranslate2d(s->x...

javascript - Bootstrap modal stops scrolling -

this going weird question... i having problem on site developing client. have couple of select2 inputs in bootstrap 3 modal window. on smaller screens modal window scrolls fine vertically, until focus on 1 of 2 select inputs. after that, can't scroll means. either keyboard, or scroll wheel or dragging scrollbar. i tried make fiddle reproduce error, because can't show site i'm working on, on fiddle, scrolling works no matter do. https://jsfiddle.net/maidomax/ckuoe762/4/ i tried fiddling also: $('select').select2({ dropdownparent: $("#mymodal") }); but makes no difference. so... have ask question way. what possibly prevent modal scrolling? scrollbar visible, , not disabled, stuck, , can't move way try. there property on div or other part of document set type of behavior? try add css: .modal-open .modal { overflow-x: hidden; overflow-y: auto; } i have had problem before , worked me. if not fix problem, can make g...

mysql - Dynamic search filter with multiple factors in web app -

i'm building real estate website , i'm little bit confused on how filter apartment search results. user can filter search clicking on check boxes , textbox contains keywords search for. my problem have many filtering options (by city and/or location in city and/or apartment size and/or number of bed rooms and/or ... ). problem how write mysql stored procedure can dynamic accept different inputs , give filtered results pagination. example, can choose number of bedrooms 2 or 3 in filter , in city , might not care other conditions. , user might put keyword along conditions search for. i'm using spring mvc , mysql guess need more concept languages , relational db i'm using. at first, though of passing key value pairs complicate things lot in procedure guess , depend on enum tables. so, can please suggest proper way implement kind of search based on best practices , expertise. many thx faceted search analytic problem, meaning need analytic schema properly...

C++ Call function that is not defined yet -

i have code. how do without creating error? int function1() { if (somethingtrue) { function2(); } } int function2() { //do stuff function1(); } just put above functions: int function1(); int function2(); but don't create endless loop! 2 lines tell compiler function1 , function2 defined in future. in bigger projects use header files. there same can use functions in multiple files. and don't forget return statement. think code example demonstration want mention it. in c++ must seperate declaration , definition . read more here: https://stackoverflow.com/a/1410632/4175009

database - Can redis do hundreds of transactions per second on single key-value pair -

i have application, works on api calls. on every api call perform task , charge it(which can sending mail or sms or such thing). currently keep users balance/credit data in mysql table in following form : |user|balance| |a |1200 | |b |1200 | |c |1300 | |d |1400 | |e |1212 | |f |9000 | |g |8000 | |h |7000 | but creating problem when single users hits thousands of apis per minute.and on every api update users balance , if there not sufficient balance, return error. when no of api hits small , there no issue when large, updating balance creates lock on row , other apis have wait process. i thinking of moving table cache or in-memory database, can fast process. earlier had memcache in mind volatile , on searching read redis. but confused, problem solved or not? different keys, fetching data redis may fast,as kept in memory/ram only, how work if there thousands of update , search queries same/single key. please share if have knowledge or experienc...

android - make webview content always fit width of the screen -

Image
i have webpage has data in table want make viewable in android app through webview. problem table varies in width, 400px 1000px. trying make regardless of width, table fills webview user doesnt have zoom in or out, or scroll horizontally. have working on galaxy s2, on other devices nexus 5x, page starts zoomed way out , user has zoom in read anything. zoomed out, content filling 50% of screen , don't know space coming from. here have setup make work on galaxy s2: html: <meta name="viewport" content="width=device-width, initial-scale=.1" /> this made started zoomed way out, when content 400px wouldn't zoomed way out. android webview: websettings settings = w.getsettings(); settings.setjavascriptenabled(true); settings.setallowfileaccess(true); settings.setbuiltinzoomcontrols(true); settings.setdisplayzoomcontrols(false); settings.setusewideviewport(true); usewideviewport way allow user zoom out enough not have scroll horizontally. he...

iphone - ios distribution certificate: A valid provisioning profile for this executable was not found -

i unfortunately removed ios distribution certificate of application. want create other 1 have error when build app: app installation failed: valid provisioning profile executable not found. here process create provisioning profile: request certificate: in keychain access, choose keychain access > certificate assistant > request certificate certificate authority. enter e-mail address , name of apple developer account, save certficatesigningrequest.certsigningrequest. create ios production certificate: in https://developer.apple.com/account/ios/certificate/ , add production app store , ad hoc certificate. i use certficatesigningrequest.certsigningrequest of first step , generate certificate. create distribution provisioning profile in provisioning profile, add app store distribution provisioning profile. continue , select app id, production certificate generated in step 2. i set name 'myapp distribution'. set provisioning profile in xcode in xcode...

php - Modifications to nested array elements do not stick -

i either working through fatigue barrier or else have serious gap in understanding of php. here need do i have array ( a ) of arrays ( a ) i need iterate through outer array and for each of inner arrays need add new element, in turn array this sort of code churn out many times day , had expected little trouble it. however, surprise whilst can modify a cannot make modifications stick , appear in a here code function fillroutenames($routes,$export) { for($i=0;$i < count($routes);$i++) { $route = $routes[$i]; trigger_error(gettype($route));//shows array, expected $disps = $route['d']; $nd = array(); foreach($disps $disp) $nd[] = fxnname($disp,$export); //now have new element want add $route['nd'] = $nd; trigger_error(json_encode($route)); /as expected output shows new element, nd } trigger_error(json_encode($routes)); //but gone - never did $oute['nd'] = $nd } there must blindingly obvious here wrong have been unable fi...

R - Upsert on a dataframe -

i working in r. have 4 data frames data attempting summarize new dataframe. 4 starting frames have rownames unique identifiers (the rest have data identifier). there potential overlap, i.e. id might show in more 1 of 4 tables. i attempting build dataframe following format: id-dataset1-dataset2-dataset3-dataset4 "1"-false-false-true-true basically says id 1 appeared in datasets 3 , 4. goal come boolean vector each id, tells datasets found in. have 4 datasets dataframes, , rownames ids. since building final dataframe (calling vectortable) iteratively, initialize empty data frame. have started working on function folowing: check if id in vector table if update correct boolean value otherwise build new boolean vector , add it here code function: mapidtovector <- function(id, vectortable, dataidx) { if(id %in% vectortable$id) { vectortable[test$id == id][dataidx] = true } else { # create vector row row <- c(id, false, f...

Picking an IDE and language for Mobile Development -

i have been coding xcode while , have released 2 ios apps. have idea third app; however, want universal (accessible devices). ide use code 3 major oss (ios, android, windows) @ same time? you can see "top 10" here... aren't cheap. http://thinkapps.com/blog/development/develop-for-ios-v-android-cross-platform-tools/

python - multiple figures in matplotlib -

i new here , started python master thesis project. try plot multiple figures can't. have looked many same questions , answers still, can't result. plt.figure(1) plt.draw() plt.axis([14,55, 3, 5]) plt.xlabel('doy') plt.ylabel('amplitudes of l1 & l2 signals') red_dot, = plt.plot(x1, l1,'ro') green_dot, = plt.plot(x1, l2, 'go') plt.legend([red_dot, green_dot], ["l1", "l2"]) plt.figure(2) plt.draw() plt.axis([14,55, 25, 60]) plt.xlabel('doy') plt.ylabel('dampenings of l1 & l2 signals') red_dot, = plt.plot(x1, damp_l1,'ro') green_dot, = plt.plot(x1, damp_l2, 'go') plt.legend([red_dot, green_dot], ["dampening of l1", "dampening of l2"]) plt.show() this have written , thing figure 1 first plot , empty figure2 window no data inside!' can help? thanks i suggest using oo interface as possible (instead of pyplot 'state machine' api). want li...

javascript - Trying to append "!important" to an inline style created with JS -

i'm working on element need able add '!important' inline style dynamically creating using js in order override several css styles exist in stylesheets developed person. unfortunately, these stylesheets used globally , particular area has slew of '!important's strung through cannot modify without risking altering previous headers exist throughout site. i'm rough in js skills, having rough go of figure out. here current code snippet: fixtextposition: function() { var width = $( window ).width(); if (width > 1451){ width = 1451; } var height = $( window ).height(); if (height > 816){ height = 816; } $("#banner-resize").css("minheight", height); if (height < 816){ $("#banner-resize").css("minheight", height - 1); } } i attempting append "!important" "minheight" value after has gone through (height - 1) , cannot seem figure out how add valu...

php - Symfony2 PHPUnit functional test has x-debug-token header instead of X-Debug-Token -

i'm working on symfony 2.8.2 application. now, want check through profiler if email sent successfully. enabled profiler in config_test.yml that framework: test: ~ session: storage_id: session.storage.mock_file profiler: enabled: true collect: false so, enable profiler in client , request in phpunit functional test: $client->enableprofiler(); $client->request($method, $path, $requestparameters, array(), $headers); $mailcollector = $client->getprofile()->getcollector('swiftmailer'); but $client->getprofile() returns false. i found problem in symfony profiler when @ line 84 tries token if (!$token = $response->headers->get('x-debug-token')) { return false; } return $this->loadprofile($token); i debugged response , found has 4 headers , 1 of them named 'x-debug-token'. why header have name? how can modify header profiler? thanks!

Adding HTML form using JavaScript to get a total in text box -

so final piece of code, need add form values , show running total in textbox underneath 'table'. there way using javascript can done? have drop down boxes values in them. this snippet of code: function erasetext() { var out = document.queryselectorall(".out"); (var i=0;i<out.length;i++) { out[i].value=""; } } var sections = { p1 : {sname: "dynamic table ", mscore: 20}, p2 : {sname: "intellij usage ", mscore: 10}, p3 : {sname: "calender control", mscore: 30}, p4 : {sname: "active form ", mscore: 20}, p5 : {sname: "object database ", mscore: 20} }; document.write("<pre>"); document.write(object.keys(sections).reduce(function(s, p, i) { var o = sections[p]; return s + (i>0?'<br><br><br><br>':'') + o.sname + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...

c# - How to implement timeout on a .NET Stream when timeouts are not supported on this stream -

i trying read/write bytes to/from bluetooth printer using xamarin android in c#. making use of system.io.stream this. unfortunately, whenever try use readtimeout , writetimeout on streams following error: message = "timeouts not supported on stream." i don't want stream.read() , stream.write() calls block indefinitely. how can solve this? you expose method cancellation token api can easliy consumed. one of cancellationtokensource constructors takes timespan parameter. cancellationtoken on other hand exposes register method allows close stream , reading operation should stop exception being thrown. method call var timeout = timespan.parse("00:01:00"); var cancellationtokensource = new cancellationtokensource(timeout); var cancellationtoken = cancellationtokensource.token; await readasync(stream, cancellationtoken); method implementation public async task readasync(stream stream, cancellationtoken cancellationtoken) { us...

javascript - jquery select2: duplicate tag getting recreated -

Image
i asked 1 question today , still unanswered ( jquery select2: error in getting data php-mysql ). however, trying fix , doing getting bit strange issue. not sure why happening this. below javascript code. <div class="form-group"> <label class="col-sm-4 control-label">product name</label> <div class="col-sm-6"> <input type="hidden" id="tags" style="width: 300px"/> </div> </div> <script type="text/javascript"> var lastresults = []; $("#tags").select2({ multiple: true, placeholder: "please enter tags", tokenseparators: [","], initselection : function (element, callback) { var data = []; $(element.val().split(",")).each(function () { data.push({id: this, text: this}); }); callback(data); }, ajax: { multiple: true, url: ...

rails link_to not works when navigated to any entity -

i cannot navigate or post when there parameter on url (when navigated entity) <a href="/xxx">xxx</a> works when @ url like http://localhost:3000/xxx but when @ url has entity parameter like http://localhost:3000/xxx/12 non of <a\> tags work , non of remote form posts work when attach mouse click on chrome, saw on url http://localhost:3000/xxx jquery function below returns undefined (the situation navigation works without problem), when on url http://localhost:3000/xxx/12 function returns jquery.fn.init[0] the function (jquery excerpt) this if ( !( eventhandle = elemdata.handle ) ) { eventhandle = elemdata.handle = function( e ) { // discard second event of jquery.event.trigger() , // when event called after page has unloaded return typeof jquery !== "undefined" && jquery.event.triggered !== e.type ? jquery.event.dispatch.apply( elem, arguments ) : undefine...

for loop - Upside-down triangle of numbers i Java -

i'm beginner java , can't figure out how print upside down triangle of numbers. numbers should decrease in value 1 each row. ex. number of rows; 6 print: 666666 55555 4444 333 22 1 so far came with; (int nr scanned input user) for (int = 1; <= nr; i++) { (int j = 1; j <=nr; j++) { system.out.print(nr); } nr--; system.out.println(); } by having nr-- ; loop gets shorter , cant figure out how keep loop going "nr"-times, yet still decreasing amount of numbers printed out. you right in need write loop print line each number, starting @ nr , decreasing 1 until 0. have print variable number of numbers @ each line. that, nested loop used print number amount of times necessary. since start printing @ nr , decrease until reach 1, try writing outer loop decrements rather increments. use nested loop print number required number of times. example: for (int = nr; > 0; i--) { (int j = 0; j < i; j++) { ...

c - How to check whether an int input is greater than 2147436647 or smaller than -2147483648? -

doing : int nbr; if (nbr <= -2147483648 || nbr >= 2147483647) printf("no way !!"); does not write no way !! value under lower limit (for example -2147483650) because inputs numbers become positive !! int exceed range [-2147436647 2147483647] on platforms wider 32-bit int . #include <limits.h> int nbr; #if int_min < -2147483648 || int_max >= 2147483647 if (nbr < -2147483648 || nbr > 2147483647) printf("no way !!"); #endif pre c99 platform may need work handle -2147483648 . to detect if string converted long exceed range, char buf[100]; buf[0] = 0; fgets(buf, sizeof buf, stdin); errno = 0; char *endptr; long x = strtol(buf, &endtr, 10); if (buf == endptr) puts("no conversion"); else if (errno) puts("out of long range"); // if `long` wider 32-bit , [-2147483648 2147483647] range still needed else if (x < -2147483648 || x > 2147483647) puts("no way !!"); else print...

powershell - Add wlan profile with password in windows programmatically -

is possible programmatically add wifi profile windows operating system (minimum version windows 7)? i tried netsh add profile , connect , doesn't work me. there powershell commands this? i want set wifi password special ssid many clients automatically. i hope has idea or can give me command sample information: ssid: wlannetwork password: password123 thanks i found way add wifi profile. at first export existing wifi profile: netsh wlan export profile name="wifinetwork" folder="c:\path\" key=clear than xml file following style: <?xml version="1.0"?> <wlanprofile xmlns="http://www.microsoft.com/networking/wlan/profile/v1"> <name>wifinetwork</name> <ssidconfig> <ssid> <hex>123456789abcdef</hex> <name>wifinetwork</name> </ssid> </ssidconfig> <connectiontype>ess</connectiontype> <connectionmode>auto...

c++ - Why are my switch cases being skipped and default being printed? -

i have written c++ code in attempt simulate vending machine. whenever user's selection entered, number 1-5 each assigned case in switch statement, none of cases execute: program not recognize valid input, , print out default case statement. why happening? #include <iostream> using namespace std; int main() { int choice; double dollars; cout << "==============================================================\n"; cout << "* *\n"; cout << "* vending machine simulator *\n"; cout << "* *\n"; cout << "==============================================================\n"; cout << "your choices are:\n"; cout << "1) coke - $1.75\n"; cout << "2) pepsi - $2.25\n...

jquery - In DataTables Display current records indexes and total records in Language : Info : tag -

Image
i new jquery data tables. have requirement in have display last ten entered records in data table no pagination or sorting.i able last ten records ajax call. in header , footer have record information. right if have total 25 records , displaying last 10, table header/footer show : records 1 10 of 10. because have language tag below: "language":{ "info": "records _start_ _end_ of _max_", }, but requirement display: records 5 15 of 15 or 7 17 of 17. i checked data tables website, had these info keywords : but _max_ not getting total records _start_ , _end_ getting records 1 10 of 10 if record sequence number getting displayed in table 5 15 any appreciated. please ask questions if description not enough. here data table initialization code: var table = $('#mydatatable').datatable({ "dom":'<i><"clear"><p><"bottomfmarg"f>t<i><"clear"><p...

string - How to extract URLs from HTML source in vb.net -

my question is: have program fetches whole source code of specified url. source code saved in variable. part of source code looks this: "thumbnail_src":"https:\/\/scontent-fra3-1.blablabla.com\/t51.2885-15\/s640x640\/sh0.08\/e35\/1234567_984778981596410_1107218704_n.jpg","is_video":false, the code has quite bunch of urls. want code part "thumbnail_src":" marker beginning extraction process , stop extraction @ ","is_video": this should done in loop until urls being extracted , saved listing variable. how can achieve that? i trying regexp sourcecode. 1 codexer wrote, correct getting eerrors in visual basic net. dim regex regex = new regex("thumbnail_src""": """(.*)""","""is_video") dim match match = regex.match(sourcestring) if match.success console.writeline(match.value) end if i tried way..and way: ...

Spring Boot Test ignores logging.level -

one of maven module ignores logging levels when running tests. in src/test/resources have application.properties: app.name=bbsng-import-backend app.description=import backend module application spring.profiles.active=test # logging logging.level.root=error logging.level.org.springframework.core =fatal logging.level.org.springframework.beans=fatal logging.level.org.springframework.context=fatal logging.level.org.springframework.transaction=error logging.level.org.springframework.test=error logging.level.org.springframework.web=error logging.level.org.hibernate=error i tried application-test.properties. my application logs lot, espacially when loading context. tried logback.xml, logback-test.xml , logback-spring.xml. nothing helps. my pom: <parent> <groupid>at.company.bbsng</groupid> <artifactid>bbsng-import</artifactid> <version>0.1.0-snapshot</version> </parent> <artifactid>bbsng-import-backend</arti...

python - Why what's wrong with this dict conversion of a lambda expression result object? -

was feeling smug thinking had best lambda expression in universe cooked return relevant network information ever needed using python , netifaces >>> list(map(lambda interface: (interface, dict(filter(lambda ifaddress: ifaddress in (netifaces.af_inet, netifaces.af_link), netifaces.ifaddresses(interface) ))) , netifaces.interfaces())) but got this traceback (most recent call last): file "<stdin>", line 1, in <module> file "<stdin>", line 1, in <lambda> typeerror: cannot convert dictionary update sequence element #0 sequence scaling bit >>>dict(filter(lambda ifaddress: ifaddress in (netifaces.af_inet, netifaces.af_link), netifaces.ifaddresses("eth0"))) is problem is: traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: cannot convert dictionary update sequence element #0 sequence but can convert filter object list >>> list(filte...

testing - Symfony functional tests: receive uploaded file -

i have html form contains following input: <input type="file" name="sentfile" /> form has not been generated $this->createformbuilder() . have written class extends webtestcase . testing method following: $crawler = $client->request('get', '/users/import'); $buttoncrawlernode = $crawler->selectbutton('import'); $form = $buttoncrawlernode->form(); $testfile = 'import_users.csv'; $destination = 'f:/www/symfony/web/uploads/' . $testfile; $form['sentfile']->upload($destination); $form['myparam'] = 'hello'; $crawler = $client->submit($form); but when run test phpunit command, controller method receives posted form shows empty $_files . other input ( myparam ) correctly received. how can use uploaded file? ps: i have not succeeded use phpt in symfony (stackoverflow.com/questions/4922207/integrate-phpt-test-cases-with-phpunit/4925061). i have not tried selenium yet re...

javascript - Button to add selected="selected" from outside form -

i using laravel, , trying integrate jquery, not at. i have multiple select box potentially lots of options, based on database values. <div class="toolselect"> <select multiple> <option value="1">tool 1</option> <option value="2">tool 2</option> <option value="3">tool 3</option> </select> </div> the user can select tools directly select box, can huge list , therefore displaying search field below select box search database of tools user can see more info tool, , decide if wants include it. currently user has first search, find entry in select box , select it. i want faster solution button next info tool, automatically adds selected="selected" correct option in select box above. i tried <input type="button" value="mer" onclick="addselect('{{$tool->id}}')"/> <script type="text/javascript"> addselect ...

javascript - Catch first zero by regex -

i have string: 0012309test07 and want find first zeros , letters. 00 12309 test 07 sure found letters /[^\d]/ , here's sample . but how catch first zeros ? use regexp \b0+|[a-za-z]+

c++ - How do I capture the original input into the synthesized output from a spirit grammar? -

i'm working on boost::spirit::qi::grammar , copy portion of original text synthesized output structure of grammar (more specifically, portion matched 1 of components of rule). grammar used sub-grammar more complicated grammar, don't have access original input. i'm guessing can done through semantic actions or grammar context, can't find example without access original parse(). here's have far: #include <iostream> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/fusion/include/adapt_struct.hpp> namespace qi = boost::spirit::qi; struct { std::string header; std::vector<int> ints; std::string inttext; }; boost_fusion_adapt_struct( a, (std::string, header) (std::vector<int>, ints) //(std::string, inttext) ) template <typename iterator> struct parser : qi::grammar< iterator, a() > { parser() : parser::base_type(start) { ...

ruby - Testing upload watir and rspec -

i trying test upload pictures/document on web pages using watir/watir-webdriver, tried not work. for example, uploading pictures on imgur: require 'watir' require 'watir-webdriver' require 'rspec' describe "upload test" before(:all) @browser = watir::browser.new :firefox @browser.goto("https://imgur.com/") end context "upload test" "can upload picture" @browser.link(:text, "upload images").click @browser.file_field(:name, "img_path").set("img_path") @browser.button(:value,"save").click end end after(:all) @browser.close unless debugging? end end there error. failures: 1) upload test upload test can upload picture failure/error: @browser.link(:text, "upload images").click watir::exception::unknownobjectexception: unable locate element, using {:text=>"upload images", :tag...