Posts

Showing posts from June, 2015

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot

c# - Windows Phone 8.1 Application Deployment Error -

i added sql database windows phone 8.1 application , cant deploy app lumia 520 or windows devices, need help! following error:- error 1 processor architecture of project being built "any cpu" not supported referenced sdk "microsoft.vclibs, version=12.0". please consider changing targeted processor architecture of project (in visual studio can done through configuration manager) 1 of architectures supported sdk: "x86, arm". myproject.windowsphone did try when put arm gives me following error and when change config arm:- error 1- there mismatch between processor architecture of project being built "arm" , processor architecture, "x86", of implementation file "c:\users\john\documents\visual studio 2013\projects\thebeat\packages\sqlite-winrt.3.8.7.1\lib\wpa81\sqlitewinrt.dll" "c:\users\john\documents\visual studio 2013\projects\thebeat\packages\sqlite-winrt.3.8.7.1\lib\wpa81\sqlitewinrt.winmd". mismatch may

html - Div container doesn't fit content -

div container doesn't fit content made version of page principal components share , try resolve problem. well, problem when expand horizontally page images cutted in bottom. want leave page that, therefore without visual changes. ps: i'm using bootstrap .image-container{ height: 100%; width: 100%; position:absolute; } https://jsfiddle.net/power96/q15oo62d/ i added inherit images .image-container img{ height:inherit; width:100%; } https://jsfiddle.net/q15oo62d/12/

Why integer division in c# returns an integer but not a float? -

does know why integer division in c# returns integer not float? idea behind (is legacy of c/c++)? in c#: float x = 13 / 4; //imagine used have overridden == operator here use epsilon compare if (x == 3.0) print 'hello world'; result of code be: 'hello world' strictly speaking, there no such thing integer division (division definition operation produces rational number, integers small subset of which.) while common new programmer make mistake of performing integer division when meant use floating point division, in actual practice integer division common operation. if assuming people use it, , every time division you'll need remember cast floating points, mistaken. first off, integer division quite bit faster, if need whole number result, 1 want use more efficient algorithm. secondly, there number of algorithms use integer division, , if result of division floating point number forced round result every time. 1 example off of top of

Inverse 0 and 255 of a matrice in Java OpenCv -

next topic ( getperspectivetransform on non entire quadrangle ), i'm finding way track little dots white on edges table in of cases. if use binary threshold, works if choose arbitrarily threshold. problem edges color table influenced light. decided convert image on hsv , use inrange function keeps pixels between values program determines (i adapt theses values based on mean value of edge table (brown in of cases...)). function returns matrice pixels between range set 255, else 0. i want inverse matrice, mean switch pixels val=0 255 , pixel val=255 0. here simple code (it doesn't work, nothing) : for (int i=0; i<mat.rows(); i++){ (int j=0; j<mat.cols(); j++){ if (mat.get(i,j).get(0)[0] == 0){ mat.put(i,j,255); } else { mat.put(i,j,0); } } } if know how in java , nice.

Weird looking Javascript for loop -

