Posts

Showing posts from March, 2014

c# - MVVMLIGHT: MouseDoubleClick does not work -

i have listbox eventtrigger mousedoubleclick. this does not work : eventname="mousedoubleclick" this works : eventname="mouseleftbuttonup" here's view <listbox x:name="mylistbox" /> <i:interaction.triggers> <i:eventtrigger eventname="mousedoubleclick"> <command:eventtocommand command="{binding userselectioncommand}" commandparameter="{binding selecteditem, elementname=mylistbox}" /> </i:eventtrigger> </i:interaction.triggers> in viewmodel public relaycommand<string> userselectioncommand {get; private set;} userselectioncommand = new relaycommand<string>(showselecteditem); private void showselecteditem(string selecteddata) { .. } the closing listbox should after interaction.triggers, not before. <listbox> <interact...

java - add jbutton at runtime -

i building application on socket programming in swing in server listens clients , if client connected want a button should added each client if connected on server screen add listener on each button.for example add send message function each client i have created thread in server listens client connections can not add jbutton @ runtime. please reply. is need ? : import javax.swing.*; import java.awt.event.*; public class newbuttononruntime { static jpanel panel; static jframe frame; public static void main(string[] args){ javax.swing.swingutilities.invokelater(new runnable() { @override public void run() { frame = new jframe("add buttons"); jbutton button = new jbutton("simulate new client"); button.addactionlistener(new actionlistener(){ public void actionperformed(actionevent e) { jbutton jb = new jbutton("a new client"...

windows 7 - how to keep floating point precision in R? -

i assign floating point number variable in r. e.g. k <- 1200.0000002161584854 i got > k [1] 1200 > k+0.00000001 [1] 1200 how keep precision of k ? i have read posts here, but, not find solution. in addition above answers, notice value of k different assigned it. have 15 or 16 digits of precision (most of time more need). k <- 1200.0000002161584854 sprintf('%1.29f',k) "1200.00000021615846890199463814497" note there libraries can increase precision, such gmp , designed around integers.

c - Array Sorting and Merging -

Image
#include<stdio.h> #include<string.h> int main(){ char a[10],b[10],temp; int lena,lenb,i,j,k; scanf("%s %s",&a,&b); lena = strlen(a); lenb = strlen(b); char c[lena+lenb]; for(i=0;i<lena;i++){ for(j=0;j<lena;j++){ if(a[i]<a[j]){ temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for(i=0;i<lenb;i++){ for(j=0;j<lenb;j++){ if(b[i]<b[j]){ temp = b[i]; b[i] = b[j]; b[j] = temp; } } } i=0;j=0; for(k=0;k<(lena+lenb);k++){ if(i<lena && j<lenb){ if(a[i]<b[j]){ c[k]=a[i];i++; } else{ c[k]=b[j];j++; } } else if(i==lena){ c[k]=b[j]; j++; } else if(j==lenb){ c[k]=a[i]; i++...

Proper location of Thymeleaf views for Spring -

i running spring boot application thymeleaf. when run application through ide (intellij) runs fine. however, when run application through command line ( java -jar ) views not resolve , following error: org.thymeleaf.exceptions.templateinputexception: error resolving template "index", template might not exist or might not accessible of configured template resolvers @ org.thymeleaf.templaterepository.gettemplate(templaterepository.java:245) @ org.thymeleaf.templateengine.process(templateengine.java:1104) @ org.thymeleaf.templateengine.process(templateengine.java:1060) @ org.thymeleaf.templateengine.process(templateengine.java:1011) @ org.thymeleaf.spring3.view.thymeleafview.renderfragment(thymeleafview.java:335) @ org.thymeleaf.spring3.view.thymeleafview.render(thymeleafview.java:190) @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1225) @ org.springframework.web.servlet.dispatcherservlet.processdispatchres...

google maps api 3 - returning variable from javascript function -

i'm trying return longitude , latitude function, can console.log both of them, when try return 1 of them, undefined. how can return latitude, longitude? function latlong(location) { var geocoder = new google.maps.geocoder(); var address = location; var longitude; var latitude; geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.geocoderstatus.ok) { latitude = results[0].geometry.location.lat(); longitude = results[0].geometry.location.lng(); } else { alert("geocode not successful following reason: " + status); } console.log(longitude); }); } you don't. the used technique pass callback latlong function parameter, , run function when receive result. something like: function latlong(location, callback) { var geocoder = new google.maps.geocoder(); var address = location; var longitu...

unicode - check python version(s) from within a python script and if/else based on that -

basically i'd know if there way know version of python script using within script? here's current example of i'd use it: i make python script use unicode if using python 2, otherwise not use unicode. have python 2.7.5 , python 3.4.0 installed, , running current project under python 3.4.0. following scirpt: _base = os.path.supports_unicode_filenames , unicode or str was returning error: _base = os.path.supports_unicode_filenames , unicode or str nameerror: name 'unicode' not defined so changed in order work: _base = os.path.supports_unicode_filenames , str is there way change effect: if python.version == 2: _base = os.path.supports_unicode_filenames , unicode or str else: _base = os.path.supports_unicode_filenames , str you define unicode python 3: try: unicode = unicode except nameerror: # python 3 (or no unicode support) unicode = str # str type unicode string in python 3 to check version, use sys.version ,...

php - MySQLi UPDATE isn't working. -

for reason can't update work, after hours of googling can't seem find working code. $stmt = $con->prepare("update user_settings set accept_emails = ? user= '$user'"); $stmt->bind_param('s', '0'); $stmt->execute(); $stmt->close(); trying update via ajax, keeps returning 500 server error. should use old mysql way? i pretty sure can't use literal in bind variables. should use. $var="0"; $stmt = $con->prepare("update user_settings set accept_emails = ? user=?"); $stmt->bind_param('ss',$var,$user); $stmt->execute(); $stmt->close();

c# - How to open a form only if Login information is correct? -

i apologize if title confusing wasn't sure of best way word question. basically trying open form form if correct login information inputted text boxes. if incorrect credentials inputted form isn't displayed. when attempting caused error in else statement saying 'invalid expression' due me wanting show user_menu screen in line above. does know how can make form open when login information correct? below code 'login button'. private void button1_click(object sender, eventargs e) { try { var sr = new system.io.streamreader("f:\\top-up year 1\\ood\\srs_system3\\srs_system\\login.txt"); username = sr.readline(); password = sr.readline(); user_menu usermenu = new user_menu(); sr.close(); if (username == textbox1.text && password == textbox2.text) messagebox.show("you logged in!", "success!"); ...

c# - attach a client certificate through code when connecting to an OData service -

am trying query odata web.api hosted on iis7. site requires client cert. how attach certificate query? using web.api 2, framework 4.5, mvc5 string certpath = @"e:\clientcertificate.cer"; uri uri = new uri("https://server/odata/"); var container = new courseservice.container(uri); container.clientcertificate = new x509certificate(certpath); the extension container class achieved reading this: http://bartwullems.blogspot.co.uk/2013/03/odata-attach-client-certificate-through.htm you attach certificate request in sendrequest2 event yourself: context.sendingrequest2 += (sender, eventargs) => { // can safely cast requestmessage httpwebrequestmessage if not in batch. if (!eventargs.isbatchpart) { ((httpwebrequestmessage)eventargs.requestmessage).httpwebrequest.clientcertificates.add(thecertificate); } };

prolog - right linear context free grammar -

i've problem. have write right linear context free grammar alphapet={0,1} numbers of 0 , numbers od 1 odd. tried write sth. it's doesn't work. s --> [1],a. s --> [0],b. --> []. --> [1],c. --> [0],b. c --> [1],k. c --> [0],b. b --> [0],k. b --> [1],d. d --> [1],b. d --> [0],c. k --> []. k --> s. grammar should accept amount of 0s , odd amount of 1s. grammar context free right linear when a->wb or a->w w word under our alphabet , a,b no terminals how about s --> [1],oddonesevenzeros. s --> [0],oddzerosevenones. oddonesevenzeros--> []. oddonesevenzeros--> [1],s. oddonesevenzeros--> [0],oddzerosoddones. oddzerosevenones--> [1],oddzerosoddones. oddzerosevenones--> [0],s. oddzerosoddones --> [1],oddzerosevenones. oddzerosoddones --> [0],oddonesevenzeros. the grammar regular because don't have remember parts have passed, can remember current state of each, i.e. 4 different stat...

ios - Core Bluetooth State Restoration -

i working on app reacts on disconnects of peripherals , trying adopt ne state preservation , restoration introduced in ios 7. i did documentation says, means: i added background mode centrals. i instantiate central manager same unique identifier. i implemented centralmanager:willrestorestate: method. when app moves background kill in appdelegate callback kill(getpid(), sigkill); . ( core bluetooth state preservation , restoration not working, can't relaunch app background ) when disconnect peripheral removing battery app being waked expected , launchoptions[uiapplicationlaunchoptionsbluetoothcentralskey] contains correct identifier centralmanager:willrestorestate: not called. if disconnect peripheral method gets called. this how have it: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { nsarray *peripheralmanageridentifiers = launchoptions[uiapplicationlaunchoptionsbluetoothperipher...

Strange behavior involving Python nested lists -

this question has answer here: list of lists changes reflected across sublists unexpectedly 13 answers i have following code: distances = [[100001] * 2] * 2 edge in edges: print(distances) distances[edge[0]][edge[1]] = edge[2] print(distances) print("\n") edges following list of tuples: edges = [(0, 1, 10), (1, 0, -9)] i'm expecting output: [[100001, 100001], [100001, 100001]] [[100001, 10], [100001, 100001]] [[100001, 10], [100001, 100001]] [[100001, 10], [-9, 100001]] but i'm getting output: [[100001, 100001], [100001, 100001]] [[100001, 10], [100001, 10]] [[100001, 10], [100001, 10]] [[-9, 10], [-9, 10]] any ideas what's wrong? try code: >>> distances[0] distances[1] you true. means same objects when modify distances[0] modify distances[1] well. because distances[0] d...

Python: How to return a result from a conditional and then have it re-enter the conditional statement -

thanks ahead of time help. having problems if else statement. below code. basically, if else: is entered means there no data , rest of code should not run. need when else: is entered need return new randx , randy values entered if (dem_arr[randx, randy] > -100): . have tried using while no success. neighbors = [(-1,-1), (-1,0), (-1,1), (0,1), (1,1), (1,0), (1,-1), (0,-1)] mask = np.zeros_like(dem_arr, dtype = bool) stack = [(randx, randy)] # push start coordinate on stack counterstack = [(randx, randy)] if (dem_arr[randx, randy] > -100): count = 0 while count <= 121: x, y = stack.pop() mask[x, y] = true dx, dy in neighbors: nx, ny = x + dx, y + dy if (0 <= nx < dem_arr.shape[0] , 0 <= ny < dem_arr.shape[1] , dem_arr[x, y] > -100 , dem_arr[nx, ny] > -100 , not mask[nx, ny] , abs(dem_arr[nx, ny] - dem_arr[x, y]) <= 5): #set elevation differnce stack.append((nx, ny)) #if point ...

c# - How to fix a rectangle to the borders of the form -

i think i'm not clear, practicing doing pictures on form. it's simple code think it's not worth post it. i want draw semi-transparent rectangles close borders of form, have managed do. problem when re-size form rectangles stay @ original positions, , don't "follow" new position of borders. make sure drawing in form's paint event. way, happen each time control redrawn: on resize example. here's example: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint.aspx public myform() { this.paint += this.paintrectangles; } private void paintrectangles(object sender, painteventargs e) { // use e.graphics draw stuff }

internet explorer 8 - CSS3 PIE not showing rounded corners in IE8 mode within IE11 -

i'm not getting rounded corners in ie8 mode within ie11. i've tried both relative , absolute paths, , neither work. pie.htc file in same folder html file. i'm running on jetty , don't have .htaccess file. pie.htc file can loaded without problem using http://localhost:8383/various_forms2_less/pie.htc <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <style> span.command_link_buttoned { background-color: #96afcf; display: block; width: 130px; height:30px; position:relative; border-radius: 5px; behavior: url(pie.htc); /*behavior: url(http://localhost:8383/various_forms2_less/pie.htc);*/ } </style> </head> <body> <span class=...

math - (7 - 12) mod 24 equals 19 but in C++ it equals 4294967291 -

this question has answer here: is there reason languages allow negative modulus? 6 answers if google (7 - 12) mod 24 answer 19 . when c++ 4294967291 uint32_t hour = (7 - 12) % 24; // hour = 4294967291 if try int32_t int32_t hour = (7 - 12) % 24; // hour = -5 (7 - 12) % 24 signed expression, , assigning unsigned int makes see different result in c % remainder operation (7 - 12) % 24 = -5 unsigned(-5) = 4294967291 // since 4294967291 + 5 = 4294967296 while google , python uses mathematics modulus operation, result 19. , 19 + 5 = 24 c,python - different behaviour of modulo (%) operation

gnuplot impulse color from third column when using polar coordinates -

Image
i'm still pretty new gnuplot been playing lot lately. have data set angles (degree), times delay , depth, find relevant display in polar coordinates color of impulses depending on depth. works fine when using normal x,y coordinates, when using polar coordinates, color wrong... let's data test.txt: 15 0.2 60 30 0.1 50 35 0.4 10 60 0.2 70 90 0.3 12 120 0.2 5 if do: set palette defined ( 0 "red", 1 "yellow", 2 "cyan", 3 "blue", 4 "magenta") set cbrange [0:80] set xrange [0:180] plot "test.txt" u 1:2:3 impulses lw 2 lc palette it's good! but if use same palette , do: set polar set angles degrees set xrange[0:0.5] set yrange[-0.5:0.5] plot "test.txt" u 1:2:3 impulses lw 2 lc palette i nice polar coordinates graph not right color impulses... what's wrong this? i've seen post explaining how color impulses using "lc variable" or "lc var z", did not work polar data.....

javascript - Using Angular services to hold commonly required data -

i writing first application in angular , have been enjoying framework has offer far. newbies set off building main controller, copying tutorials. seeing error of ways , refactoring. my question services holding data commonly required among controllers. i've taken data out of 'main controller' , placed service have injected both controllers requiring access. though neither controller sees functionality i've defined in new service: varianceservice not defined being new approach welcome , help, aswell current problem, comments on best way apply approach highly appreciated. thanks in advance. here example of code: var app = angular.module( 'varianceanalysis', ['ngroute', 'nganimate', 'mgcrea.ngstrap', 'mgcrea.ngstrap.tooltip', 'mgcrea.ngstrap.helpers.dateparser', 'sharedservices'] ) .service('varianceservice', function () { var variances = {}; return { r...

How to write this postgres sql query to oracle? -

following postgres sql query have used. need change query run in oracle. select distinct d.id, d.title, d.entityname, d.abstract, d.url, d.ranking, d.forwardemail, d.technologyclass, d.technology, d.product, d.technologytype, d.comments, d.status, d.year, d.day, d.month, d.entitytype, d.entitysource, d.chapter, d.country, d.region, d.address research_data d d.status = 'a' , d.id in(select e.parent_id research_data_history e e.changed_date::date = to_date('02-01-13', 'mm-dd-yy')) what have tried? getting error when running in oracle? should have remove ::date sub sele...

android - How to Send alarm time to other activity -

hi new android want create alarm rang when alarm time found unfortunately couldn't make please me out problem here mainactivity.class , soundactivity.class file 1 can tell me how set out please? thank package com.toprecur.myalarm; package com.toprecur.myalarm; import java.util.calendar; import java.util.gregoriancalendar; import android.app.activity; import android.app.alarmmanager; import android.app.pendingintent;`enter code here` import android.content.intent; import android.os.bundle; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.view.viewdebug.flagtostring; import android.widget.button; import android.widget.textview; import android.widget.timepicker; import android.widget.toast; public class mainactivity extends activity { protected static final timepicker timepicker1 = null; protected static final calendar calendar = nul...

php - MySQL selecting from multiple tables -

im trying select data multiple tables, fine doing 2 tables query so: $myquery = sql_query( "select a.object_title, a.published_by, b.userid table1 join table2 b on (a.published_by = b.userid)" ); but see now, want select data third table, third table not have relationship such primary key between first 2 tables, want pull data , form sort of link "join". how add third query? thanks you use cross join : $myquery = sql_query( "select a.object_title, a.published_by, b.userid, c.whatever table1 join table2 b on (a.published_by = b.userid) cross join table3 c" ); i used this other post find idea. more infos here .

How to generate random unique number in PostgreSQL using function -

in postgresql, how generate random unique integer number column, return not exits in table column? see pseudo_encrypt function, implements permutation based on feistel network technique. combined postgres sequence, guarantees unicity of result, randomness human eye. exemple: create sequence seq maxvalue 2147483647; create table tablename( id bigint default pseudo_encrypt(nextval('seq')::int), [other columns] ); the effective range of id here 0...2^32-1 . can adjusted if necessary modifying function. variant 64 bits output space can found at: pseudo_encrypt() function in plpgsql takes bigint . edit: pseudo_encrypt implements 1 permutation, , not accept user-supplied key. if prefer having own permutations, depending on secret keys, may consider skip32 (a 32-bit block cipher based on skipjack, 10 bytes wide keys). a plpgsql function (ported perl/c) available at: https://wiki.postgresql.org/wiki/skip32

Manually overwriting the results of SQL query in Access 2010 -

i came across strange situation , hope maybe guys can provide clarity. i run sql query in access , results. if enter results window , manually alter record, re-run query, result of query show alteration instead of correct value. how can be? moreover, field alter attribute table, re-running should retrieve value original table, instead on alteration query, right? thanks! when you're using access, long query isn't complicated union , lots of other fun stuff, the queries returned not 'static' 'dynamic': changes make cells directly edit db. yes, query retrieving value table save changes make table. if run query programatically can specify whether make read-only or not results window directly edits tables queries.

c - why is if(1/10) and if(0.1) have different values? -

this question has answer here: what behavior of integer division? 5 answers just not understand why following 2 have different values. first 1 has value 0, while other has value 1 if(1/10); if(0.1); by default type of 1 int , 1/10 rounded down 0 equivalent false . while 0.1 has bits set , not 0 . on other hand 1.0/10 equivalent 0.1 .

ms access - Preventing MSAccess linked tables from having a dbo_ prefix? -

is there way prevent msaccess concatenating 'dbo_' prefix tables linked sql server db? no. microsoft access' native naming convention process force name <schema>_<objectname> default table name. there no controls or settings allow change that, except in code. it's rather complex , goes beyond scope of question, if linking in code (which do) can store tablealias , create linked table name way.

c++ - expected primary-expression before ']' token" -

//purpose: simulate probability car make decision in video game. //40% of time car turn left, 30% right, 20% straight, , 10% explode. #include <iostream> #include <cstdlib> #include <time.h> #include <iomanip> using namespace std; void getcount( count[] ); int main() { int count[4] = {0}; unsigned int k; float theoretical; srand( (unsigned) time(null) ); getcount( int count[] ); cout.setf( ios::showpoint | ios::fixed ); cout << setprecision(2); cout << " car simulation" << endl << endl << " number of experimental theoretical % error " << endl << " times selected percent percent " << endl << " ---------------- -------------- ------------- ------ " << endl; ( k = 0; k < 4; k++ ) {...

sql server - Multiple SQL Databases with EF - Good or Bad design? -

currently have large in house platform makes use of number of different sql databases (all on same server). have created new databases feel data quite different/independant storing in other databases. approach have ended having number of different databases (most have 30-50+ tables), inevitably there connections required between them. as using entity framework, cross database queries proving real pain, have tried number of different approaches , feel main problem ef doesn't work across multiple databases. while know answer "it depends" i'm interested in peoples ideas or views on question should combine of our seperate databases 1 large database? were correct have split our data different databases (even if ef doesn't work it)? how large database talking about? how many tables / how many gbs? type of data goes in? the answer guessed "it depends". here i'd no, splitting not right choice. if having cross database queries, data ...

getting boolean or string from ASP.NET Web API via IOS -

i can value in json format function: nsmutablearray *jsonarrayclass = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; but have no idea how string value or boolean value. have validation return data type. not json. the raw value shown on flidder looks (id00001 return string): http/1.1 200 ok cache-control: no-cache pragma: no-cache content-type: application/json; charset=utf-8 expires: -1 server: microsoft-iis/7.5 x-aspnet-version: 4.0.30319 x-powered-by: asp.net date: mon, 07 apr 2014 17:15:28 gmt content-length: 9 "id00001" try [[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding];

PHP - parallel task runner -

i need parallel task runner in php (most on windows - iis7 fastcgi), has complete implementation hiding. interface should this: $taskrunner = new paralleltaskrunner(); $taskrunner->add(function () use ($sharedresource){ //task 1 }); $taskrunner->add(function () use ($sharedresource){ //task 2 }); $taskrunner->run(); //runs task 1, task 2 parallel i have done research: aware of techniques can run php code parallel - pthreads, pcntl, exec, gearman, curl multi, etc... the questions need answer for: is possible make implementation hiding of these techniques? how possible (if there advanced workaround in implementation details)? there library has feature? how can extract information running of parallel tasks? example: task1: { a(); b(); } , task2: { c(); } , how can know calling order of functions a(); b(); c(); or a(); c(); b(); or c(); a(); b(); ? how can debug tasks if goes wrong? update i checked many possible solution, , ended pthreads. easier use...

r - Difference between standard error and standard deviation? -

Image
i have 2 samples. each calculate number of objects, according time. plot in y axis number of objects , in x axis time in hour. in excel have option plot error bars, using standard deviation or standard error. i'd know what's difference between them , if standard error enough show data of 2 samples significant? after reading definition on internet, it's still confusing me, being newbie on statistics. this graph , plotting standard errors, gives. not enough judge significance of data? i think mean have 2 sample populations, right? if have 2 samples means have 2 'records'. standard error refers "standard devation" occurs in sample population. standard deviation refers complete population. significance derived formula helps understand if 'effect' chance alone. also, if meant have 2 samples, not enough statistical research. large studies use thousands of samples. however, "statistical" purposes taught me in math class 36 acc...

java - how to insert binary string of 8 bit to a byte array -

i want convert number 0 256 binary string , store in byte array. there way store binary representation in array? please me,, public static void main(string[] args) { int x= 0; int ; byte[] second = new byte[256]; (i=0; i<=256; i++) { string binarystr = long.tostring(x,2); string output = string.format("%8s", binarystr).replace(' ', '0'); system.out.println(output); second[i] = output; x++; }

c# - Binding to a property of a collection -

context the wpf datagrid allows developers manually bind each column property of itemssource, this: <datagrid itemssource="{binding people}" autogeneratecolumns="false"> <datagrid.columns> <datagridtextcolumn binding="{binding name}"/> <datagridtextcolumn binding="{binding age}"/> <datagridtextcolumn binding="{binding country}"/> </datagrid.columns> </datagrid> the advantage of these column bindings visual studio display design-time warnings if bindings don't correspond property of objects in people collection. provide list of valid properties through intellisense. i'm developing different type of grid , having trouble getting functionality. have developed this: <my:grid itemssource="{binding people}"> <my:column property="name" /> <my:column property="age" /> <my:column property=...

github - Git - how best to store multiple repositories inside one master repository? -

i moving lot of projects private repositories in github. lot of these projects no longer actively in use. such, i'd rather not have dedicated repository per each of these projects - i'd lump them 1 'deprecated projects' repository. , maintain history of each individual project. i've tried placing project directories, along .git directories, main deprecated projects repository, doesn't seem work - directory seems tracked/versioned in main repository, none of it's files. what best option available me in situation? have tried renaming .git directories in sub-directories / projects .git-directory, , seems though removes problem - files in projects added main repository correctly. if indeed work want, acceptable solution - having rename .git-directory folder .git if did want move project out of 'deprecated repositories' repo, , start active development on again. if can confirm whether approach okay, or result in problems, useful. i'm pretty ...

javascript - Remove blankspace from td class with greasemonkey -

if have webpage example alot of <td class="house">111 22</td> . numbers random classname same , blankspace between numbers @ same position in of them, , want remove space in of them after page loaded. how should script work? how using var str = "111 22"; str = str.replace(" ",""); code example : <script type="text/javascript"> //page initial $(function() { removespace(); }); function removespace(){ var str = $(".house").html(); str = str.replace(" ",""); $(".house").html(str); } </script>

javascript - How can I use two twitter bootstrap modals in succession? -

this minor, subtle point, in ux, subtlety makes difference. i have crafted 1-page web app using twitter bootstrap. in 1 particularly important part of application... my user takes action, i present confirmation dialog (technically bootbox confirm ) the user clicks ok confirm the modal disappears, action via ajax takes place, then display secondary modal (bootbox dialog) success message. what trying change step 4. don't want darkened overlay disappear, dialog box itself. instead, leave background dimmed , display spinner (spin.js of course) replaced success modal upon ajax completion. in short, think may need override default behavior of success method of bootbox confirm. is possible? it should work if listen close event on first modal $(document).on('close', '#firstmodalid', function(){ $('#secondmodalid').modal('show'); }); you can try closed event. if timed right user shouldn't see both @ same time , shouldn...

opengl - Cannot draw TextButton or Button in LibGDX for desktop -

i trying make menu in libgdx. cannot button or textbutton drawn in screen. tried using test skin. tried use table. tried use button , textbutton. the image fine because can appears while drawing using spritebatch , font works well. this part of code. public class menu implements screen { private stage stage; private skin skin; private textbutton textbutton; private game mygame; private bitmapfont font; private textureatlas atlas; private spritebatch batch; private textureregion test; public splashscreen(game g){ mygame = g; } @override public void show() { batch = new spritebatch(); stage = new stage(); stage.clear(); atlas = new textureatlas("buttons/bot.pack"); skin = new skin(atlas); font = new bitmapfont(gdx.files.internal("fonts/arialfnt.fnt"),false); textbuttonstyle buttonstyle = new textbuttonstyle(); buttonstyle.up = skin.ge...

Why does Bower remove my "resolutions" and how do I stop it -

i have bower.json file { "name": "example-project", "private": true, "dependencies": { "angular": "1.2.14", "angular-scenario": "1.2.14", "angular-resource": "1.2.14", "angular-ui-router": "0.2.10", "angular-strap": "2.0.0" } } when run grunt (with grunt-bowercopy or grunt-bower-task ) error fatal error: unable find suitable version angular when run bower install says doesn't know version of angular use: unable find suitable version angular, please choose one: 1) angular#1.2.14 resolved 1.2.14 , required angular-scenario#1.2.14, example-project 2) angular#>= 1.0.8 resolved 1.2.16 , required angular-ui-router#0.2.10 3) angular#~1.2.10 resolved 1.2.16 , required angular-strap#2.0.0 prefix choice ! persist bower.json so explains why grunt failing - had transitive dependencies , didn't know 1 ...

R $ operator is invalid for atomic vectors -

i have dataset 1 of columns "#" sign. used following code remove column. ia <- as.data.frame(sapply(ia,gsub,pattern="#",replacement="")) however, after operation, 1 of integer column had changed factor. i wonder happened , how can avoid that. appreciate it. a more correct version of code might this: d <- data.frame(x = as.character(1:5),y = c("a","b","#","c","d")) > d[] <- lapply(d,gsub,pattern = "#",replace = "") > d x y 1 1 2 2 b 3 3 4 4 c 5 5 d but you'll note, approach never remove offending column. it's replacing # values empty character strings. remove column of # might this: d <- data.frame(x = as.character(1:5), y = c("a","b","#","c","d"), z = rep("#",5)) > d[,!sapply(d,function(x) all(x == "#"))] x y 1 1 2 2 b 3 3 # 4...

ruby on rails - Why can't regular expressions match for @ sign? -

for string be there @ six. why work: str.gsub! /\bsix\b/i, "seven" but trying replace @ sign doesn't match: str.gsub! /\b@\b/i, "at" escaping doesn't seem work either: str.gsub! /\b\@\b/i, "at" this down how \b interpreted. \b "word boundary", wherein zero-length match occurs if \b preceded or followed word character . word characters limited [a-za-z0-9_] , maybe few other things, @ not word character, \b won't match before (and after space). space not boundary. more word boundaries... if need replace @ surrounding whitespace, can capture after \b , use backreferences. captures preceding whitespace \s* zero or more space characters. str.gsub! /\b(\s*)@(\s*)\b/i, "\\1at\\2" => "be there @ six" or insist upon whitespace, use \s+ instead of \s* . str = "be there @ six." str.gsub! /\b(\s+)@(\s+)\b/i, "\\1at\\2" => "be there @ six." # no ...

javascript - JQuery Mobile: <script> tags do not show up but code runs -

i'll refer ticket step in right direction need: jquery mobile not loading new page scripts one of answers states code not nested in first $([data-role=page]) tag in jquery mobile not show in html. don't know if maybe browser quirk or not regardless, code getting run despite never showing up. find difficult if want debug js code since can't add break points of it. i've had problem using jquery autocomplete plugin works 1 time , after submitting form , returning the form no longer works. believe because page (well partial piece of jquery mobile) gets reloaded , autocomplete plugin no longer bound textbox. i've tried using live , on methods make sure rebound doesn't work. can javascript/jquery mobile geniuses out there me out problem? thanks!

How to overcome Network Failure error in MySQL -

i developing ci app client mysql end. the client has 8 shops. for each shop, there local server , , additionally, there one central server, placed @ head quarters (hq). the problem facing is, at time of network failure @ shop , billing , other processes should work; without central server . once network back, need sync hq server . those clicking on board on close can please details need? not getting part thats why, please add comment, it this common problem in shop environment, should cope requirements having basic data single store (eg. items, promotions, parameters) , setting database synchronization between local stores , center db ... if have mysql in each store , central db, can set mysql replication, otherwise take @ symmetricds in short missing component can fit scenario, since : symmetricds open source software both file , database synchronization support multi-master replication, filtered synchronization, , transformation across network in ...

Creating a SQLite table row updating row again and again -

i have created table application... first time user give input 2 edittext ,name , mobile number when table empty after updating first row of table...so on a scenario: add new record name:"name1", telephone: "123456789" --> new record add new record name:"name2", telephone:"987654321" --> update entered record. if want then: be sure insert new record same id inserted one. use db.insertwithonconflict() [ link ] insert new records, passing value conflict_replace [ link ] last parameter conflictalgorithm sample code void add_contact(person_contact contact) { db = this.getwritabledatabase(); contentvalues values = new contentvalues(); // single_row_id constant holding single row id used. e.g: single_row_id = 1 values.put( key_id, single_row_id ); values.put( key_name, contact.get_name() ); // contact name values.put( key_ph_no, contact.get_phone_number()); // contact phone // ins...

css3 - Design html table as gridView -

i work vb.net. have gridview attribute "gridlines". when gridlines="both" mark lines in color , shape. want same design in regular html table, through css. how can it? you can using applying class in gridview , set gridlines="none" none. here give example <asp:gridview id="grid_patient" style="width: 100%;" cssclass="salesgrid" runat="server" gridlines="none" autogeneratecolumns="false" processfocusedrowchangedonserver="disable" > and css below .salesgrid { font-size: 12px; overflow: hidden; border:1px solid #000000; }

windows - Android Studio: Change location of .gradle directory -

i using android studio 0.52 default wrapper implementation. when open project android studio downloads gradle 1.11 distribution files {user.home}/.gradle directory. unfortunately folder mapped network drive, has limited space. i tried setting global environment variable gradle_user_home local drive, didn't work. "installed" gradle locally , chose local installation in android studio's gradle settings , set service directory path local drive. keeps downloading files {user.home}/.gradle why android studio ignore env variable? there way change gradle_user_home in android studio? thanks! there bug report http://issues.gradle.org/browse/gradle-2414 describing problem. while bug fixed gradle's point of view see fixed when idea/android studio picks newer version of gradle tooling api distribution.

MYSQL Search query taking too long in php. Server times out -

i have table sub_mastersheet around 50 columns , 30,00,000 entries. trying run query in taking way long , server times out. other queries on table working ok. here query: select * sub_mastersheet contributor_name1 = '$author' or contributor_name2 = '$author' or contributor_name3 = '$author'; i've tried: select * sub_mastersheet contains(contributor_name1, '$author'); none of above 2 queries working , server times out. on php admin these queries take hour execute. can help? add index on columns (contributor_name2,contributor_name2) it improve performance of query.

What is the best way to store local in android? -

i have build quiz app 1500 questions .i need 1 random question . don't have load questions once .. best way store questions sql,json,xml ? probably amount of questions, i'd go using sql database. depends, however, kind of choose, if local or centralized one. if plan change questions time time, can have relatively strong server users might connect webservice , questions, i'd recommend centralized storage database. if plan not change them, they'll static, or same users, or can't afford having remote server, use sqlite database local every device, , each time start app, load questions (or queries when need them).

r - Custom legend in fille.contour3 -

i trying use costume legend filled.contour3, in example: colorramppalette(c('white','blue','green','yellow','red','darkmagenta','darkviolet'))(15) when use filled.contour3 predefined legend (e.g., terrain.colors) works fine. if try add costume legend (e.g., terrain.colors(10)) error message: error in .filled.contour(as.double(x), as.double(y), z, as.double(levels), : not find function "color.palette" here sample code: #generate fake data x = rep(c(10,11,12),length = 9) y = rep(c(1,2,3),each = 3) z = runif(n=9,min = 0,max = 1) xcoords = unique(x) ycoords = unique(y) surface.matrix = matrix(z,nrow=length(xcoords),ncol=length(ycoords),byrow=t) #this works: filled.contour3(xcoords,ycoords,surface.matrix,color=terrain.colors,xlab = "",ylab = "",xlim = c(min(xcoords),max(xcoords)),ylim = c(min(ycoords),max(ycoords)),zlim = c(min(surface.matrix),max(surface.matrix))) #this doesn't work:...

java - Terminating a user input determined Scanner? -

i wonder if explain why scanner keeps waiting on input? have stop process on eclipse before code block executes , unsure why scanner keep taking input day . expect press enter , code execute after entering x amount of numbers. public static void main(string[] args){ scanner ascanner = new scanner(system.in); int sum = 0; system.out.println("enter ints : "); while(ascanner.hasnextint()){ sum += ascanner.nextint(); } system.out.println(sum); } if want program take x amount of numbers, have counter , break while loop after has executed x number of times. alternatively, use loop make things easier. you use ctrl+z in eclipse stop console waiting inputs.

javascript - How to allow regex to work for mm/dd/yyyy and yyyy-mm-dd format -

my regex mm/dd/yyyy is: /^((0[1-9]|1[012])[\/](0[1-9]|[12][0-9]|3[01])[\/](19|20)[0-9]{2})*$/ i want use mm/dd/yyyy , yyyy-mm-dd both format. i tried below 1 don't want user type in number date , month. /^((\d{4})-(\d{2})-(\d{2})|(\d{2})\/(\d{2})\/(\d{4}))$/ i tried below make work not sure wrong here: /^((0[1-9]|1[012])[\/](0[1-9]|[12][0-9]|3[01])[\/](19|20)[0-9]{2})|((19|20)[0-9]{2})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])*$/ the below gives function produces parser format 1 describe. dateparser('yyyy/mm/dd')('1990-03-25') { y: 1990, m: 3, d: 25 } . you can use chain function chain([dateparser('mm/dd/yyyy'), dateparser('yyyy-mm-dd')])('2014-04-04') try formats in order. var patterns = { yyyy: '\\d{4}', yy: '\\d{2}', mm: '0\\d|1[012]', m: '0?\\d|1[012]', dd: '[3][01]|[012]\\d', d: '[3][01]|[012]?\\d', hh: '[2][0-4]|[01][0-9]'...

c# - Item template for TabControl -

Image
i'm using tabcontrol present data different datatable s. xaml code: <tabcontrol margin="5, 5, 5, 5" horizontalalignment="stretch" dockpanel.dock="top" itemssource="{binding path=iteminfoviewmodels}"> <tabcontrol.itemtemplate> <datatemplate> <stackpanel> <textblock text="{binding editingtable.name}"></textblock> <contentcontrol> <partials:iteminfo /> </contentcontrol> </stackpanel> </datatemplate> </tabcontrol.itemtemplate> </tabcontrol> i view looks this: which wrong. - header text , content - displayed header shown. how can change xaml, should? try using contenttemplate instead of itemtemplate . itemtemplate applied header of each tabitem , contenttemplate used display selected tab. ...

Oracle LEFT JOIN View performance -

i have 2 tables, aren't large tables. have created view based on tables select tab_a.id id, tab_a.name name tablea tab_a union select tab_b.id id, tab_b.name name tableb tab_b after all, have third table, lets call tablemain fields: tablemain.id, tablemain.status, tablemain.viewid viewid exists join view final select like select tablemain.id tablemain left outer join view on tablemain.viewid=view.id and join very slow on view. its fast if join directly tablea or tableb, not when using view. it fast if use view.name in select select tablemain.id, view.name tablemain left outer join view on tablemain.viewid=view.id not sure why view join working fast if use view field in select, and how make view join fast without it. posting plans: good plan (using view.name in select) select tablemain.id, view.name tablemain left outer join view on tablemain.viewid=view.id | id | operation | name | rows | byt...

c++ - null character in encrypted data (openssl) -

is possible after cbc encryption, null character appears in resulting multibyte data. if yes, precaution should take avoid it. is possible after cbc encryption, null character appears in resulting multibyte data. absolutely. not pseudo-random function if values 0's missing. if yes, precaution should take avoid it. treat byte array embedded null s. never treat char* . if want treat char* , need encode first. try hexadecimal, base32 or base64.

Create an APK for Android from a kivy/python program -

this question has answer here: kivy apk in windows 1 answer how can create apk android, on windows , kivy & python program? i cannot seem find suitable, easy-to-understand tutorial. how this? the build tools not run directly on windows right now. you have couple of options: 1) use linux virtual machine. kivy provides prebuilt vm image python-for-android ready use, described @ http://kivy.org/docs/guide/packaging-android.html#testdrive . 2) use cloud builder @ http://android.kivy.org/ . there tools access more flexibly buildozer in nearish future.

android - What is the small graphic displayed under an EditText called and how can I remove it? -

after pretty thorough googling still cannot figure out the little graphic that's displayed under text in , edittext view called. remove either using xml or programmatically. little graphic thing under cursor in image: http://1.bp.blogspot.com/-uauoq0h4vok/t8reinvawpi/aaaaaaaabpc/n4yibxd3kzg/s1600/android%2bedittext%2btext%2bchange%2blistener%2bexample.jpg . sorry if dumb question, without name of little graphic feature can't seem find out it. it background drawable associated edittext. can change manually setting background yourself, such <edittext android:background="@android:color/transparent" ... />

svn - Can I import to a subversion repository without importing the parent folder -

i'm sure i'm missing i'm bit out of practice subversion. say i've got folder full of files: /projectname/index.html /projectname/img/a.jpg /projectname/img/b.jpg and want import whole thing subversion, can svn import <foldername> <repository> when import not index.html , images, parent projectname folder. when want check out, i'm going checking out folder too. is there way import folder contents not folder? checkout put index.html , img folder whichever folder doing checkout to? or have import files , folders 1 one? yes , no... when use svn import , importing directory (aka folder). subversion considers directories project locations, , subverion import importing projects. however, don't have use svn import : $ svn co --depth=immeidates $repo/trunk # checkout location project $ cd trunk # go directory $ cp -r /projectname/* . # copy files svn workspace $ svn add -r . ...

objective c - Generate same set of random numbers -

this question has answer here: generate reliable pseudorandom number 2 answers i gave small racing game randomnly generates it's course on start up. course long manually make , wondering if there way can generate same randomn numbers every time? don't want course different everytime... would have save list of randomn numbers in plist? you can use old c-functions. set seed rng: srand(314) . random number: int randomnumber = rand(); . not tested.. form memory. verify works. :)

java - Trying to properly implement Dijkstra's Shortest Path algorithm with 2 short arrays and 1 boolean array -

i trying implement dijkstra's shortest path algorithm. i'm having hard time understanding how test every possible path inside while loop. i've looked specific examples of proper implementation cant find can use code working :\ any pointers appreciated here code package userapplication; `enter code here`import java.util.arraylist; public class shortestpath { private ui ui; private map map; private boolean included[]; private short distance[]; private short path[]; private arraylist<short> trace; private short n; boolean flag = false; // ***************************************************************// public shortestpath(ui ui, map map, short n) { initialize(ui, map, n); } // ***************************************************************// // ***************************************************************// private vo...