Posts

Showing posts from January, 2013

python - How to properly run two while loops in asyncio code with executor pools? -

i have 2 functions want run concurrently. heartbeat function, executes simple while loop. , function meat of script, that's in while loop. while heartbeat functions marches along, meat , potatoes function ruins once , never loops... i'm using asyncio , executor pools accomplish goals of having 2 functions (loops) running simulutaneously. also how errors/exception show while using executor pools, cant see errors.... here's code: import lib.myfunctions import asyncio import oandapy fmc = lib.myfunctions.fmcmixin() def meatandpotatoes(currency_pair=sys.argv[1], time_compression=sys.argv[2],sleep_time=sys.argv[3]): while true: try: = oanda.get_history() if (something): print("niceeee") else: print("ok cool") except: sleep(sleep_time) if __name__ == "__main__": executor = proce

osx - Using "~" with a POSIX path in AppleScript -

how can use ~ in following applescript? info posix path of "users/[user]/pictures" the script should universal, if replace users/[user] ~ , script looks that info posix path of "~/pictures" i'm getting error directory not available. i'm thankful help. there no need use tilde ( ~ ) in applescript, shortcut current user's home folder in shell. there many relative paths in applescript path desktop is alias specifier desktop folder of current user, equivalent alias "[startup volume]:users:[current user]:desktop" the relative path pictures folder is path pictures folder other paths path music folder path applications folder path home folder etc. please dictionary of standard additions further paths for relative paths there parameter specify domain path library folder user domain -- alias "[startup volume]:users:[current user]:libary" path library folder local domain -- alias "[startu

cloudfoundry - Unable to Login to VMware vCenter server through Cloud Foundry -

i have installed cloud foundry in windows 7 machine.i trying login vmware vcenter server through cloud foundry cli giving api endpoint ip address of vcenter server.i getting "server error, status code: 404, error code: 0, message:". able ping vcenter server , make api calls through rest client. c:\ cf login c:\ api endpoint> http://xx.xx.xx.xx invalid ssl cert xx.xx.xx.xx tip: use 'cf login --skip-ssl-validation' continue insecure api endpoint c:\ cf login --skip-ssl-validation -a http://xx.xx.xx.xx c:\ api endpoint: https://xx.xx.xx.xx failed server error, status code: 404, error code: 0, message: cloud foundry version : 6.12.1 please me in debugging error the api endpoint has following structure: https://api.my_ip.xip.io

hook - Prestashop 1.6: Place "User Info Block" module (User Login block) next to the "Cart Block" -

i'm using default theme in prestashop 1.6. there way move "user info block" module (user loging/logout) "dislaynav" hook "displaytop" hook above main menu , between quick search , cart block. module hooked in position reason doesn't show after unhooked initial position "displaynav" hook ! uninstall , reinstall user info block module transplant displaytop.

r - As.XTS from Matrix - Error - Adds time and timezone info -