i have never seen javascript loop such for( ; i-- ; ) , used in code: uid: function (len) { var str = ''; var src = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789'; var src_len = src.length; var = len; (; i--;) { str += src.charat(this.ran_no(0, src_len - 1)); } return str; } i understand behavior, if share insights type of loop. this syntax of for-loop construction: for ([ initialization ]; [ condition ]; [ final-expression ])       statement in case for (; i--;) { : no variables initialized, because var = len; inintialized earlier, it's not needed. condition part truthy until i becomes 0 loop terminate. i-- executed on before each iteration, , due -- operator become 0 , it's falsy, , loop stop. since i decremented in condition part of loop, final-expression not needed too. way put it: since i not used inside loop, not matter whether decrement before each loop itera

javascript - how to get the coordinates of google maps marker and store it in textbox or label using asp.net c# -

i'm trying marker's coordinates , store latitude , longitude of marker 2 separate labels. there possible way of getting coordinates , setting labels display them? thank you. here's code tried use doesn't post coordinates <asp:label id="lbllongitude" runat="server" text="longitude: "></asp:label> <asp:label id="lbllong" runat="server" text="label"></asp:label> <asp:label id="lbllatitude" runat="server" text="latitude: "></asp:label> <asp:label id="lbllat" runat="server" text="label"></asp:label> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=aizasybxs9w71w5ggrizwme0rlz7xs69_dezp6i"></script> <script type="text/javascript"> function updatelatposition(latlng) { var lat = document.getelementbyid('hiddenla

javascript - fs.statSync throws an error when contained in a function? -

i'm making function returns boolean when file exists or not, using fs.statsync . looks this: function doesexist (cb) { let exists try { fs.statsync('./cmds/' + firstinitial + '.json') exists = true } catch (err) { exists = err && err.code === 'enoent' ? false : true } cb(exists) } example use case: let fileexists doesexist('somefile.json', function (exists) { fileexists = exists }) however, running code throws me typeerror: string not function . have no idea why. i think want remove callback, , add file name parameters: function doesexist(firstinitial) { try { fs.statsync('./cmds/' + firstinitial + '.json') return true } catch(err) { return !(err && err.code === 'enoent'); } } let fileexists = doesexist('somefile'); btw, there fs.exists .

ruby - Prefixing Route Controllers in Rails -

is there way prefix controller path in routes.rb , don't have specify manually? before: resources :users, :controller => 'api/users' after: resources :users, :controller => 'api/users' or after: resources :users namespace :api resources :users end guide

Intellij autocomplete (a function name) till names diverge and not complete to first suggestion in list -

i trying accomplish quick partial auto-completion in intellij, when typing this: line.setst i these auto-complete suggestions: setstrokewidth setstrokedashoffset setstrokelinecap setstrokelinejoin setstrokemiterlimit .... now wish use auto-complete complete till search results start differ. have no idea if there shortcut this. wish auto-complete to: setst <press something> setstroke is possible? annoys me since used in linux terminal. there's no such option in intellij idea 14. can use camel hump completion , type letter starting words inside identifier need. example, if wish choose "setstrokemiterlimit" list don't want type common prefix, don't need to. need typing "m" after "setst" (so becomes "setsm"). or "setsl". uppercase not necessary: "ssml" match "setstrokemiterlimit", too.

html - Building a responsive navbar with bootstrap -

i building website using bootstrap 3. problem navbar on webpage shows next brand div, floated left. navbar doesn't have enough space when using mobile phone access webpage , have scroll in menu. html <div class="navbar navbar-fixed-top navbar-default" role="navigation"> <div class="container"> <button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.html">future logo</a> <div class="navbar-collapse navbar-responsive-collapse collapse"> <ul class="nav navbar-nav&

.net - Is this c# code enough to handle globalization? -

my c# winforms program used in following countries united kingdom : date format day-month-year , currency separator '.' united states : date format month-day-year , currency separator '.' denmark : date format day-month-year , currency separator ',' i want make program run irrespective of regional settings on users computer. main concern handling date format , currency fields (language translation not problem because program show english text) to have decided dates in database saved yyyy-mm-dd format , decimal fields saved . separator. created database danish_norwegian_ci_as collation . assuming data saved in above datetime format & decimal format without me requiring special. i have put following code in program var cult = new cultureinfo("en-gb"); thread.currentthread.currentculture = cult; thread.currentthread.currentuiculture = cult; cultureinfo.defaultthreadcurrentculture = cult; cultureinfo.defaultthreadcurrentu

ios - Notification of changes to Documents directory when device locked /app not active -

im detecting changes in documents directory https://stackoverflow.com/a/20423421/1238867 predictively not monitor change if device in standby/locked/app not in foreground. i know longshot want observe if changes have happened documents directory when in background? eg device in standby , connected file sharing in itunes, , documents directory altered as flag allowing file sharing read bit of conundrum a lot of searching on , google has not provided anything

vector - Generating decimal values in matlab -

this question has answer here: random numbers add 100: matlab 4 answers how generate vector of lets 5 decimal values such sum 10. for i=1:5 d(i)=rand; end 1)i know generates vector, how include condition? 2) can generate negative numbers well? d = rand(5,1); d = d * 10 / sum(d);

