Posts

Showing posts from August, 2012

cmake - How to use different tool chains -

in project targets build , run on build platform , other targets build cross platform; options have, when using cmake? currently use cmake_build_type define tool chain, build type , platform (for example -d cmake_build_type=arm_debug ). in 1 place in build, switch tools (compilers, linke etc.), command line flags, libraries etc. according value of cmake_build_type. every build type, create build directory. this approach has it's drawbacks: multiple build directories , no easy way depend 1 target 1 build type on target in other build type (some kind of precompiler needed on build platform build cross platform example). as every build targets has single tool chain used love associate target target platform / tools set. implies libraries have build more 1 target platform different tool sets. the ' one build type , platform per cmake run ' limitation fundamental , advise against trying work around it. the proper solution here seems me split build several s...

python - Convert date in form of "%Y%M%D" to "%Y%M%D%H%M%S" in pandas -

below dataframe date time open high low close volume adj close 0 2012-05-15 15.90 16.06 15.80 16.02 134454.78 0.08 1 2012-05-16 16.00 16.00 15.75 15.76 150305.11 -0.26 2 2012-05-17 15.80 15.97 15.76 15.94 133389.98 0.18 3 2012-05-18 15.80 15.91 15.66 15.72 157863.19 -0.22 4 2012-05-21 15.72 15.84 15.70 15.77 85694.85 0.05 you see in column of "date time", data in form"%y%m%d" want convert them "%y%m%d%h%m$s" example 2012-05-17 00:00:00 thanks! if not need convert datetime, can call apply , use datetime.strftime formatting: in [212]: df['date'] = pd.to_datetime(df['date']) df['date'] out[212]: index 0 2012-05-15 1 2012-05-16 2 2012-05-17 3 2012-05-18 4 2012-05-21 name: date, dtype: datetime64[ns] in [213]: import datetime dt df['date'] = df['date'].apply(lambda x: dt.datetime.strftime(x, '%y-%m-%d %h:%m:%s...

html - google font is not working, lato and raleway -

i trying import font google not working properly. in local system fine when publish code , upload on server not working, using default browser font. platform : mvc.net 4.5 | bootstrap 3.3.4 | html5 | css3 here css. @import url(http://fonts.googleapis.com/css?family=lato:400,100,100italic,300,300italic,400italic,700,700italic,900,900italic); @import url(http://fonts.googleapis.com/css?family=raleway:400,100,200,300,500,600,800,700,900); body { font-family: 'lato', sans-serif;} .banner h1{font-family: 'raleway', sans-serif;} very it's because of mix between secured (https) , unsecured (http) protocols. removing 'http:' font address let browser make choice. try following code: @import url(//fonts.googleapis.com/css?family=lato:400,100,100italic,300,300italic,400italic,700,700italic,900,900italic); @import url(//fonts.googleapis.com/css?family=raleway:400,100,200,300,500,600,800,700,900);

algorithm - Big-O complexity of a piece of code -

i have question in algorithm design complexity. in question piece of code given , should calculate code's complexity. pseudo-code is: for(i=1;i<=n;i++){ j=i do{ k=j; j = j / 2; }while(k even); } i tried algorithm numbers. , have gotten different results. example if n = 6 algorithm output below i = 1 -> executes 1 time = 2 -> executes 2 times = 3 -> executes 1 time = 4 -> executes 3 times = 5 -> executes 1 time = 6 -> executes 2 times it doesn't have regular theme, how should calculate this? the upper bound given other answers high. algorithm has o(n) runtime, tighter upper bound o(n*logn). proof: let's count how many total iterations inner loop perform. the outer loop runs n times. inner loop runs @ least once each of those. for i , inner loop runs @ least twice. happens n/2 times. for i divisible 4, inner loop runs @ least 3 times. happens n/4 times. for i divisible 8, inner loop runs @ le...

java - Using PreparedStament of JDBC with Mysql's TableName end with '\' -

i trying insert mysql database, has table name end ' \ '. name ' abc\ '. public static void main(string[] args) throws classnotfoundexception{ try { class.forname("com.mysql.jdbc.driver"); connection master = drivermanager.getconnection($url,$usr,$pwd); string st = "insert `abc\\` (`pad`,`c`,`k`,`id`) values(?,?,?,?)"; preparedstatement pstmt = master.preparestatement(st); pstmt.setint(1, 10); pstmt.setint(2, 1); pstmt.setstring(3, "1"); pstmt.setstring(4, "2"); pstmt.execute(); master.close(); }catch(sqlexception ex){ ex.printstacktrace(); } but doesn't work, problem : java.sql.sqlexception: parameter index out of range (1 > number of parameters, 0). but, table's name ' a\bc ', backslash not last character, program works well. can me solve problem? lot. it working statement . public...

html5 - How can i render html website in nativescript application? -

how can render html and/or non local website nativescript app? cant find way start or manipulate browser instance. the documentation quite bit, here 2 examples: example url this example create new page webview on , navigate page. url may local (html file on phone) or remote ( http://.. .) var framemodule = require('ui/frame'); var pagemodule = require('ui/page'); var webviewmodule = require("ui/web-view"); var factoryfunc = function () { var webview = new webviewmodule.webview(); webview.url = 'http://www.example.com'; var page = new pagemodule.page(); page.content = webview; return page; }; framemodule.topmost().navigate(factoryfunc); example of loading local data webview an example of have view ( .xml ) , and corresponding .js file , feed string containing html displayed. where .xml is: <page xmlns="http://www.nativescript.org/tns.xsd" loaded="loaded"> <webview id=...

javascript - Any way to raise an error when getting the function instead of running it -

a common error: a = myfunction; ...instead of: a = myfunction(); any way avoid this? in case have function inside object, object avoid return functions , require execution? you can use typeof check if it's function: a = myfunction; var result; if (typeof == "function") // set myfunction, not myfunction() result = a(); else // presumably set myfunction() , not myfunction result = a; this way can call function if indeed function, otherwise can else it, assuming that's you're wanting do.

ios - Error ITMS-90032 in xcode when submitting to App Store -

Image
when want submit app app store keep getting message : does know have place file or if have rename / delete somewhere? this info.plist file : and directory : here worked me: select target go build phases expand copy bundle resources go bottom of panel , select + sign. add each of missing resources.

node.js - node-oracledb other language encoding -

i'm newbie @ node.js! i'm in trouble @ encoding 'korean'. my oracle database has korean string data, , directly console.log(korean text) worked. but when use execute function , select query, , console.log(return rows), isn't work. text broken. i set encoding type in eclipse utf-8. think, have set controlling encoding type in oracledb module, can`t find how set it. please me. have resolve problem @ cost!!! i set nls_lang. don't set it. check , take picture. done when found registry. windows 7 64bit node 0.10.38 eclipse / nodeclipse it's resloved. i set nls_lang variable, 'original value'.utf8 , works. this master of node-oracledb. thanks. from version 1.0, node-oracledb sets "client" character encoding oracle's al32utf8 value. see https://github.com/oracle/node-oracledb/blob/master/changelog.md

batch file - creating folders based on Filename without overwriting -

working on script whereby staff scans in students exams certificates via photocopier , places copy location the script below following 1) scans c:\users\location filename.pdf (the staff member manually enter student number @ photocopier , save file name that) 2) script creates folder based on filename here create folder called /filename 3) moves pdf folder it works fine trying modify not overwrite so if example staff member makes typo of student1 , student1 exists dont want override it any suggestions script below can test it code: @echo off pushd c:\users\location %%f in (*.pdf) ( 2>nul md "%%~nf" >nul move /y "%%~nf*.*" "%%~nf" ) popd you cannot overwrite folder md suppose talking move operation: @echo off pushd c:\users\location %%f in (*.pdf) ( 2>nul md "%%~nf" echo n|move /-y "%%~nf*.*" "%%~nf" >nul 2>nul ) popd or (might depend on local settings , expected inp...

java - Why can't I access APIs deployed in a newly created Jetty base directory? -

i using jetty server apps. have web app, , when deploy in ${jetty_home}/webapps , works fine: can access apis have created locally , remotely. but when create new jetty base directory, , deploy web app there, cannot access these apis , 404 error. any idea things might have done incorrectly? new in web development, appreciated. update: these steps did when created new jetty base directory: mkdir /opt/web cd /opt/web java -jar $jetty_home/start.jar --add-to-start=http,deploy then placed war file in /opt/web/webapps . new jetty base directory, started server with java -jar $jetty_home/start.jar jetty.port=8000 this log when server started. warning: property jetty.port in <command-line> set in /opt/web/start.ini 2015-05-14 12:11:49.973:info::main: logging initialized @659ms 2015-05-14 12:11:50.278:info:oejs.server:main: jetty-9.2.10.v20150310 2015-05-14 12:11:50.310:info:oejdp.scanningappprovider:main: deployment monitor [file:/opt/web/webapps/] @ interval 1 201...

javascript - How do I pass a parameter to express.js Router? -

here's modified example express.js's routing guide : var express = require('express'); var router = express.router(); router.get('/', function(req, res) { res.send('birds home page'); }); router.get('/about', function(req, res) { res.send('about birds'); }); ... app.use('/birds', router); app.use('/fish', router); this prints "about birds" when visit both /birds/about , /fish/about . how pass parameter or router so, in controller functions, can tell 2 different routes apart? for example, i'd see "birds can fly" when visiting /birds/about , "fish can swim" when visiting /fish/about . ideally, i'd able pass "configuration object" mini-app not need know possible routes may mounted @ (in pseudocode): router.get('/about', function(req, res) { res.send(magic_configuration.about_text); }); .... magically_set_config(router, {about_...

javascript - Google Charts with 3 columns -

i want create google chart has 3 columns. want add 2 sets data it. please refer js code understanding. also can check https://jsfiddle.net/dt6syt2w/2/ i'm looking forward getting solution user : asgallant google.load('visualization', '1', {packages: ['corechart', 'line']}); google.setonloadcallback(drawtrendlines); function drawtrendlines() { var data1 = new google.visualization.datatable(); data1.addcolumn('number', 'x'); data1.addcolumn('number', 'normal value 1'); data1.addcolumn('number', 'peak value 1'); data1.addrows([ [0, 0, 0], [1, 10, 15], [2, 23, 25], [3, 17, 26], [4, 18, 30], [5, 9, 20], [6, 11, 25], [7, 27, 30] ]); var data2 = new google.visualization.datatable(); data2.addcolumn('number', 'x'); data2.addcolumn('number', 'normal value 2'); data2.addcolumn('number...

android - MP3 decoding failed using mediacodec without mediaextractor -

i trying decode mp3 in android using omx.google.mp3.decoder , play using audiotrack gets failed returning i/omxclient( 3506): using client-side omx mux. i/sw ( 3506): codec ==== codec name:omx.google.mp3.decoder i/sw ( 3506): type supported codec:audio/mpeg i/sw ( 3506): encoder:false e/omxnodeinstance( 3506): omx_getextensionindex failed i/swaudioplayer( 3506): decoder ready: true e/softmp3 ( 3506): mp3 decoder returned error 2 e/acodec ( 3506): [omx.google.mp3.decoder] error(0x80001001) e/mediacodec( 3506): codec reported error. (omx error 0x80001001, internalerror -2147483648) e/swaudioplayer( 3506): exception in audio play java.lang.illegalstateexception here decoder setup code (tried using playbufsize 4kb 64kb no luck in decoding mp3) private static mediacodecinfo getcodecinfo(string mimetype) { string info = ""; int numcodecs = mediacodeclist.getcodeccount(); (int = 0; < numcodecs; i++) { mediacodecinfo codecinfo = med...

c++ - How do I switch between local and global settings for the initial state of a C++11 RNG? -

in code given below, implement flag (or equally simple) has same effect commenting out local setting , using global setting times (yielding 2 different numbers in example), , using local setting @ other times (yielding 2 identical numbers in example). i have tried obvious "if" , "switch" structures without success. #include <iostream> #include <random> void print(); std::seed_seq seed{1, 2, 3, 4, 5}; std::mt19937 rng(seed); // *global* initial state std::uniform_real_distribution<> rand01(0, 1); int main() { print(); print(); return 0; } void print() { std::mt19937 rng(seed); // *local* initial state std::cout << rand01(rng) << std::endl; } use ternary , reference : std::mt19937& ref = flag ? rng : local; here, flag condition test, rng "global" random object, , local more localised one. binding reference result of ternary syntactically valid: can't using if sta...

ios - How to solve linker command failed with exit code 1 -

i getting below error when running in xcode 6.3. how solve error ld: entry point (start) undefined. in crt1.o architecture armv7 clang: error: linker command failed exit code 1 (use -v see invocation) check whether have stetted initial uiviewcontroller . if not select uiviewcontroller , set initial uiviewcontroller r.

jquery - php ajax upload not working -

i want upload image using php , ajax jquery, got problem, first if on submit #uploadimage form, form process action not ajax whatever remove action.second if button change type button , javascript function .submit on click function ajax called $_files not set because image not save , there nothing output message the view <form id="uploadimage" action="http://localhost/pkh/mod/page/tpl/ajax_php_file.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" id="file" required /> <input type="submit" value="upload" class="submit" /> </form> the js <script type="text/javascript"> $(document).ready(function (e) { $("#uploadimage").submit(function(e) { e.preventdefault(); $("#message").empty(); $('#loading').show(); $....

debugging - Trace a module line by line? -

i'm trying use windbg trace program (only 1 module in it), , log line numbers executed. automate process later, wish walk through code line line. i'm trying see if can use automated debugger calculate code coverage of automation. i have correct symbols. how do this? debuggers have capability execute code line line. i've tried using l+t , l+o , l+s , p , pr . i've enabled source mode ( l+t ), not see source code in command window, , neither see source window. you need add symbol , src path windbg, not able resolve normally. you can either add paths using gui: 'file>symbol file path...' , 'file>source file path...' using gui or ctrl+s , ctrl+p respectively. alternatively can using commands .srcpath , .sympath

sbt - Dependent task runs only when main task called directly -

so, have sbt project, 2 custom tasks jooq:codegen , flyway:migrate [ https://github.com/sean8223/jooq-sbt-plugin , https://github.com/sean8223/flyway-sbt-plugin ] not relevant here, flyway:migrate task creates schema in database, , jooq:codegen generates code schema. hence, imperative flyway:migrate runs before jooq:codegen . so, added following line in build.sbt (codegen in jooq) <<= (codegen in jooq) dependson (migrate in flyway) also, compile needs generated code jooq:codegen , plugin takes care of default. here weird part. when run sbt compile , get: ~/n/p/d/davion git:data-access ❯❯❯ sbt compile [info] loading project definition /users/rohan/nomadly/projects/davion-projects/davion/project [info] set current project davion (in build file:/users/rohan/nomadly/projects/davion-projects/davion/) [info] done updating. [info] initialising properties : /jooq-config4460313300896426081.xml ... output truncated ... [info] table records generated : total: 669.172m...

html - CSS confusion. Exactly similar tag, exactly similar CSS, but not working properly -

i have javascript appends html div there if loop, , appends divs similar data, difference in class name. either tag gets appended: <div class="customer" id="0"><h2>lorem ipsum</h2><h3>testing</h3></div> or appended: <div class="vehicle" id="0"><h2>lorem ipsum</h2><h3>testing</h3></div> the css is: for customer classed div: #results .customer{ height: 60px; padding-top: 18px; margin: 10px 0px; border-bottom: 20px solid black; } #results .customer h2{ font-size: 2.5em; } #results .customer h3{ width: 90%; text-align: right; float: right; font-size: 1.5em; margin-top: 15px; margin-right: 15px; } for vehicles classed div: #results .vehicle{ height: 60px; padding-top: 18px; margin: 10px 0px; border-bottom: 20px solid black; } #results .vehicle h2{ font-size: 2.5em; } #results .vehicle h3{ wid...

mysql - Undefined index $_Request php -

this question has answer here: php: “notice: undefined variable”, “notice: undefined index”, , “notice: undefined offset” 23 answers i seem having problem updating database because of undefined index. flow of program when user tries update existing record, redirect updateuser.php?id=$rw[id] after filing in form , pressing ok button error occurs notice: undefined index: id in updateuser.php on line 14 here's updateuser.php file(the part occurs). $id=$_request['id']; //line 14 if(isset($_post['btnadd'])){ $col1=$_post['uname']; $col2=$_post['pass']; $col3=$_post['fullname']; $col4=$_post['user_type']; include("dbcon.php"); $adduser = mysql_query("update users set user_id = '$col1', pass='$col2', fullname='$col3', user_type='$col4' id='$id'") or die(m...

scala - Why does the compiler complain when using the abstract modifier in a trait in two cases? -

i practicing chapter trait in online book programming in scala 1ed. http://www.artima.com/pins1ed/traits.html there 2 examples show power of traits, enrich thin interface , stackable modification. here snippet of implementation // example 1 trait relation[t] { def compare(that: t): int def <(that: t) = compare(that) < 0 def >(that: t) = compare(that) > 0 def <=(that: t) = compare(that) <= 0 def >=(that: t) = compare(that) >= 0 } // example 2 trait doubling extends intqueue { abstract override def put(a: int) { super.put(a*2) } } the above code fine compile. i curious existence of abstract modifier, first added abstract modifier in front of relation::compare() in example 1. maybe it's reasonable mark abstract compare going override subclass. // case 1 abstract def compare(that: t): int then compiler complains error:(19, 16) `abstract' modifier can used classes; should omitted abstract members abstract def compa...

android - Fragment getting overlapped in ViewPager -

i getting overlapped fragments in pageviewer of android . pfb layout pageviewer <tabhost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="900dp" android:layout_alignparentbottom="true" > <relativelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <framelayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@android:id/tabs" > <android.support.v4.view.viewpager android:id="@+id/viewpager" android:layout_width="fill_parent" android:layout_height="wrap_content" > </an...

mysql - Optimization of INSERT Query in SQL -

i investigating on comparing effectiveness of 2 ways of insert data in sql know executes faster the first 1 is insert mytb(id, name) select 0, 'uyen' union select 1, 'uyen' union .... select 1000, 'uyen' and second 1 is: insert mytb(id, name) values (0,'uyen'); insert mytb(id, name) values (1,'uyen'); .... insert mytb(id, name) values (1000,'uyen'); i have tried executing 1000 rows. runs faster , other runs faster (i think because resources of system different in every execution or other issues). did search around internet without success. please me give answer , explain reasons. want know optimization queries. thanks

Can not send email by Mailer Rails -

Image
i have tried configure tutorials still can not send email. @ console, displays image below: i have configured in config file \ environments \ development.rb , production.rb follows: config.active_record.dump_schema_after_migration = false config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, domain: 'gmail.com', user_name: 'gmail username', password: 'password', authentication: 'plain', enable_starttls_auto: true } app\mailers\user_mailer.rb: class usermailer < applicationmailer def registration_confirmation(user) mail(:to => user.email,:subject => "registered") end end app\mailers\application_mailer.rb class applicationmailer < actionmailer::base default from: "testoneb...

c# - Python global variable referenced before assigned a value -

i started program in python, , love far. programmed in c# , java, causing problem. in c#, if have public variable, change in each method. sorry bad explanation, easier visualize code. this code example of want happen in python in c# form. code not work because it's example. class player { public var player; //create variable public var playerrectangle; public var playermovement; public player() { player = pygame.image.load("player.png"); //set variables value playerrectangle = player.get_rect(); playermovement = new int[0,0]; } public void update() { event in pygame.event.get(): if event.type == pygame.keydown , event.key == pygame.k_w: playermovement[1] = -2 //use variables value if event.type == pygame.keydown , event.key == pygame.k_s: playermovement[1] = 2 if event.type == pygame.keydown , event.key == pygame.k_a: ...

objective c - ios, ipad , MBProgressHUD works fine iphone, but not working properly in ipad -

i using mbprogresshud in ipad, works fine, , not works fine(user interaction not disable mbprogresshud working). on other hand works fine in iphone (all time). my code : -(void)performheavytask { [mbprogresshud showhudaddedto:self.view animated:yes]; [[flrtalertcontroller sharedinstance]setfriendsdatadelegate:self]; [[flrtalertcontroller sharedinstance] performselectorinbackground:@selector(getdatafirsttime) withobject:nil]; } you should use latest version of (v 0.9.1) guide install project in link https://github.com/jdg/mbprogresshud/blob/master/readme.mdown and should add mbprogresshud view of navigationcontroller or view of top controller in stack. see sample project in mbprogresshud

r - Used Predict function on New Dataset with different Columns -

using "stackloss" data in r, created regression model seen below: stackloss.lm = lm(stack.loss ~ air.flow + water.temp + acid.conc.,data=stackloss) stackloss.lm newdata = data.frame(air.flow=stackloss$air.flow, water.temp= stackloss$water.temp, acid.conc.=stackloss$acid.conc.) suppose new data set , need predict "stack.loss" based on previous model seen below: #suppose need used model on new set of data stackloss$predict1[-1] <- predict(stackloss.lm, newdata) i error: error in `$<-.data.frame`(`*tmp*`, "predict1", value = numeric(0)) : replacement has 0 rows, data has 21 is way used predict function on different data set same columns different rows? thanks in advance. you can predict new data set of whatever length want, need make sure assign results existing vector of appropriate size. this line causes problem because stackloss$predict1[-1] <- predict(stackloss.lm, newdata) because can't assign , sub...

android - WifiManager and ConnectivityManager support in Arc Welder -

i using welder run application apk , looks fine @ beginning realized features wifimanager , connectivitymanager doesn't work correctly. for example, below function return true regardless of running system of welder's actual connection status , network status change broadcast not kicked in. guarantee app work correctly, need have these kind of functionalities. are these known issue going fixed ? comment welcomed. public static boolean isnetworkconnected() { connectivitymanager mngr = (connectivitymanager) inrestowaitapplication.getinstance() .getsystemservice(context.connectivity_service); networkinfo info = mngr.getactivenetworkinfo(); if (info == null || !mngr.getactivenetworkinfo().isconnected()) return false; return true; } public static boolean iswifienabled() { wifimanager wfmgr = (wifimanager)inrestowaitapplication.getinstance().getsystemservice(context.wifi_service); return wfmgr.iswifienabled(); } ...

parsing - Processing input before giving input to parser -

what kind of processing should done input given parser. as of know using stanford parser.jar there stanford corenlp.jar difference between parser.jar , corenlp.jar parsing method as per corenlp documentation can pass operation want input in annotators command: java -cp "*" -xmx2g edu.stanford.nlp.pipeline.stanfordcorenlp -annotators tokenize,ssplit,pos,lemma,ner,parse,dcoref -file input.txt to use parsing in corenlp can pass parse or should pass annotators except dcoref i.e.) java -cp "*" -xmx2g edu.stanford.nlp.pipeline.stanfordcorenlp -annotators tokenize,ssplit,parse -file input.txt or java -cp "*" -xmx2g edu.stanford.nlp.pipeline.stanfordcorenlp -annotators tokenize,ssplit,pos,lemma,ner,parse,dcoref -file input.txt does parser.jar has sentence splitting in built in it's jar can give paragraph input , sentence , parsed data out or should give 1 sentence @ time thank you, the c...

python - Pygame - Making a Sprite "walk" in the right direction -

i continuing work using pygame. working on enemy class. basically, walk 1 side another. can walk between set boundaries, cannot image display proper direction enemy facing. if can please me out or give me advice, i'd appreciate it. thank you. i believe issue update() function. here enemy class class enemies(pygame.sprite.sprite): enemy_moving_frames_r = [] enemy_moving_frames_l = [] change_x = 0 change_y = 0 boundary_top = 0 boundary_bottom = 0 boundary_left = 0 boundary_right = 0 level = none player = none def __init__(self): pygame.sprite.sprite.__init__(self) sprite_sheet = spritesheet("stuff/skeleton_7.png") image = sprite_sheet.get_image(7, 7, 28, 64) self.enemy_moving_frames_r.append(image) image = sprite_sheet.get_image(37, 7, 33, 64) self.enemy_moving_frames_r.append(image) image = sprite_sheet.get_image(70, 7, 33, 64) self.enemy_moving_frames_r.append(image) image ...

Meteor HTTP.GET get gzipped json back how to decompress? -

var url = "https://www.parsehub.com/api/v2/projects/{project_token}/last_ready_run/data"; var api_key = 'te79widrkomn_fxs2e_knnx5'; url = url.replace('{project_token}', 'tbnbvhg208xhgupecak62v80'); console.log('start fetching remote results ' + url); this.unblock(); http.get(url, {params: {api_key: api_key}}, function(error, result) { if(error) { console.log('http failed!'); } else { console.log('http success'); if (result.statuscode === 200) { console.log('status code = 200!'); console.log(result.content); } } }); the result.content here gzipped, how unzip it? tried gb96:zlib not make work. there hidden flag while using http...

ruby - How to get the index of 'th' element using Nokogiri -

i have following html code , need determine index of "number of strings" using <span> id. i'm using nokogiri parse html , row. doc = nokogiri::parse(myfile.html) table = doc.xpath("//span[@id='numstrs']/../../..") row = table.xpath["tr[1]"] here html: <tr> <th id ="langframe"> <span id="cabinet"> cabinet</span> </th> <th id ="langbb1"> <span id="bb1"> bb1</span> </th> <th id ="langbb2"> <span id="bb2"> bb2</span> </th> <th id ="langtemp"> <span id="temp"> temperature</span> </th> <th id="langstrs"> <span id="stringspresent"> strings present</span> </th> <th id="langmstrqty"> <span id="numstrs"> number of strings</span> </th> </tr> got working, not ...

php - CodeIgniter "like()" function with % wildcard inside search terms -

let's have function this: public function get_list($category = '', $limit = 10, $offset = 0) { if (!empty($category)) $this->db->where('category', $category); $search = $this->input->get('search'); if (!empty($search)) $this->db->or_like(array('foo_column'=>$search)); $query = $this->db->get('table_name', $limit, $offset); //echo $this->db->last_query(); return $query->result(); } produce query : select * table_name foo_column '%match something%' as can see % wildcard can added in both side, before , after . and how if want produce like: ... foo_column '%match%something%'? fyi, use str_replace() function change space % codeigniter escape slash . produces query like: ... foo_column '%match\%something%' this useful when search match something keyword match something , , wildcard on...

c# - How to insert Data into sql server database -

i'm trying insert data sql server 2014 database, error incorrect syntax near ')'. my table matches types of data put in, example, i'm put int int . here code: string ip = request.userhostaddress; string name = "jesus said: love enemies (v.s.)"; int blueq = convert.toint32(textbox1.text); int redq = convert.toint32(textbox2.text); int whiteq = convert.toint32(textbox3.text); int blackq = convert.toint32(textbox4.text); int whiteqr = convert.toint32(textbox9.text); int redqr = convert.toint32(textbox10.text); int sn = 600; int price = total_jslye; string size; if (radiobutton1.checked == false) { size = "11x35"; } else size = "18x50"; try { string conn = system.configuration.configurationmanager.connectionstrings["sqlcs"].connectionstring; var cmd = "insert cartsigns (@signnumber, @redquantity, @bluequantity, @whitequantity, @blackquantity, @whitereflectivequantity, @redreflectivequantit...

MongoDB update queries slow after PHP driver update -

since updating our mongo php drivers 1.4.1 1.6.6 update , insert queries have become approximately 5x slower. there's been no change mongodb server, on 2.6.4 has else experienced this, known issue later drivers in php? we're running rhel 6.4, php 5.4 according http://docs.mongodb.org/ecosystem/drivers/php/ should 100% compatible , supported

html - Textbox hover background image moves and re-sizes -

Image
i have attempted put in background image on kendo ui textbox . it's when don't hover on it. but hover on it, happens: how fix this? when hover , click textbox , image needs stay @ same place. here html adding textbox: @html.kendo().textboxfor(vm => vm.username) here css adding background in: #username.k-textbox{ background-image:url(/images/user_icon.svg); } input.k-textbox{ background-size:19px; background-repeat:no-repeat; background-position:12px 50%; outline: none; display: inline-block; } solved own problem. needed override hover setting textbox css . here additional code added: input.k-textbox:hover{ background-size:19px; background-repeat:no-repeat; background-position:12px 50%; }

python - Django can't flush database during tests -

when trying run tests (python manage.py test) getting: commanderror: database test_db couldn't flushed. possible reasons: * database isn't running or isn't configured correctly. * @ least 1 of expected database tables doesn't exist. * sql invalid. hint: @ output of 'django-admin.py sqlflush'. that's sql command wasn't able run. full error: cannot truncate table referenced in foreign key constraint detail: table "install_location_2015_05_13" references "app". hint: truncate table "install_location_2015_05_13" @ same time, or use truncate ... cascade. i using partitions in our project generated on fly via python function (so can run periodically). don't have models these partitions. the partition maintenance function invoked after syncdb triggers post_syncdb signal (so executed when test database set up). how can make django clear additional tables (partitions)? or how can tell django use cascade whi...

core bluetooth - ios corebluetooth reconnect device after close app without call cancelPeripheralConnection -

the follow: open app scan device -> paring -> connecting -> write setting information. it's successful. double tap on home button , remove app. i see in bluetooth menu in setting app device still connecting. if turn device off turn on, setting app connect device. seems setting app try re-connect paired device. open app again, retrieve peripherals: [centralmanager retrieveconnectedperipheralswithservices:servicesuuid]; result: cbperipheral: 0x14d741b0, identifier = 3e0a0fe9-33db-d2fc-90ce-b73ab64045db, name = time app, state = disconnected connect retrieved peripheral, system didn't trigger callback: didfailtoconnectperipheral or didconnectperipheral . i try use preservation , restoration, uiapplicationlaunchoptionsbluetoothcentralskey return null . so, how connect device after closing app without call cancelperipheralconnection ? @ time, must go setting app , forget device connect again. thanks all. make sure calling [centralmanage...

fft - Matlab: finding phase difference using cpsd -

from understanding, when using cpsd function such: [pxy,f] = cpsd(x,y,window,ns,nfft,fs); matlab chops time series data smaller windows size specified you. , windows shifted ns data point. final [pxy, f] average of results obtained each individual window. please correct me if wrong process. my question is, if use angle(pxy) @ specific frequency, 34hz. give me phase difference between signal x , y @ frequency 34hz? i having doubt because if pxy average between each individual window, , because each individual offset window shift, doesn't mean averaged pxy 's phase affected window shift? i've tried correct ensuring window shift corresponds integer of full phase difference corresponding 34hz. correct? and little background doing: i have numerous time-series pressure measurement on 60 seconds @ 1000hz sampling rate. power spectrum analysis indicates there peak frequency @ 34 hz each signal. (averaged on windows) i want compare each signal's phase ...

php - Grocery CRUD always showing No items to display but shows total number grid footer -

Image
i have problem, using grocery crud , when list data, shows no items display shows total number of records in table controller class manage_home extends ci_controller { public function __construct() { parent::__construct(); $this->load->database(); $this->load->helper('url'); $this->load->library('grocery_crud'); } public function all_intro() { // echo "all well"; $crud = new grocery_crud(); $crud->set_table('tbl_home_information'); $crud->columns('pk_information_id','information_title','information_status','information_added'); $crud->fields('pk_information_id','information_title','information_status','information_added'); $crud->display_as('pk_information_id','id'); $crud->display_as('information_title','title'); $crud->display_as('information_added...

python - Date parsing and timezone adjusting in pandas dataframes -

i have 800,000 rows of data in dataframe, , 1 column of data df['date'] string of time , date 'yyyy-mm-dd hh:mm:ss.fff' , doesn't have timezone information. know in new_york timezone , need convert cet. have 2 methods job done: method 1 (very slow sure): df['date'].apply(lambda x: timezone('america/new_york')\ .localize(datetime.datetime.strptime(x,'%y%m%d%h:%m:%s.%f'))\ .astimezone(timezone('cet'))) method 2 : df.index = pd.to_datetime(df['date'],format='%y%m%d%h:%m:%s.%f') df.index.tz_localize('america/new_york').tz_convert('cet') i wondering if there other better ways it? or potential pitfalls of methods listed? thanks! also, shift timestamp fix amount of time, such 1ms timedelta(0,0,1000) , how can implement using method 2? method 2 definately best way of doing this. however, occurs me formatting date after have loaded data. it faster parse dates ...

How to find running/stop service in my SQL Server Configuration? -

Image
i have installed sql server 2012 on system. when tried access sql server configuration, couldn't see sql service running on system. how ensure it's running? i bet installed sql tools, not engine itself. search file "sqlservr.exe" on local machine. standard/default installation put somewhere in %programfiles% folder (ie c:\program files\microsoft sql server\mssql.1....). if file not exist on local machine, engine feature not checked/included, or install failed, @ should @ setup log files.

git - .gitignore exclude specific file -

i trying use .gitignore file exclude templates.js located in public/app/ folder. .gitignore file looks this: /vendor /node_modules composer.phar composer.lock .ds_store templates.js but when check in git gui, templates.js file still show in it. how can exclude file using .gitignore ? in contrast name "ignore" might suggest. .gitignore consulted when git add files: in other words file added (index of the) repository not excluded based on .gitignore . first better modify .gitignore such file no longer added. add following line .gitignore file: public/app/template.js next need exclude file repository. don't want remove file file system, can done with: git rm --cached public/app/template.js the --cached flag ensures file not removed file system. (if not important, can use git rm public/app/template.js , but remove file ). background the reason .gitignore not proactively used because might want override .gitignore . instance don't...

How to animate & control Android PreferenceFragment screens? -

i have preferencefragment contents defined in xml. these contents include child preferencescreen . when click on preferencescreen , new screen rendered successfully, has no animation (it shows on screen, before material ripple finished on lollipop devices). even worse, if had complex layout going on (for example, preferencefragment in tab on 1 side of screen) layout blown away , replaced full-screen fragment. i suspect if find callback or event occurs when preferencescreen clicked, can solve both problems, don't know start. i did slide in right-to-left animation of preferencefragment... extended preferencefragment , overridden oncreateview() this: @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = super.oncreateview(inflater, container, savedinstancestate); animrelativelayout animrelativelayout = new animrelativelayout(getactivity()); relativelayout.layoutparams layoutparams =...

How to write repeating Regex pattern in JavaScript -

how write regex following pattern in javascript: 1|dc35_custom|3;od;czy;gl|2;ob;bnp;mt|4;sd;abc;mt|5;ih;dft;fr|6;oh;aqw;mt|7;ip;can;mt|8;op;car;mt|9;ec;smo;gl|10;do;czt;ku| where the first part 1|dc35_custom| fixed. the second part onwards, pattern repeats 9 times(i.e. 3;od;czy;gl| 2;ob;bnp;mt| , on. the 1st character in ranges 2-11 , should not repeat. example 3 appears in first pattern, should not appear again. i'm making lot of assumptions this, here's crack @ it: 1\|dc35_custom\|(([2-9]|10|11);[a-z]{2};[a-z]{3};[a-z]{2}\|){9} how works 1\|dc35_custom\| literal text, escaping vertical bar operators ([2-9]|10|11) match number 2 11. [a-z]{2} match 2 lowercase letters [a-z]{3} match 3 uppercase letters [a-z]{2} match 2 uppercase letters {9} looks 9 consecutive matches of entire sequence enclosed in parentheses it not, amadan points out, check uniqueness, because that's bit beyond regex for.

Fixed y axis in Python plotting times in 12 hr format -

Image
i have plot need y axis fixed 00:00, 01:00, 02:00, etc way 12:00. of it's plotting values have in csv on y axis. csv in following format. how o y axis constant , show 00:00 12:00 in 1 hr increments , still have data plotted correctly? ml int 0.1 534.15 0:00 ml ext 0.25 654.23 3:00 ml int 0.35 743.12 6:30 and following code have far. import pandas pd import matplotlib.pyplot plt import numpy np data = pd.read_csv('data.csv', header=none) ints = data[data[1]=='int'] exts = data[data[1]=='ext'] int_index = data[data[1]=='int'].index ext_index = data[data[1]=='ext'].index time = [t t in data[4]] int_dist = [d d in ints[3]] ext_dist = [d d in exts[3]] fig, ax = plt.subplots() ax.scatter(int_dist, int_index, c='orange', s=150) ax.scatter(ext_dist, ext_index, c='black', s=150) ax.set_yticks(np.arange(len(data[4]))) ax.set_yticklab...

parallel processing - How to use a M-.file in a parfor loop in Matlab? -

my code inside parfor loop getting longer , longer , split up. having parts of code saved in different script files seems logical , attractive , since doesn't change except code saved seems should work. doesn't. i usual " transparency violation error ". the problem seems typical did not find question asked or answered anywhere. below small working example . (yes, made function. in case of many more input , output variables becomes ugly imo , slower due communicating arguments) c = nan(10,1); %result vector parfor loop = 1:10 = 1; b = 2; mfile_test %run m-file contains 1 line: % c = + b; c(loop)=c; end the mfile_test script containing line 1 line c = + b. i beginning understand why parallel computing has issue here not how solve it. since possible without problem if had line c = + b inside parfor file cannot belief there no simple way solve (e.g. in worst case tell matlab load text file , run code here , now). if there alter...