for reason not understand, when run as.xts convert matrix date in rownames, operation generate date time in end. since different start indexes merge/cbinds not work. can point me doing wrong? > class(x) [1] "xts" "zoo" > head(x) xly.adjusted xlp.adjusted xle.adjusted agg.adjusted ivv.adjusted 2005-07-31 0.042255791 0.017219585 0.17841600 0.010806168 0.04960026 2005-08-31 0.034117087 0.009951766 0.18476766 0.015245222 0.03825968 2005-09-30 -0.029594066 0.008697349 0.22851906 0.009769765 0.02944754 2005-10-31 -0.015653740 0.019966664 0.09314327 -0.012705172 0.01640395 2005-11-30 -0.005593003 0.005932542 0.05437377 -0.005209811 0.03173972 2005-12-31 0.005084193 0.021293537 0.05672958 0.002592639 0.04045477 > head(index(x)) [1] "2005-07-31" "2005-08-31" "2005-09-30" "2005-10-31" "2005-11-30" "2005-12-31" > temp=t(apply(-x, 1, rank, na.last = &quo

javascript - In jquery when you type letter middle of word goes last -

i have 2 inputs when type upper 1 writes bottom 1 same time. have letter i , different letter ı in english have same capital letter i wrote following code address this: $(".buyuk").on("keypress", function(event) { event.preventdefault(); if (event.which == 105) $(this).val($(this).val() + "İ"); else $(this).val($(this).val() + string.fromcharcode(event.which).touppercase()); }); after write word when want edit word middle adds letter end. example, typed moitor when though expected output monitor , became moitorn instead. try this: $(".buyuk").on("keypress", function(event) { event.preventdefault(); var char = string.fromcharcode(event.which).touppercase(); if (event.which == 105) char = "İ"; var og = $(this).val(); var selection = this.selectionstart; $(this).val(og.substr(0, selection) + char + og.substr(this.selectionend, og.length)); this.s

html - PHP data to plot -

Image
i have 2 arrays representing x , y values don't seem in right format. want convert this: into this: the code used first 1 is: $dataset2[] = array(floatval($row["x"]),intval($row["y"])); and second 1 is: $dataset2[] = array(($x),($y)); in second case have x , y arrays of numbers , in first case mode of obtaining them bit different, , nope, unfortunately can't values in first case in second one. to convert use: var dataset1 = <?php echo json_encode($dataset2); ?>; in both cases. thanks! try .. var = floatval($row["x"]); var b = intval($row["y"]); for(var = 0; < a.length; i++){ $dataset2[] = array(a[i],b[i]); }

windows - What is the Programdata/Application Data folder? -

so writing application iterates through specified directory tree , experimenting exception handles permissions folder access , there 1 folder came across compiler returned had directory of c:\programdata\application data does know folder is? doesn't seem exist within windows explorer. like, folder isn't there. it's not hidden. isn't there. able inside folder using elevated command prompt when used "dir" command see folder contained, cmd returned: "directory of c:\programdata\application data file not found" i curious know folder is..... the dir /a command friend here: c:\programdata>dir /a volume in drive c has no label. volume serial number 848a-bbb7 directory of c:\programdata 23/05/2015 03:38 pm <dir> . 23/05/2015 03:38 pm <dir> .. 14/05/2015 10:28 pm <junction> application data [c:\programdata] as can see, application data junction point points programdata. win

python 3.x - Two sensors, Is it possible to pause a sensor for a short time? -

i have code saving data online. have 2 ir sensors reading door, 1 6 inches other. if first sensor goes off before second, know entering room, , code sends +1 file online. when second sensor triggered first, means leaving, system should pause , nothing should happen until person moves out of both sensors. last part isnt happening. how can pause first sensor when leaving, not accidentally double count? code: #!/usr/bin/python3.4 ubidots import apiclient import rpi.gpio gpio import time import datetime import os import web person_count = 0 ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%m-%d-%y %i:%m:%s') gpio.setmode(gpio.bcm) gpio.setup(4, gpio.in) #ir sensor closest door gpio.setup(25, gpio.in) #ir sensor farthest door gpio.setup(17, gpio.out) #led indicate when data being recorded web. api = apiclient("165c54954ee6d8f7324366495cab70217c7c3c91") test_variable = api.get_variable("559c18cc76254214be90fe05") while t

javascript - Changing bootstrap navbar based on template -

so, want have same default bootstrap navbar on every page on website. if change name of 1 page (eg: page 1), want have changed across pages. understand, can use jquery load header separately. however, doesn't seem pull "active" class page active. how have "active" class on page active. fyi, i'm using angularjs framework. <!doctype html> <html lang="en"> <head> <title>bootstrap case</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </head> <bo

ggplot2 - R: Extract scale name from ggplot object -

i wondering how extract scale name (i.e., legend name) ggplot object in general way possible. general, mean extracts same thing no matter how changed scale name, whether using name within scale function or using labs . for instance: library("ggplot2") set.seed(3489243) rho <- round(rnorm(25, 0, 5)) profit <- 0.5 + 0.3 * rho + rnorm(25, 0, 1) betaadjusted <- factor(c(rep(true, 15), rep(false, 10))) returns.both <- data.frame(rho, profit, betaadjusted) p1 <- ggplot(aes(x=rho, y=profit, shape = betaadjusted), data=returns.both) + geom_point() + scale_shape_discrete(name = "is beta adjusted?") p2 <- ggplot(aes(x=rho, y=profit, shape = betaadjusted), data=returns.both) + geom_point() + labs(shape = "is beta adjusted?") i want extract text is beta adjusted p1 , p2 using same code. possible? using labs(p2) gives me text under labels list using labs(p1) gives me text under scales list. don't want have @ 2 p

Wordpress - Theme options from parent theme are missing in child theme -

i'm creating child theme wordpress theme flaton. problem specific options theme doesn't show in child theme. theme uses redux option framework. so how maintain theme options parent theme, shows in child theme well? need in functions.php (that in child theme)? when having parent theme activated , pasting url: http://localhost:8080/wordpress/wp-admin/admin.php?page=_options ...then shows options. but when having child theme activated , pasting same url, i'm getting message: "you not have sufficient privileges access page". this means functions.php of child theme not calling on redux. may want alter slightly. ;)

Datetime conversion in Mysql and javascript -

i using javascript , mysql store datetime var twodigits = function (d) { if (0 <= d && d < 10) return "0" + d.tostring(); if (-10 < d && d < 0) return "-0" + (-1 * d).tostring(); return d.tostring(); }; date.prototype.tomysqlformat = function () { return this.getutcfullyear() + "-" + twodigits(1 + this.getutcmonth()) + "-" + twodigits(this.getutcdate()) + " " + twodigits(this.getutchours()) + ":" + twodigits(this.getutcminutes()) + ":" + twodigits(this.getutcseconds()); }; so when send "2015-07-11 10:00:00" stores "2015-07-11 04:30:00" in db var p = new date("2015-07-11 10:00:00").tomysqlformat (); when retrieve value db "2015-07-10t23:00:00.000z". using var x = new date("2015-07-10t23:00:00.000z"), gives me sat jul 11 2015 04:30:00 gmt+0530 (india standard

javascript - Kendo UI Angular Upload / Kendo Grid integration -

ok, here versions: kendo ui v2014.3.1119 angularjs v1.3.6 jquery v@1.8.1 jquery.com the issue following: have kendo upload should populate grid after excel file read. i'm using kendo ui angular directives. here key pieces of code: upload html <input name="files" type="file" kendo-upload k-async="{ saveurl: '{{dialogoptions.importurl}}', autoupload: false, batch: true }" k-options="{localization: {uploadselectedfiles: '{{messages.global_button_import}}'}}" k-error="onimporterror" k-select="onselect" k-success="onimportsuccess" k-multiple="false" /> grid html <div kendo-grid="grid" k-options="gridoptions" k-ng-delay="gridoptions" k-rebind="gridoptions" > </div> key pieces on controller angular.mo

locate random latitude, longitude in google map with 1 km distance -

i'm locating randomly latitude , longitude in google map . got latitude , longitude table(which consists bunch of latitude , longitude points). need select points, having 1000 m distance each , every points. is there method above.

javascript - Selenium RC - HtmlRunnerTestLoop Undefined - user-extensions.js -

i having hell of time getting selenium rc run data-driven tests correctly via batch file. scripts written via selenium ide , use features such if, while, xml , label , working fine within ide. have scoured internet trying find working user-extensions.js file, no avail. i have "somewhat" working version found on here (stackoverflow), keep getting htmlrunnertestloop undefined error. the script run through it's first iteration fine, @ end command prompt says, "command failed close cleanly. destroying forcefully" , shuts down. when try load .js file directly selenium ide, error saying htmlrunnertestloop undefined. does have working user-extensions.js file includes selblocks/flow control plugins share or point me too? or have suggestions matter?

javascript - Angular route not working -

i'm attempting setup basic routes in angular app cannot seem ngview work correctly. below relevant index.html code, module, , config: index.html: <body ng-app="myapp"> <h3>testing live</h3> <div ng-view></div> </body> app.module.js: angular.module('myapp', ['ngroute', 'ngresource']); app.config.js: angular.module('myapp') .config(function($routeprovider, $locationprovider) { $routeprovider.when('/player/:playerid', { template: '<h1>testing...</h1>', controller: 'playerinfocontroller', controlleras: 'playerinfo' } ); $locationprovider.html5mode({ enabled: true, requirebase: false, rewritelinks: false }); }); when visit /player/56 example, see 'testing live', not 'testing...' expect. instead there's <!-- ngview: --> in section. i

python - Resetting / Updating TTL for a Couchbase counter -

(this pretty simple question - 1 can answered trying out - since docs not explicit it, figured i'd document here) when set new ttl'd couchbase counter (using incr() in python, example) - , re-incr() counter another ttl value, key's ttl reset new value? here's way of asking this: if run following code: cb.incr(key='mykey',amount=1,initial=1,ttl=10) //10 seconds ttl cb.incr(key='mykey',amount=1,initial=1,ttl=100) //will update ttl? will key expire after 10 or 100 seconds? the python library docs: http://docs.couchbase.com/sdk-api/couchbase-python-client-1.2.3/api/couchbase.html no, second incr operation not update ttl. if want change ttl use touch command. note matches behaviour of original memcached protocol - see example how incr work expiry times?

scala - Play framework: empty body in post request -

helo! have following code: def foo = action { request => ok(request.body.astext.getorelse("no body")) } in frontend have form this: <form action="@controllers.routes.application.foo()" method="post"> <input name="name" type="text"> <input name="surname" type="text"> <button type="submit"> </form> if fill form , click submit, gives me result: no body. if add brakepoint in debugger ok(..), shows me, body not emty. anycontentasformurlencoded(map(name -> arraybuffer(123), surname -> arraybuffer(123))) why, doesn't give me body text, or else, , how can them? given form , debugging output, should using asformurlencoded .

excel - Paste without hitting enter -

i'm trying paste data (the .entirerow.select) new sheet ("win") without having hit enter when choosing paste data. want data pasted starting in column a, row 1 below last row entered data (lastrow defined earlier in code). advice? thanks. if archive = "win" .entirerow.select application.cutcopymode = false selection.cut sheets("win").select range("a" & lastrow + 1).select activesheet.paste i cleaned code little: if archive = "win" entirerow.cut sheets("win").range("a" & lastrow + 1).paste where running issues?

WPF (Vb.net): How to change the application icon dynamically? -

i'm working on simple application windows (if ask, windows vista+ compatible) , i'd user able change icon of application. i have 2 icons, 1 old , 1 new, , i'd user able go settings (for example) , check "use old icon" or uncheck it, , depending on chosen option icon of application - shortcut desktop icon, icon in tray bar, icon in alt+tab menu, , on - change 1 chosen. the application can make change after has been reopened (it's not important show immediatelly). is possible? or way set icon through project settings before compiling it? thanks , time! this works icon , tray tested - not guess this.icon = this.icon = new bitmapimage(new uri(@"myicon.ico", urikind.relative));

Batch File: Ping Domain & get IP and show result with text -

situation i have 2 email hosting lot of domain. ej: https://domain1.com hosted in server1 ip 1.1.1.1 https://domain2.com hosted in server2 ip 2.2.2.2 https://domain3.com hosted in server2 ip 2.2.2.2 https://domain4.com hosted in server1 ip 1.1.1.1 script function: -the user input domain. -the script yould ping domain, if domain ip 1.1.1.1 script should show (this domain hosted in "server1"). if domain 2.2.2.2 system show inform (this domain hosted in "server2"). @echo off setlocal enabledelayedexpansion set /p domain=ingrese domainname: set server1=1.1.1.1 set server2=2.2.2.2 /f "tokens=1,2 delims=[]" %%a in ('ping -n 1 !domain!') ( if "%%b" neq "" set ip=%%b ) echo ip.....%ip% if %ip% == !server1! echo server1 if %ip% == !server2! echo server2 pause problem: i don't know this: -if ip domain doesn't mach server1 or server2, said domain not mach. -also if ip domain not resol

machine learning - reducing FP rate scikit-learn random forest -

i working scikit-learn random forest classifier , want reduce fp rate increasing number of trees needed successful vote greater 50% 75%, after reading documentation not sure of how this. have suggestions. (i think there should way because according documentation predict method of classifier decides based on majority vote). appreciated, thanks! lets have classifier use 75% agreement within estimators. in case gets new sample, , odds 51%-49% in favour of 1 class, want do? the reason 50% rule used, because decision rule proposed may lead cases classifier says "i cannot predict label of these samples". what can do, wrap results of classifier, , whatever calculations wish - from sklearn.ensemble import randomforestclassifier sklearn import datasets import numpy np def my_decision_function(arr): diff = np.abs(arr[:,0]-arr[:,1]) arr [ diff < 0.5 ] = [-1,-1] # if >0.5, 1 class has more 0.75 prediction return arr x, y = datasets.make_classifica

c - Why the analyzation of code isn't right? -

why output "0 -6" , not "4 60"? isn't k=8, l=2? #define mac(a,b) (a<b ? a*b:a-b) void main (void) { int i=2; int j=4; int k=mac(i,j); int l=mac(j,i); i=mac(k+l,k-l); j=mac(k-l,k+l); printf("%d %d\n", i,j); } one immediate problem. expression mac(k+l,k-l) becomes (k+l<k-l ? k+l*k-l:k+l-k-l) ^^^^^^^ and, can see underlined bit, expression not think due precedence rules (multiplication done before addition). this can fixed ensuring each argument in macro parenthesised: #define mac(a,b) ((a)<(b) ? (a)*(b):(a)-(b)) but still won't if pass in n++ incremented multiple times. macros simple text substitutions , known cause problems such you're seeing. advice turn mac proper function avoid problem completely, like: int mac (int a, int b) { if (a < b) return * b; return - b; }

mod rewrite - URL redirect with Nested RewriteCond in .htaccess -

i'm migrating old url: example.com/video?id=40 to new one: example.com/video/name-of-video but them don't share field, can't make single rule , have write rewritecond every video have: rewritecond %{query_string} ^id=1$ rewriterule (.*) http://www.example.com/video/name-of-video? [r=301,l] rewritecond %{query_string} ^id=2$ rewriterule (.*) http://www.example.com/video/name-of-video? [r=301,l] rewritecond %{query_string} ^id=3$ rewriterule (.*) http://www.example.com/video/name-of-video? [r=301,l] rewritecond %{query_string} ^id=5$ ... so have more 6000 rewritecond slows web. want achieve check if url has query string 'id=(.*)' , if has it, check id has redirect correct video. want like: # if rewritecond %{query_string} ^id=(.*)$ # rewritecond %{query_string} ^id=1$ rewriterule (.*) http://www.example.com/video/name-of-video? [r=301,l] rewritecond %{query_string} ^id=2$ rewriterule (.*) http://www.example.com/video/name-of-video? [r=301,l] rewrite

php - need to send SMS and EMail to group of user if record's status is not changed aftewr 24 hrs? -

i using php , mysql. have record in database , want check status value of record after 24hrs of insertion if still in pending or no changed want send sms , email person relevant status. achieve have implemented solution in used php code need continuously execute , check status of record may cause dos. in solution create trigger can't able send db values parameter php file. should solution???? two ways came mind this. first , ( the way ) using cronjob. it's way. second , (bad way purpose) check see rows has age of 30 days in each request coming website. there cons way website doesn't visitors days sms or emails won't sent on time. bad thing executes on every request loading time , memory consumed during process.

python pointer memory reallocation -

i confused python's handling of pointers. example: a=[3,4,5] b=a a[0]=10 print returns [10, 4, 5] the above indicate b , pointers same location. issue if say: a[0]='some other type' b equals ['some other type', 4, 5] this not behavior expect python have reallocate memory @ pointer location due increase in size of type. going on here? variables in python reference memory location of object being assigned. changes made mutable object not create new object when b = a asking b refer location of a , not actual object [3, 4, 5] to explain further: in [1]: = [1, 2] in [2]: b = # b & point same list object [1, 2] in [3]: b[0] = 9 # list mutable original list altered & since referring same list location, changes in [4]: print [9, 2] in [5]: print b [9, 2]

jquery - Server side data to client side. (Node.js + express) -

good evening. we're starting implement server side code @ school , it's confusing hell. have piece of code on client side .js links server side .js. server side contains array of 2 objects. i'm trying pull length of array through client side. i've tried postscontroller.all.length , other things no avail. clues? var postscontroller = { all: function() { $.get('/api/posts', function(data) { var allposts = data; // iterate through allposts _.each(allposts, function(post) { // pass each post object through template , append view var $posthtml = $(postscontroller.template(post)); $('#post-list').append($posthtml); }); // add event-handlers phrases updating/deleting postscontroller.addeventhandlers(); }); }, i think problem not receiving json data server, instead jquery interpreting text. recommend trying use: $.getjson() see more information here on jquery documentation site

parsing - javascript parse datetime string in NewYork Timezone -

i have datetime string represents local new york time. 12/30/2020 12:00 pm i want parse in javascript epoch. parsing has work users may in different timezones. what did moment("07/13/2015 01:45 -04:00", 'm/d/yyyy h:mm z').unix() but not because had hardcode -04:00 and assume date i'm parsing eastern daylight saving time. use moment-timezone add-on. moment.tz("12/30/2020 12:00 pm", "m/d/yyyy h:mm a", "america/new_york").unix() also, aware there's no guarantee rules particular time zone persist future. knows if 2020 if government won't change dst rules again last did in 2007. sure, it's not affect date in december, in general case can't certain. when consider other time zones have changes - dozen or more changes globally every year. oh, , 1 minor petpeeve... said: ... epoch. the word epoch means "the start of something". unix epoch 1970-01-01t00:00:00z . it's

php - PHPQuery- Select table columns into an array -

i have html file table this: <tr valign="top" class="dselbkg" onmouseover="this.classname='selbkg'" onmouseout="this.classname='dselbkg'" > <td height="20" align="center">1</td> <td height="20"><div align="center">16-12-2014</div></td> <td ><div align="center">1st<br> (10:0 - 1:0 pm)</div></td> <td ><div align="center">be2105 </div></td> <td >programming in c</td> </tr> <tr valign="top" class="dselbkg" onmouseover="this.classname='selbkg'" onmouseout="this.classname='dselbkg'" > <td height="20" align="center">2</td> <td height="20"><div align="center">18-12-2014</div></td>

excel - Reports on Pivot Tables - Getting Slicers', Charts' and Filters' info -

i'm working on big reporting system lot of pivot tables, pivot charts, slicers , filters. so sure all pivot tables have right sources , slicers apply each 1 of them , started work on code aggregate useful info each pivot table : sub test_2_pt_report_by_sheet() thisworkbook.save application.screenupdating = false dim pt pivottable, _ sl slicer, _ rws worksheet, _ ws worksheet, _ pf pivotfilter, _ pfl pivotfield, _ headers string, _ tpstr string, _ sp() string, _ a() redim a(20, 0) set rws = thisworkbook.sheets("pt_report") headers = "name/sheet/address/version/source/slicercache/refreshed/slicer_number/slicers/slicers_values" & _ "activefilters/filters/activevalues/haschart/chart_location/ / / / / / " = lbound(a, 1) ubound(a, 1) a(i, 0) = split(headers, "/")(i) next on error resume next each ws in thisworkbook.sheets each pt in ws

ios - paste one xib onto another xib -

i want paste blue view onto yellow one. screenshot however, no matter how change autolayouts of blue one, there conflicts. press button in middle, , view show. xcode project add line file maned uiviewcontroller+testalert.m containerframe.size.width = view.frame.size.width; just after containerframe.size.height = view.frame.size.height; so code of showalertviewb function if (show) { nsarray* nibviews = [[nsbundle mainbundle] loadnibnamed:@"alertviewb" owner:self options:nil]; alertviewb = (alertviewb*)[nibviews objectatindex:0]; // [alertviewb removeconstraint:alertviewb.containerheightconstraint]; // nslayoutconstraint *newcontainerheightconstraint = [nslayoutconstraint constraintwithitem:alertviewb attribute:nslayoutattributeheight relatedby:nslayoutrelationequal toitem:nil attribute:nslayoutattributeheight multiplier:1.0 constant:view.frame.size.height]; // [alertviewb addconstraint:newcontainerheightconstraint];

json - Unable to get around with ng-controller -

i beginner angularjs trying build template using it. my points.html page this: <form ng-app="stdapp" ng-submit="save()" ng-controller="submissioncontroller"> <div class="select"> <label> select student </label> <select ng-options="student.name student in students" ng-model="student"></select> </div> <div class="checkbox"> <label ng-repeat="behavior in behaviors"> <input type="checkbox" ng-model="behavior"> {{behavior.name}} </label> </div> <div> <button type="button" class="btn btn-info">mark</button> </div> </form> and

php - mysqli create link based on row -

i want create link based on row value, , - more important, add variable - if row empty, text... if row have value, display this.... //i need display: // if row season empty, resulting link must be // web.com/movies/".$row["title_id"]." // if row season have value, link must be: //web.com/series/".$row["title_id"]."/season/".$row["season"]."/episode/".$row["episode"]." this base code. <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "dbname"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "select id, type, label, title_id, season, episode, approved links order id desc limit 30 offset

javascript - new Date(epoch) returning invalid date inside Ember component -

i have date-filter component using in ember application works on initial render, not on page reload, or if save file (which triggers application live update). in main template of application, render date-filter passing unix timestamp {{date-filter unixepoch=item.date}} then, in components/date-filter.js , use computed property called timeconverter change unix epoch time string formatted according user's language of choice, , in templates/components/date-filter.hbs file {{timeconverter}} display results timeconverter: function(){ //step 1: epoch passed in component var epoch = this.get('unixepoch'); //step 2: create human readable date string such `jun 29, 2015, 12:36pm` var datestring = new date(epoch) //do language formatting --code omitted problem step2 } it step 2 fails (returning invalid date ) if refresh page or save file. returns proper date string first time component called. if new date(epoch) in parent component, , try pa

rebase - How to linearize "splintered" merging history in Git? -

it must obvious, found no way it. every manual describes rebasing onto top of existing branch or simple interactive rebase , that's all. suppose, have diamond-shaped git history that: * 949430f merge commit (d) (head, mybranch) |\ | * e6a2e8b (c) * | 3e653ff (b) |/ * 9c3641f base commit (a) and want archieve history like: * 949430f combined commit (bcd) | * 9c3641f base commit (a) commits b , c may melted or discarded @ all, doesn't matter, want preserve result. not want revert commits because of nasty conficts resolving. here things i've tried: 1) can't archeve simple squashing b , c git rebase -i head~2 ... p 3e653ff (b) f e6a2e8b (c) ... not apply a91f3a4 well, that's understandable, there're conflicts. 2) can't archeve squashing. git rebase -i -p head~3 ... pick 9c3641f base commit (a) f 3e653ff (b) f e6a2e8b (c) pick 949430f merge commit (d) ... error: unable match a91f3a4... 3) can't discard b , c git rebas

javascript - Console.log and Alert not working in Chrome -

im working in google chrome servlet have following code: public void process(string input, printwriter out) { system.out.println(input.indexof("\\\\")); string json[]= input.split("\\\\"); for(int x =0; x< json.length;x++) { system.out.println(json.length); //jsonprocess(json[x]); out.println("<p class=\"json\" style =\"display:none\"> "); out.println(json[x]); out.println("</p>"); } out.println("<script>"+ "var jsonprocess= function(){\n" + "var jsoninfo = document.getelementbyclassname(\"json\");\n" + "var canvasel = document.getelementbyid(\"c\");\n" + "var nodesdata =[];\n"+ "window.alert(\"this test\");\n" +

html - Overlapping Rows/Columns Using Bootstrap Grid -

Image
issue: attempting create layout. need in 2 forms. since unable nest forms, have been trying use styling top left col-md-4 hide , allow 1 underneath slide make seem on same row (even though aren't). appreciated! here achieve: attempted solutions: without use of rows, off-setting top columns create space on left 1 below fill : <form id="1"> <div class="col-md-4 col-md-offset-4"> <div class="panel panel-default"> <div class="panel-heading">hello</div> <div class="panel-body">content here..</div> </div> </div> <div class="col-md-4"> <div class="panel panel-default"> <div class="panel-heading">hello</div> <div class="panel-body">content here..</div> </div> </div> </form> <form id="2"> <div class="col-md-4&

url rewriting - What RegEx pattern to use for URL rewrite to redirect traffic to HTTPS, but not from a particular subdomain? -

just got our ssl certificate installed , want redirect traffic https. running iis 7 on windows server 2008 using url rewrite module, want redirect traffic secure protocol, not particular subdomain. for example: mydomain.com , www.mydomain.com, want redirect https however, admin.mydomain.com, want leave on http protocol this example followed . set inbound rule , matching url pattern i'm using is: ^(?!(admin).*).*$ this redirects traffic domain, it's redirecting traffic admin.mydomain.com, don't want. pattern use redirect traffic, except particular subdomain? you'll need remove have , keep rule example, add 1 more condition below. negate=true ensures rules matches except domain want exclude: <add input="{http_host}" negate="true" pattern="^admin.mydomain.com$"/>

mongodb - Grails: Event listener never stop (with websocket plugin) -

i have problem listener (platform core plugin). never stop after event (afterinsert) triggered (mongo standalone) my service catch event , use simpmessagingtemplate (websocket plugin) send on topic data (a news user registration). data saved, listener triggered again , again. p.s. data not saved, consequent exception, rollback transaction. in debug mode can see assigned id. @transactional class messageeventservice { simpmessagingtemplate brokermessagingtemplate @listener(topic = 'afterinsert',namespace = 'gorm') void afterinsert(user user) { log.info("diobo") brokermessagingtemplate.convertandsend("/topic/myeventtopic", "myevent: user add ${user.name}") } } and @ end... .[grails] servlet.service() servlet grails threw exception java.lang.outofmemoryerror: java heap space @ java.util.arrays.copyof(arrays.java:2367) why happens?!?!? thanks!

node.js - Node/Express API - decouple oAuth login from server -

i have developed rest api using node.js , express , client application using angular. i authenticate users using third party oauth services (twitter initially), of tutorials/reading have done suggests must have webapp coupled server avoid security exceptions due different domains. i wish keep server , client decoupled plan build native apps @ point in future. can advise on workflow required such setup? surprised if server , app must coupled given native apps have decoupled setup. looking advice, thoughts, links ;) for getting access token in order fetch information of user advised make request server (you can securely store clientid , secret there). you have endpoint can authorize client specific service, let's /oauth/twitter/authenticate . call endpoint clicking login twitter button of angular application you have endpoint twitter going return information, in success or failure, e.g. /oauth/twitter/callback . store information in success , potentialy esta

winforms - Create Poll in C# (windows form) -

i want create poll. have table questions(fields: id,question) , answers(fields: id,questionid,answer). there table results(fields: questionid,answerid,userid).i want show percent of responding item in datagridview. example when enter question id, datagridview show: choose question id:1 option...........percent 1 ------------------------- 30 2 -------------------------- 20 3---------------------------50 4-------------------------- 10 this code result not show it: int = convert.toint32(textbox1.text); var q = (from s in session.db.poolusers s.poolqid == select s); var qq = (from c in q group c c.poolaid agroups select agroups.key); var qqq = (from c in qq select c).count(); messagebox.show(qqq.tostring()); and there classes: public partial class poola //for answers { public int id { get; set; } public string answer { g

javascript - Problems with three.js -

i want create scene car , should able move around scene mouse using three.js. i tried coding, works fine wanted add orbitcontrol , can't see whole scene anymore. what's wrong in there? <!doctype html> scene <script src="js/three.js"></script> <script src="js/controls/orbitcontrols.js"></script> <script> var width = 1300; var height = 500; init(); function animate() { requestanimationframe(animate); controls.update(); function init(){ var renderer = new three.webglrenderer({antialias: true}); renderer.setsize(width,height); var camera = new three.perspectivecamera(45, width/height, 1, 10000); camera.position.x = 5; camera.position.y = 2; camera.position.z = 5.3; var controls = new three.orbitcontrols( camera ); controls.damping = 0.2; controls.addeventlistener( 'change', render ); document.body.appendchild(renderer.domelement); var scene = new

php - Regex check for words and words with spaces separating letters -

so have array of profanities checking in string. e.g. $string = 'naughty string'; $words = [ 'naughty', 'example', 'words' ]; $pattern = '/('.join($words, '|').')/i'; preg_match_all($pattern, $string, $matches); $matched = implode(', ', $matches[0]); but want check profanities split spaces: e.g. n u g h t y yes can adding array: $words = [ 'naughty', 'n u g h t y', 'example', 'e x m p l e', 'words', 'w o r d s' ]; but have huge array of "bad" words , wondering if there easy way of doing this? ------ edit ------ so isn't meant super accurate. application every space new line.. string this: n u g h t y string result in this: n a u g h t y string to answer question asked, create pattern b\s*a\s*d instead of bad : $string = 'some bad , b d , more ugly , u g l y words';

cappuccino - CPDatePicker - open at dateValue not today's month -

can programatically trigger buttons on cpdatepicker graphical calendar? i'm setting date object fine, calendar displays current month, today's day in blue, rather datevalue month. clicking little circle button between month arrow stepper buttons switches display datevalue. i'm doing in code not ib. have trawled cp , ns documentation stuck! the implementation cpdatepicker uses control _cpdatepickercalendar display purposes in mode think you're asking about. control appears set view display whatever date selected: - (void)setdatevalue:(cpdate)adatevalue { var datevalue = [adatevalue copy]; [datevalue _datewithtimezone:[_datepicker timezone]]; [_monthview setmonthfordate:datevalue]; [_headerview setmonthfordate:[_monthview monthdate]]; [self setneedslayout]; [self setneedsdisplay:yes]; // <-- makes cappuccino redraw calendar } this called cpdatepicker when its' datevalue property written to. believe think want accomplish

c# - Unable to update current time in a excel using oledb -

Image
i trying insert current time time column in excel using below code through oledb connection when check excel value inserted in date format. value updated in excel - 1/0/1900 3:54:11 pm expected value - 3:54:11 pm string currenttime = datetime.now.tostring("hh:mm:ss.fff tt"); string cmnd1 = "create table [" + currentdate + "] (testcase char(100), executiontime time, result char(20))"; string cmnd2 = "insert [" + currentdate + "] (testcase, executiontime, result) values ("+ "'" + tname + "',@dd,'" + result +"')" ; using (oledbconnection conn = new oledbconnection(connectionstringtd)) { oledbcommand createsheet = new oledbcommand(cmnd1, conn); oledbcommand insertresult = new oledbcommand(cmnd2, conn); insertresult.parameters.addwithvalue("@dd", datetime.now.timeofday); conn.open

ruby on rails - how to add an upload button to active admin -

i trying add button call popup windows upload file on server. looking paperclip alternative without need use image preprocessor. user flow going next: - log in active admin - click create new photo - pick photo using file picker (a place stuck) - upload selected picture onto cloudinary or similar it. i use paperclip afraid require many other dependencies on production server. advice, friend? the simplest solution can think of looks this: activeadmin.register user form :html => { :multipart => true } |f| f.inputs "upload" f.input :image, :type => :file end f.actions end end maybe missed multipart attribute? nevertheless, i'd suggest take @ carriverwave ( https://github.com/carrierwaveuploader/carrierwave ). if not helping @ all, please post code examples. make easier others provide useful feedback.

excel - MS Access external data links -

this might hard explain i’m going try i have multiple external excel links in ms access database all excel workbooks located on server multiple users access workbooks analyse data (formulas , graphs etc) users refresh tables ms access queries some of these queries use external excel data. if user opens workbook in read/write mode whilst i’m opening query uses excel file. query opens copy of workbook in read mode? there way of on coming issue workbook doesn’t open. i can’t make excel file shared workbook since i’ve implemented tables

c# - Combining video and audio from multiple sources using ffmpeg -

i trying add audio file video file using ffmpeg. ffmpeg.exe -i "video.avi" -i "wave.wav" -map 0:0 -map 1:0 -vcodec copy -acodec copy "output.mp4" the above parameters work output file length greater of 2 input lengths. how can specify using video's length instead? as has been noted [1] [2] , in many cases ffmpeg cannot accurately set duration, or not set duration expected. use -t set desired duration.