c++ - dynamic stack , error while compiling , dev compiler and g++ -

this dynamic stack , , there functions 1 till 6 , , 0 exit , when choose 6 ,it's shown error "segmentation fault (core dumped) " , have g++ compiler , i'm compiling in , when use codeblocks works , can ` #include <stdlib.h> #include <iostream> using namespace std; const int n=100; struct stack{ int a[n]; int count; }; //создание стека void creation(stack *p) { p->count=0; } //проверка стека на пустоту int full(stack *p) { if (p->count==0){ return 1; } else if (p->count==n) { return -1; } else { return 0; } } //добавление элемента void add(stack *p) { int value; cout<<"Введите элемент > "; cin>>value; p->a[p->count]=value; p->count++; } //удаление элемента void delete(stack *p) { p->count--; } //вывод верхнего элемента int top(stack *p) { return p->a[p->count-1]; } //размер стека int size(stack *p) { return p->

shell - Password management in Bash -

i have functions in .bashrc file used issue backup commands on remote websites. right now, username , password fields stored function-local strings in plain text within function definition. there better way of doing this? my idea far put hashed version of passwords in file user account has read access, run de-hashing command-line function on , store plain text result in memory, use it, clear it. is there better/safer or de-facto common way of accomplishing this? thank you. there 2 ways can think of safely approaching problem. 1. gpg keep gpg encrypted file passwords in in key=value format (shell parsable basically), 1 per line. such as: foo_pass='bar' pop_pass='tart' when want access them, do: eval "$(gpg -d /path/to/file | grep '^foo_pass=')" supersecretpassword="$foo_pass" somecmd if command needs password argument (this unsafe), adjust last line. 2. keyring daemon depending on os, might have access keyr

arrays - How to allocate memory C -

i need int matrix[x][x] field allocated, x user input , want rows 1 continous block of memory. lets user inputs x=5 , when matrix [1][6] = 1 i want matrix [2][0] = 1 anyone can me ? may suggest different approach: allocate 1-dimensional data-structure holds data in "line". write get-function linearizes these coordinates. class linearmatrix{ int dim; int* memory; public: linearmatrix(int d) : dim(d) { memory = (int*) malloc(dim*dim*sizeof(int)); // insert code fill matrix } int get(int x, int y){ int index = x*dim + y; return memory[index]; } void set(int x, int y, int value){ int index = x*dim + y; memory[index] = value; } ~linearmatrix(){ free(memory); } }; the memory continous way , allows insert checks if coordinates ok. of course, have remove \n characters matrix string raw numbers in array. the linearmatrix used somehow this: linearma

php - Woocommerce plugin gives 'We were unable to process your order' -

i'm using child theme of unite theme . , using woocommerce - excelling ecommerce plugin ecommerce. , done payumoney integration. when i'm checkout, it's giving following error, {"result":"failure","messages":" \n\t\t\t unable process order, please try again.<\/li>\n\t<\/ul>\n","refresh":"true","reload":"false"} where problem?

Python function that handles scalar or arrays -

how best write function can accept either scalar floats or numpy vectors (1-d array), , return scalar, 1-d array, or 2-d array, depending on input? the function expensive , called often, , don't want place burden on caller special casts arguments or return values. needs treat numbers (not lists or other iterable things). np.vectorize might slow ( broadcasting python function on numpy arrays ) , other answers ( getting python function cleanly return scalar or list, depending on number of arguments ) , np.asarray ( a python function accepts argument either scalar or numpy array ) not getting dimensions required output array. this type of code work in matlab, javascript, , other languages: import numpy np def func( xa, ya ): # naively, thought do: xy = np.zeros( ( len(xa), len(ya) ) ) j in range(len( ya )): in range(len( xa )): # complicated xy[i,j] = x[i]+y[j] return xy works fine arrays: x = np.array([1., 2

escaping - HTML Character Form -

i have text area / form: <div><textarea name="subject" rows="3" cols="60" placeholder="please enter subject..." required="true"></textarea></div> and if user types text area: su/bject su\bject shown. is there html way make sure no '\' or other characters apart aa - zz taken form? thanks in advance when submitting, can catch result without unwanted chars doing this: yourtextarea.value = yourtextarea.value.replace( /[^a-za-z]/g , ''); or if want strip them right on key press, modify text area this: <textarea onkeyup="this.value = this.value.replace( /[^a-za-z]/g, '');" name="subject" rows="3" cols="60" placeholder="please enter subject..." required="true"></textarea>

php - Get MySQL row with HTML textbox, return column -

i have mysql database containing table called hashes_md5 these columns: plain,hash . want make simple php script user inputs text within textbox. php script should text in column 'plain' , if exists, return value column 'hash' corresponding row. have connection mysql server done: <?php $connection = mysql_connect("localhost", "root","password"); or die ("error occured. credentials correct?"); mysql_select_db("hashes") or die ("error occured. database doesn't exist."); $query = "select plain, hash hashes_md5"; $result = mysql_query($query); while($row = mysql_fetch_object($result)) { echo "$row->plain, $row->hash <br>"; } ?> how can this? and have done? here sql command rest you: select hash hashes_md5 plain='$plain_escaped_hash' but sure? hash 1 way encoding, can md5() input , print out! if user wants crack hash can enter hash

c++ - Set default comparison type in Template -

i want set default class type default comparison type in template , want compares 2 character strings using templates, did write code it’s giving error. code , error given below, class casesencmp{ public: static int isequal(char x, char y){ return x==y; } }; template<typename c=casesencmp> int compare(char* str1, char* str2){ for(int i=0; i<strlen(str1) && i<strlen(str2); i++) if(!c::isequal(str1[i], str2[i])) return str1[i]-str2[i]; return strlen(str1)-strlen(str2); } main(){ char *x = "hello", *y = "hello"; compare(x,y); } but when have added prototype of template, works template<typename c> compiler gives error error: default template arguments may not used in function templates without -std=c++11 or -std=gnu++11| also when try type casting in main function using code, works compare<casesencmp>(x,y); but want set default policy i faced issue in code::blocks. tackle

stored procedures - Execute SQL Task in TSQL -

i have multiple sql tasks execute stored procedures. intend call these sql tasks in other stored procedure. how do ? in these sql tasks, have exec sp statement.all these sql tasks need start in stored procedure only. you can't call individual ssis tasks, can call ssis package stored procedure. procedure not totally straight-forwards , won't put instructions here, there many sites so . however, if these tasks call sp, why not call sp?

Thymeleaf: Error Resolving Template -

i trying use layouts/templates thymeleaf i'm getting following exception. exception processing template "user/index": error resolving template "/layouts/default.html", template might not exist or might not accessible of configured template resolvers here thymeleafconfig.java @configuration public class thymeleafconfig { @bean public servletcontexttemplateresolver templateresolver() { servletcontexttemplateresolver resolver = new servletcontexttemplateresolver(); resolver.setprefix("/web-inf/views/"); resolver.setsuffix(".html"); resolver.settemplatemode("html5"); resolver.setorder(1); return resolver; } @bean public springtemplateengine templateengine() { springtemplateengine engine = new springtemplateengine(); engine.settemplateresolver(templateresolver()); engine.adddialect(new layoutdialect()); engine.adddialect(new sp

mysql - Search functionality: loop through all database tables (Laravel) -

i'm looking way loop through database tables in laravel in order add search functionality website. i guess there should way without hardcoding table names. you can this: $tables = db::select("select table_name information_schema.tables table_schema='your_database_name'"); just change your_database_name own value. can use laravel helper function, array_pluck , array of table_name values. array_pluck($tables, 'table_name')

angularjs - moving video forward/backward frame by frame using Videogular API -

is there way seek video frame frame using videogular api? if not, best work around? thanks! came across need myself. here directive created. note hardcoded framerate , i'm showing controls when player paused. app.directive("vgframebuttons", ["vg_states", function (vg_states) { return { restrict: "e", require: "^videogular", template: '<button class="iconbutton" ng-click="prevframe()"><i class="fa fa-angle-double-left"></i></button>' + '<button class="iconbutton" ng-click="nextframe()"><i class="fa fa-angle-double-right"></i></button>', link: function (scope, elem, attr, api) { var frametime = 1 / 29.97; scope.prevframe = function () { api.seektime((api.currentti

java - Mockito and CDI bean injection, does @InjectMocks call @PostConstruct? -

i have code: class patient { @inject syringe syringe; @postconstruct void saythankyoudoc() { system.out.println("that hurt crazy!"); } } @runwith(mockitojunitrunner.class) class testcase { @mock syringe siringemock; @injectmocks patient patient; //... } i expected mockito call postconstruct, had add: @before public void simulate_post_construct() throws exception { method postconstruct = patient.class.getdeclaredmethod("saythankyoudoc", null); postconstruct.setaccessible(true); postconstruct.invoke(patient); } is there better way this? although not direct answer question, suggest move away field injection , use constructor injection instead (makes code more readable , testable). your code like: class patient { private final syringe syringe; @inject public patient(syringe syringe) { system.out.println("that hurt crazy!"); } } then test be: @runwith(mockitojunitrunner.clas

Call C++ function pointer from Javascript -

is possible pass function pointers c++ (compiled javascript using emscripten) directly-written js? i've found ways of creating function pointers of javascript functions pass c++, not way of exposing function pointer, given value @ runtime in c++ code, javascript. code-wide, i'm after able complete code snippet below in order call function passed cfunctionpointer i'm doing console.log void passtojs(void (*cfunctionpointer)()) { em_asm_args({ // prints out integer. able // call function represents. console.log($0); }, cfunctionpointer); } found answer @ https://stackoverflow.com/a/25584986/1319998 . can use runtime.dyncall function: void passtojs(void (*cfunctionpointer)()) { em_asm_args({ module.runtime.dyncall('v', $0, []); }, cfunctionpointer); } the 'v' signature of void function doesn't take arguments. apparently supports other signatures, such 'vii' , void function takes 2 integer arguments. i

Parallel Image Processing in OpenMP - Splitting Image -

i have function defined intel ipp operate on image / region of image. input image pointer image, parameters define size process , parameters of filter. ipp function single threaded. now, have image of size m x n. want apply filter on in parallel. main idea simple, break image 4 sub images independent of each other. apply filter each sub image , write result sub block of empty image each thread write distinct set of pixels. it's processing 4 images each on own core. this program i'm doing with: void openmptest() { const int width = 1920; const int height = 1080; ipp32f input_image[width * height]; ipp32f output_image[width * height]; ippisize size = { width, height }; int step = width * sizeof(ipp32f); /* splitting image */ ippisize section_size = { width / 2, height / 2}; ipp32f* input_upper_left = input_image; ipp32f* input_upper_right = input_image + width / 2; ipp32f* input_lower_left = input_image + (heig

database - How to create a temporary / dynamic / virtual table when a SQL runs in Oracle? -

i have data has measured not in table. can not insert table nor can create table , insert these data. used dual following table. used join other tables. with movie_genre ( select '10' "id", 'action' "genre" dual union select '20' "id", 'horror' "genre" dual union select '30' "id", 'comedy' "genre" dual union select '40' "id", 'adventure' "genre" dual union select '50' "id", 'drama' "genre" dual union select '60' "id", 'mystery' "genre" dual union select '70' "id", 'musical' "genre" dual ) select * movie_genre ; so result - id genre 10 action 20 horror 30 comedy 40 adventure 50 drama 60 mystery 70 musical my question is, there better way this? suggestion life saver. an example - lets have table - create table movi

css - Horizontally center fluid div containing elements set to float left -

i've centred inner div in parent div elements contained in inner div not horizontally in line. for approach see demo . i'm aware of 2 common apprroaches centering div in div i.e. using html below: html: <div id="outer" style="width:100%"> <div id="inner">foo foo</div> centering method 1: #inner { width: 50%; margin: 0 auto; } centering method 2: #outer { text-align: center; } #inner { display: inline-block; } correct me if i'm wrong but: method 1 seems suitable if inner div have set width. method 2 seems suitable if width of inner div fluid , contains 1 element multiple elements aren't horizontally in line. edit: what describe in method 2 above issue i'm having i.e. rather outcome seen in demo i'm trying achieve. << < march - 2016 > >> i'm looking best way remedy whilst making sure width of centred div dyna

jsp - How to compare a form field with db values using jstl -

hi m using code , recherche name of input in form problem tryin make search using jsp jstl servlet of jstl code <c:foreach items="${offrerecherche}" var="o" > <c:choose> <c:when test="${o.type==recherche}"> <tr> <td><c:out value="${o.idoffre}"/></td> <td>${o.nameoffre}</td> <td>${o.specialite}</td> <td>${o.adresse}</td> <td>${o.region}</td> <td>${o.etat}</td> <td>${o.type}</td> </tr> </c:when> would u me plz

ruby on rails - Searchkick / Elasticsearch exact match -

i using elasticsearch through searchkick i have field called "detail" thats analyzed using "standard" analyzer ... in google "several words" search exact match .. can same in searchkick? not looking fields: [{detail: exact}, name] because match whole article ... term whole not individual words. you need use match_phrase: true . can see in elastic search documentation. but feature not merged yet in searchkick. fyi: github pull request think can use monkey-patch add feature project.

uml - Activity diagram of use-case, do I include <<includes>> in it? -

Image
if i'm example making activity diagram (flowchart) of "update component", need include "show available component updates" activity diagram in 1 too? different use-cases, "update component" includes "show available component updates" thanks. contrary " one sequence diagram per 1 use case scenario " best practice, there's no rule (as far know) how broad in scope should activity diagram be. the rule applies here " use level of detail makes things clear enough readers ". i think it's best justified the guru said in interview mark collins-cope objective view magazine on sep 12, 2014 grady booch, creator of unified modelling language (uml) : "the uml should used reason alternatives. put diagrams. throw use cases against it. throw away diagrams write code against best decision. repeat (and refactor)" for instance activity diagram in uml-diagrams.org: uml activity diagram e

google maps - how to make button start new activity containing android googlemap -

i have created class display google map want make class start first when press class button go googlemap class app crashing when press button code of new class import android.content.intent; import android.os.bundle; import android.view.view; public class homepage extends mainactivity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.layout1); } public void onclick(view view) { startactivity(new intent("com.example.gmapsapp.mainactivity")); } public void onclick1(view view) { startactivity(new intent("com.example.gmapsapp.homepage2")); } } this mainactivity contain map public class mainactivity extends fragmentactivity { private static final int gps_errordialog_request = 9001; googlemap mmap; private static final double nasrcity_lat = 30.066108, nasrcity_lng =31.336184; private static final float defaultzoom = 13;

Google Cloud Ruby API Authorization / Client / Token handling -

i'm struggling bit google cloud ruby api in rails app , looking guidance. here's few questions , appreciated. key = google::apiclient::keyutils.load_from_pkcs12('file.p12', 'notasecret') client = google::apiclient.new({:application_name => "app name", :application_version => "1.0"}) client.authorization = signet::oauth2::client.new( :token_credential_uri => 'url', :audience => 'audience', :scope => 'scope', :issuer => '', :signing_key => key) client.authorization.fetch_access_token! probably important: "client.authorization.fetch_access_token!" does need called every time? supposed saving off access token , using until expires or library take care of me? what for? works is, copied value example found online. should using differently? 'notasecret' :application_name , :application_version -- these used for? doc d

ruby on rails - Coping with "string contains null byte" sent from users -

i have api controller receives information media file's path , id3 tags, , saves them active record instance, using postgresql/rails. sometimes user sends strings such as: "genre"=>"hip-hop\u0000hip-hop/rap" and rails/postgres aren't happy when trying persist on save : an argumenterror occurred in internals#receive: string contains null byte activerecord (3.2.21) lib/active_record/connection_adapters/postgresql_adapter.rb:1172:in `send_query_prepared' how can clean string in ruby remove null bytes? the gsub method on string suitable. can string.gsub("\u0000", '') rid of them. http://ruby-doc.org/core-2.1.1/string.html#method-i-gsub

javascript - Using query URL in the form -

i practicing on how query url. not expected output. here code: form 1: <html> <head> <title>save value</title> </head> <body> <form action="display.html" method="get"> <label> first name: <input name="name" size="20" maxlength="25" type="text" id="name" /> </label> <input type="submit" value="submit" /> </form> </body> </html> form 2: <html> <head> <title>display</title> <script type="text/javascript"> <script type="text/javascript"> function queryvar(variable) { var query = location.search.substring(1); var vars = query.split("&"); var i; (i = 0; < vars.lenght; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return(false

c# - Passing a javascript function to ReactJS.NET Server side -

i have pretty basic, complicated question. i using reactjs.net render react components server side. have typeahead component use multiple times throughout site. 1 of properties expects javascript filter function. i don't want have create seperate component each instance of typeahead, pass in javascript function property can reuse component throughout site. for example, render component on server following. second parameter properties argment @html.react("components.worksitetypeahead", new { filterfn = model.somefunction }) now reactjs.net expects native c# objects (string, array, list, etc), don't see straight forward way pass in javascript function. ideas on how go telling mvc5 view render function not string? first instinct there might sort of javascript raw type not aware of, haven't been able find it. as suspected, @ least 1 way go use newtonsoft's jraw type. @html.react("components.worksitetypeahead", new { filterfn

java - formatting toString method using String.format -

required output: code: 123 title: booka fees(sgd): $20.00 loan duration: 3 wks return string.format("%-20s%-20s%\n", "code: " + code, "title: " + title, "%.2f\nfees(sgd): $" + fees, "lesson duration: " + lessonduration + "wks"); it returns first 3 (code, title, fees) not loan duration. put in %.2f fees of 2 decimal place? your question asks "loan duration", example code uses "lesson duration". problem. that %.2f should work setting 2 decimal places. how behaving?

MYSQL Prepared Statements Select Row_Count -

i have simple sql query: $stmt = $db_main->prepare("select id user username=? , mail=? limit 1"); $stmt->bind_param('ss', $username, $mail); $stmt->execute(); and want know, if found user. want count rows found. tried use rowcount (not safe select) or num_rows or looking if result id numeric (which '' not be, hoped...) there has easy way count selected row, hasn't be? check number of rows returned with: $stmt->num_rows; check instance this site . p.s. : added per question in comment: use fetch() in order next record. ... $stmt->execute(); $stmt->bind_result($user_id); // access id $stmt->store_result(); // optional: buffering (see below) if ($data = $stmt->fetch()) { { print("id: " . $user_id); } while ($data = $stmt->fetch()); } else { echo 'no records found.'; } regarding store_result() documentation : "you must call mysqli_stmt_store_result(

excel - VBA web data not showing entire table -

i trying download table excel sheet loop through next table.the loop working(very slow though) getting top of page up(the top 5 lines dog name trainer name etc) , main table not appear.i cookie message up. suggestion welcome: option explicit sub macro1() sheets("sheet1").select range("a1").select dim integer dim e integer dim myurl string, shorturl string sheets("sheet1").select = 1 while < 3 myurl = "url;http://www.racingpost.com/greyhounds/dog_home.sd?dog_id=" & & "" activesheet.querytables.add(connection:=myurl, destination:=range("$a$1")) .name = shorturl .fieldnames = true .rownumbers = false .filladjacentformulas = false .preserveformatting = true .refreshonfileopen = false .backgroundquery = true .refreshstyle = xlinsertdeletecells .savepassword = false .savedata = true .adjustcolumnwidth = true .refreshperiod = 0 .webselectiontype = xlentirep