Posts

Showing posts from September, 2011

javascript - numbers and text in same field -

i can't numbers , text in same form field force 2 decimal places or total figure. this link . i trying last 3 cells work 2 decimal places. e.g. total sq mt figure x price should calculate cost cell. also want cost cell (nan) working ! thanks. in general, want this function calc(val1, val2) { // not replacement calculate function val1 = parsefloat(val1.replace(/[^\d\.-]/g, '')); val2 = parsefloat(val2.replace(/[^\d\.-]/g, '')); return (val1 * val2).tofixed(2); } note: above returns string and stop redefining math.round in code

c++ - How do I link a library? (MySQL Library) -

alright, trying link program , never linked before need not linking (because have directory in linker -> additional directories need link against libmysql.lib/dll. not sure how that. if give me basic understanding great! don't make complex ;) i trying follow steps on website , says this: (i have looked , people said makefile , don't know how works) the connector/c++ static library file mysqlcppconn-static.lib. link library statically application. link against files libmysql.dll , libmysql.lib. @ runtime, application require access libmysql.dll. here's need install library c++ project. add additional depencies in linker. project->properties->linker->input click dropdown, click edit. on list on top, add names every .lib file included in library. example, if installing sdl, 1 add: sdl2.lib sdl2main.lib these files can found under lib folder of library downloaded (look around bit). tell vs header files are. project->propert

stripe.net - How to Update Account in StripeApi using C#? -

i trying update account in stripe api using stripe.net library ,using stripeaccountservice , storing in stripeaccount class made myself store result returned api : var accountservice = new stripeaccountservice("secretkey in string"); striperequestoptions option = new striperequestoptions(); option.stripeconnectaccountid = "accountid update"; stripeaccount x = accountservice.get(option); x.email = "local@local.com"; //then not know how save changes api now. but stripeaccountservice class has no update method define. how can perform update on account. i using this library. stripe api have update method here . stripe.net not support managed accounts: "managed accounts valuable service well, not available in stripe.net yet." https://github.com/jaymedavis/stripe.net#stripe-connect

node.js - Cannot install atom packages on windows -

i'm using atom windows 10 64bit. here's apm -v : apm 1.0.5 npm 2.13.3 node 0.10.40 python 2.7.10 git 2.6.1.windows.1 visual studio when trying install packages atom, atom-alignment , fails no error message: gyp info worked if ends ok gyp info using node-gyp@2.0.2 gyp info using node@0.10.40 | win32 | ia32 gyp http https://atom.io/download/atom-shell/v0.30.7/node-v0.30.7.tar.gz gyp warn install got error, rolling install gyp with apm install atom-alienment --verbose says: installing atom-alignment c:\users\clive\.atom\packages request { url: 'https://atom.io/api/packages/atom-alignment', json: true, retries: 4, proxy: null, strictssl: true, headers: { 'user-agent': 'npm/2.13.3 node/v0.10.40 win32 ia32' }, callback: [function], method: 'get' } request make request https://atom.io/api/packages/atom-alignment request onrequestresponse https://atom.io/api/packages/atom-alignment 200 { server: 'cowboy', connect

What's the meaning of DISALLOW_FUN in Android's source code? -

from http://developer.android.com/reference/android/os/usermanager.html , can find weird string variable named disallow_fun, specifies if user not allowed have fun. however, cannot understand means. any explanation? afaik, easter egg , along lines of gravity_death_star_i , many other similar jokes in sdk .

javascript - Set a local image into clipboard contents -

i've looked everywhere found solutions revolving online images. i'm dealing local image directory: c:\users\me\desktop\venice.jpg i need javascript or vbscript set image (not path) clipboard, can paste image application word or ms paint. i've found following code, don't know how adapt use. there no internet access required. simple, local javascript function need. have no applicable html don't see substitute "div" below. great!! thank you. var div = document.getelementbyid('divtocopy'); div.contenteditable = 'true'; var controlrange; if (document.body.createcontrolrange) { controlrange = document.body.createcontrolrange(); controlrange.addelement(div); controlrange.execcommand('copy'); } div.contenteditable = 'false'; in powershell copying image file clipboard simple this: add-type -assembly system.windows.forms add-type -assembly system.drawing $imgpath = 'c:\users\me\desktop\venice.jpg' $img =

Haxe / OpenFL compile fails with "Unknown identifier : cpp" -

working on openfl project, updated bunch of relevant haxe libraries (hxcpp, openfl, lime, etc) , started getting weird haxe compiler error. > lime test linux cffipointer.hx:55: characters 23-81 : unknown identifier : cpp ... (tons more of same error) i believe line referencing #if compile switch on cpp . should never fail far know? notes: if see error, feel free comment can identify cause! someone commented lime , openfl commands different, , technically are, openfl built on lime , commands ( lime test linux , openfl test linux ) work interchangeably project. i'm not sure of exact issue, fixed installing , switching official haxe 3.2.0 haxe.org (i got error while using haxe 3.2.0-rc2 -- release candidate build.)

xcode - iOS convert UTC string to local date -

code: nsdateformatter *fmt = [[nsdateformatter alloc] init]; fmt.dateformat = @"yyyy-mm-dd hh:mm:ss"; nsdate *utc = [fmt datefromstring:strtime]; nstimezone *tz = [nstimezone defaulttimezone]; nsinteger seconds = [tz secondsfromgmtfordate: utc]; nsdate *localdate = [nsdate datewithtimeinterval:seconds sincedate:utc]; nsstring *local = [fmt stringfromdate:localdate]; nslog(@"local time%@", local); nsdate *localdate = [fmt datefromstring:local]; i getting utc string server. converted local string try convert local date. date showing in utc format.what wrong code?any appreciated.thanks in advance try out: nsdateformatter *fmt = [[nsdateformatter alloc] init]; fmt.dateformat = @"yyyy-mm-dd hh:mm:ss"; nsdate *utc = [fmt datefromstring:<your_utc_string>]; fmt.timezone = [nstimezone systemtimezone]; nsstring *local = [fmt stringfromdate:utc]; nslog(@"%@", local);

elixir - Forcing package update with Mix -

when use following command mix deps.update --all mix use locally cached packages if version of package has not been changed in mix.ex file. question is, how can force mix not use cached version , download server instead? example, if there changes in last version of package , want pick up, if version has not been bumped. first of released hex package can changed 1 hour after created, after becomes immutable , wont ever change. in future when hex adds tooling testing packages before release never able change package has been published. hex conditional request fetch package if it's cached. if package didn't change use cache, if did change fetch again. if unable reach hex cdn automatically use cached package if it's available. additionally time or update packages hex download registry of released packages includes checksum use verify against package tarball never able use outdated packages.

python - Pandas HDFStore: Saving and Retrieving a Series with Hierarchical Period Index -

i first create series 2 dimensional hierarchical index. index type (pandas.period, numpy.int32) in [265]: import pandas pd in [266]: import numpy np in [267]: hdf_file = r'f:\test.h5' in [268]: data = np.random.randint(10, size=(7, 3)) in [269]: dates = pd.date_range('1/1/2015', '1/7/2015').to_period('d') in [270]: ts1 = pd.dataframe(data, index = dates, columns = [1, 2, 3]).stack() then, save series (ts1) using hdfstore , retrieve (as ts2): in [271]: pd.hdfstore(hdf_file, 'w') store: ...: store['ts'] = ts1 ...: in [272]: pd.hdfstore(hdf_file, 'r') store: ...: ts2 = store['ts'] ...: now, dtype of index of retrieved series (ts2) has been changed integer: in [273]: print(ts1) 2015-01-01 1 3 2 8 3 0 2015-01-02 1 2 2 3 3 9 2015-01-03 1 9 2 2 3 2 2015-01-04 1 4

java - Captcha creation without a third party -

newbie on here. i'm designing , coding few websites using adobe dreamweaver. i'm 3 months in web development @ current job @ point. haven't had formal training in web development, have eye design , attention detail. however, more technical things difficult me i'm getting started. want create self contained captcha within 2 websites without using third party service or downloadable plugins. important, because creating website company work full time part of job description. how go making simple contact form , captcha using php & java example? i'm familiar php , java. if explain me in idiot-proof way i'd appreciate it. i've been browsing stack overflow, can't seem find specific , i'd prefer fresh answer. thanks all. i'm not familiar of jargon yet, forgive me lack of knowledge presently. if incredibly stupid question also, apologize - still need answer. using php: start session create random string store string session

sqlite - SQLite3 Query - Incorrect output -

i running 1 specific query on database in sqlite3 , giving me wrong output. the question posed myself to: find total number of itemid's of auctions highest current price. the answer 1,046,871,451, 300k more that. there tables/relations: item (itemid, name, currently, buy_price, first_bid, number_of_bids, started, ends, userid, description) user (userid, rating, location, country) category (itemid, category) bid (itemid, userid, time, amount) this attempt: select itemid item in (select max(currently) item); i @ lost , input query. many in advance. edit note : = current price of item. edit 2 : 2nd attempt select itemid item in (select distinct max(currently) item group itemid);

python - Incrementing in a for loop -

so issue not incrementing correctly... tried uses int "step" + 1 every time loop ran doesn't anything. why that? when print(step) adds 337. not go full 1000 had thought asked too. how do correctly? lockers = [] step = 3 locker = 0 while len(lockers) <= 1000: lockers.append(1) in range(0, len(lockers)): lockers[i] = 0 in range(0, len(lockers), 2): lockers[i] = 1 in range(0, len(lockers), step): if lockers[i] == 0: lockers [i] = 1 else: lockers[i] = 0 step += 1 print(lockers) range gives iterable object: >>> range(10,20 , 2) range(10, 20, 2) >>> list(range(10,20 , 2)) [10, 12, 14, 16, 18] the values in decided call returns, , aren't re-evaluated each time around loop. step goes 337 because incrementing once each element in object range(0, 1000, 3) , has 334 items, not 1000: >>> len(range(0,1000,3)) 334 to works range advances step , need write own generator

licensing - Use Azure Cloud Service for License Server -

i want build license server(or service db) hosted azure .net desktop application. works as, give our customer serial key. customer use key aktive application. application send request azure, check whether matched license file available on server,then download license file customer pc. of course, used check licesne , update. i totoally new azure, need vm. or build cloud service, how works technically, give hint? thanks lot this depends on looking for. azure has different products different use cases. what kind of program "license server"? .net console application? best bet use "cloud service" , build "worker role" around application. worker roles console apps hosted on vm microsoft , allows preinstall software on vm itself. not direct control on os (more explained here http://blogs.msdn.com/b/plankytronixx/archive/2012/06/08/the-difference-between-azure-vms-and-azure-vm-role.aspx if need fine grained control on license server (e.g. ne

Use JQuery interfaces directly typescript? -

i'm new typescript i'm missing here, in code i'm trying specify function returns object implements jqueryxhr interface in jquery library definition file (jquery.d.ts) that's code import $ = require("jquery"); interface iproduct { ... } class product { create(product: iproduct) : jqueryxhr { return $.ajax(... ); } } jqueryxhr interface in jquery.d.ts file can't figure out how reference since it's not exported ? try adding following top of file. ///<reference path="[relative path to]/jquery.d.ts" />

c++11 - golang-style "defer" in C++ -

this question has answer here: what standard defer/finalizer implementation in c++? 6 answers i reading go language's defer statement. allows specify action take when function has ended. example, if have file pointer or resource, instead of writing free/delete every possible return path, need specify defer function once. it looks analogue might coming c++ ( what standard defer/finalizer implementation in c++? , will there standardization of scope guard/scope exit idioms? ) until then, there unforeseen doing object destructor makes callback? looks destructor order local variables sane , handles exceptions well, though maybe not exiting on signals. here sample implementation... there troubling it? #include <iostream> #include <functional> using namespace std; class frameexittask { std::function<void()> func_; public: frameexittask

html - How to add text to a page using python selenium? -

i'm trying enter text text box using python selenium. the html looks below: <div class="sendbox placeholder" contenteditable="true" data-placeholder="type message or drop attachment..." id="sendmessage" style="height: 375px;"></div> after manually typing 'test' text box, html looks this: <div class="sendbox placeholder" contenteditable="true" data-placeholder="type message or drop attachment..." id="sendmessage" style="height: 375px;">test</div> i've tried following code, there no response driver.find_element_by_xpath("//div[@id='sendmessage']").send_keys("testing") however, if manually click on text box cursor shows , enter in code, work. haven't been able figure out how make curser show via python selenium. i've tried below though. driver.find_element_by_xpath("//div[@id='sendmessag

javascript - AngularJS - Service talking to Controller -

angular js has pretty cool feature of two-way binding allows controller data automatically updated when view changes (or vice-versa). today can have controllers dependent on services. possible services depend on controller? e.g. if service wants fetch data controller on it's own will, possible? also, possible extend scope of ng-model variable pass service (along controller) variable, keeps in sync automatically? thanks. when assign multiple variables same object , each reference same object. following demonstration. may not preferred approach depending on use case app.controller('mainctrl', function($scope, myservice) { $scope.mainmodel = myservice.myobject; }) app.controller('otherctrl', function($scope, myservice) { $scope.othermodel = myservice.myobject; }) app.factory('myservice', function() { return { myobject: { name: 'test' } } }); both of following inputs show same value <div ng-controll

drupal - Drupal8 How to set a logo? -

i new drupal. installed drupal 8 tried learn it. wanted change logo of site. using theme bartik. went apperance settings->logo image settings->upload logo image. selected image , tried save configuration error this. fatal error: cannot instantiate interface drupal\core\cache\cachebackendinterface in /home/user/public_html/dp8/core/lib/drupal/component/dependencyinjection/container.php on line 265 why getting fatal error? did miss? this may caused because of contributed module added. had changed logo on system , works fine, try clear caches , disable , dev version modules. regards

java - AVD is not working properly. It come up but unable to work on that -

Image
while i'm trying open avd this. now i'm suppose do. this avd configuration. try this... create avd following config.

python - YoutubeDL - How to get a status object after download has completed -

i'm trying information out of seems status object that's hitting hook in youtube-dl, , i'm trying save db. i've got 'song' object attributes such "filename" i'm trying save once download complete, , maybe continually update database progress. there's 4 ways can think of i've not been able them work send my_hook function db , song object , save in there once status == finished. problem i'm unable pass additional parameters hook unless i'm missing something get my_hook function return d , save that, problem don't think can access return (youtube-dl source) get ydl.download([song.url]) return status object can process, don't think though i don't want this, can output .json file , there, or guess name of file given i'm dictating :( code looks this: def my_hook(d): if d['status'] == 'finished': file_tuple = os.path.split(os.path.abspath(d['filename'])) print(&qu

javascript - Changing Text and Hiding a table -

i want use div "link" in way when div clicked toggles table's visibility , div's text changes. can table toggle upon click, can't text in div change based upon table's visibility. here code: $(document).ready(function () { $('.details td').hide(); $('#link').click(function () { $('.details td').toggle(); if (('.details td').is(':hidden')) { $('#link').text('click more detail'); } else { $('#link').text('click hide details'); } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="link" style="color: blue">click more detail</div> <div class="details"> <table class="details"> <tr> <td>details</td> </tr> <tr> <td>more details</t

Salesforce and vk.com API integration -

i need implement such functionality, can allow manage vk.com* entities (create posts, send messages, add new friends etc) form salesforce side. although vk.com provides rich api documentation, developed solutions apex. i checked appexchange , googled popular solutions, didn't find anything:( there ready apex ways or have myself? maybe can use power of salesforce chatter? i glad advice, suggestions! *vk.com social network, kind of facebook, has higher relevance facebook in eastern europe, russia.

ruby - Rails subquery always returns nil value -

Image
i need count rows other table in subselect, use query: follows_sql = follow.where(followable_type: 'idea').where('follows.followable_id = ideas.id').select('count(followable_id)').to_sql idea = idea.select("(#{follows_sql}) fcnt").includes(:collaborations). where(collaborations: { user_id: 4, owner: true }) so produced valid sql, cant access 'fcnt' value idea var. tried in different ways like: idea[0].fcnt # return nil idea[0]["fcnt"] # return nil but can access fields exists in idea model. how can access custom ' fcnt ' field? i think along following should work you idea = idea.select("ideas.*, count(follows.id) fcnt").joins("left outer join follows on follows.followable_id = ideas.id").group("ideas.id") ideas.each |idea| puts idea.fcnt # should output number end note i've left out other includes , clauses. try solve problem first, , if query works out, ad

asp.net mvc - How to show complete table using model in MVC? -

my database table has 50 rows, how show tables on view using model? when tried show product data on view. shows last row of table, how can show rows in view? //model : product properties public class allitems { public string id { get; set; } public string name { get; set; } public string qty { get; set; } public string price { get; set; } public string imgname { get; set; } public string prddesc { get; set; } } //controller : product data action manager public actionresult viewallitems() { string[] name = new string[10]; datatable dtproducts = data.getallitems(); (int = 0; < dtproducts.rows.count; i++) { allitems allitems = new allitems { id = dtproducts.rows[i][0].tostring(), name = dtproducts.rows[i][1].tostring(), qty = dtproducts.rows[i][2].tostring(),

c# - Task.ContinueWith callback thread -

i tried find answer couldn't. wondering on thread task.continuewith delegate called. await know tries run on captured synchronizationcontext there nothing documented continuewith . i tried sample program , though seems called on threadpool thread, suspect in scenario might call on synchronizationcontext . maybe can provide definitive answer. this depends on scheduler associated continuation. default, task continuations scheduled through current scheduler, being taskscheduler associated executing task. when continuewith not called within task, current return default scheduler, default taskscheduler instance provided .net framework, , schedule tasks on thread pool. if want influence behaviour, can call 1 of continuewith overloads takes taskscheduler parameter. common pattern pass taskscheduler.fromcurrentsynchronizationcontext() when creating continuations on ui thread, cause continuation dispatched onto ui thread when executed. edit : in reply your com

powershell - Using the Get-Date cmdlet -

i taking scripting class part of degree , stumped on powershell script. have use get-date time how long game played, , create log file stores number of games played, , shorted , longest games played. log file must created outside script, must update within script. put code have far below. $rand = new-object system.random $number= $rand.next(0,11) clear-host do{ $a = read-host -prompt "enter number between 1 , 10" if ($a -gt $number) {write-host "number high"} elseif ($a -lt $number) {write-host "number low"} elseif ($a -eq $number) {write-host "you did it!! took $x tries!"} else {"you have guess number!!!"} $x = $x + 1 } while ($a -ne $number) $path = c:\temp\logfile.log.txt to time execution, grab date before , after you've done work, , subtract 2 timespan representing time took $starttime = get-date # script goes here $endtime = get-date $timetaken = $endtime - $starttime write-host "a total of $($t

html - jQuery: slideDown() showing wrong divs -

i have 4 different divs want show 4 different buttons. when uesr clicks specific link, specific div show up. html: links: <div class="col-md-3 text-center"> <a id="clickme1">i'm interested</a> </div> <div class="col-md-3 text-center"> <a id="clickme2">i'm interested</a> </div> <div class="col-md-3 text-center"> <a id="clickme3">i'm interested</a> </div> <div class="col-md-3 text-center"> <a id="clickme4">i'm interested</a> </div> my divs: <div class="col-md-3 text-center" id="ad1"> <p>show table here</p> </div> <div class="col-md-3 text-center" id="ad2"> <p>show table here</p> </div> <div class="col-md-3 text-c

collections - Magento - Add filter to getLoadedProductCollection() -

in magento store (ce-1.9.0) have setup custom product attribute: custom_depth_check and attribute has setting of used in product listing : yes used sorting in product listing : yes i need filter getloadedproductcollection() attribute. attribute either set at: null 0 1 i need filter instances of getloadedproductcollection() exlcude products custom_depth_check : 1 i have tried clear , reload so: $_productcollection=$this->getloadedproductcollection() ->clear() ->addattributetofilter('custom_depth_check', array('neq' => 1)); but results in empty collection. tried adding ->load() @ end again nothing comes up. the collection loaded in file: app/code/mage/catalog/block/product/list.php in function: _getproductcollection() do local ovveride copyng file in local folder app/code/local/mage/catalog/block/product/list.php and add new filters before line $this->preparesortablefieldsbycategory($layer->getcurrentcategory(

Unable to send HTML mail using opencart -

i trying send html mail using opencart using following code $mail = new mail(); $namess = $this->request->post['name']; $emailss = $this->request->post['email']; $phoness = $this->request->post['phone']; $phoness2 = $this->request->post['phone2']; $enquiryss = $this->request->post['enquiry']; $conve = $this->request->post['contactviae']; $convp = $this->request->post['contactviap']; if($conve == '1') { $convee = "yes"; } else { $convee = "no"; } if($convp == '1') { $convpp = "yes"; } else { $convpp = "no"; } $body = "hello admin <br/><br/> have recieved request product. details product follow : <br/><br/> <table border='1'> <tr><td>name</td><td>$namess</td></tr> <tr><td>email</td><td>$emailss</td>

Swig and PHP: C function expects enum as argument -

i have c function looks this: getcurrentmode(radiomodes *radiomodes); and both .h file , swigs .i file contain these enum definition: typedef enum _radiomodes { radiomodes_none = 0, radiomodes_one = 1, radiomodes_two = 2, } radiomodes; getcurrentmode should set $rcs correct mode. when run: $rcs = radiomodes_none; getcurrentmode($rcs); i these error: php fatal error: type error in argument 1 of getcurrentmode. expected swigtype_p__radiomodes how swig , php set $rcs correct enum? or how swig convert enum radiomode int , back? solved: issue needed add pointer function after .h file defined. %pointer_functions( radiomodes, radiomodesp ) this added several new functions can use in php.

How to do unit test websocket with embedded jetty? -

i want write junit ut case websocket serverendpoint code using embedded jetty. i tried things explained in below link: junit test javax.websocket on embedded jetty throws rejectedexecutionexception: nonblockingthread i want test onmessage callback websocket. if dont use server.join() method connection closes opens. if use server.join() method nothing happens after joining. below code. server startup code:: public class embeddedjettyserver { private final int port; private server server; public embeddedjettyserver(int port) { this.port = port; } public void start() throws exception { server = new server(); serverconnector connector = new serverconnector(server); connector.setport(8080); server.addconnector(connector); // setup basic application "context" application @ "/" // known handler tree (in jetty speak) servletcontexthandler context = new servletcontexthandler(se

php - mysqli_query “INSERT into” -

i use code dosen't insert data base..please me mysqli_query($link, "insert `usertable`(`id`, `username`, `password`) values (null,'$username','$password')" ); mysqli_query("insert `usertable`(`username`, `password`) values ('$username','$password')" ); database set id auto-increment.

php - use custom function in assetmanager -

how use yii::$app->session['somename'] in yii2 assetmanager? how make access function in assetmanager? class appasset extends assetbundle{ public function getlang() { $currentlang = yii::$app->session['lang']; if ($currentlang == 'fa' || $currentlang == 'ar') { return 'rtl'; } else { return 'ltr'; } } public $lang; public $basepath = '@webroot'; public $baseurl = '@web'; public $css = [ 'css/iconsprite.min.css', // how call getlang here ] how call getlang in css part? you can this .. other functions public function init() { $this->setupassets(); parent::init(); } protected function setupassets() { $lang = $this->getlang(); $this->css[] = "css/myfile.$lang.css"; }

Django - Suffix all urls with language code -

i'm working on multilingual site want suffix urls current 2-character language code. if no language specified want default english. for example: mysite.com/ --> mysite.com/en mysite.com/location --> mysite.com/locations/en mysite.com/ar display arabic site since don't want add (?p<language>[a-x]{2})$ urls i'm guessing should write middleware check suffix , strip out? what's best way achieve this? as indicated in comment @bogdan above resorted using built-in prefixing feature in django. i added localemiddleware in middleware_classes setting i added languages setting specify languages in site, in case english , arabic languages looked languages = ( ('ar', _('arabic')), ('en', _('english')), ) in views used request.language_code access language code , display appropriate language in template

Creating R package, what is .Rcheck folder? and how to create .tar.gz file? -

i trying create r package using "rstudio" first time ^_*. actually, wrote functions in several "r scripts" , documentation using roxygen2. i loaded , built (ctrl+shift+b) , works "done(packagename)", used roxgen2::roxgenise() documentation , ".rd files" have been created in "man" folder. also, checked package (ctrl+shift+e) , got "status: ok" , "r cmd check succeeded". i mean working well. questions - there folder "packagename.rcheck" has been created, folder? , important creating ".tar.gz" file? appreciate help, thanks

python - Conditional Substitution of values in pandas dataframe columns -

suppose i've pandas dataframe column values age df.age = {25, 35, 76, 21, 23, 30} i want inplace replace this: if df.age >=25 , df.age <= 35: replace value 1 else: replace value 0 i've tried df[df.age >= 7.35 , df.age <= 7.45, 'age'] = 0 doesn't seem work. you can create function check conditions, , apply dataframe: def condition(value): if 25 <= value <= 35: return 1 return 0 # stealing sample @anandskumar because i'm lazy in [32]: df out[32]: age 0 25 1 35 2 76 3 21 4 23 5 30 in [33]: df['age'] = df['age'].apply(condition) in [34]: df out[34]: age 0 1 1 1 2 0 3 0 4 0 5 1 or using 1 liner lambda: df['age'] = df['age'].apply(lambda x: 1 if 25 <= x <= 35 else 0)

java - Can't set max for seekbar -

i trying set max seekbar still defaults 100. xml <seekbar android:id="@+id/seekbarrow1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="5" android:progress="0" /> defining , setting max final seekbar seekbarrow1 = (seekbar)findviewbyid(r.id.seekbarrow1); seekbarrow1.setmax(50); don't know if effecting here listener seekbarrow1.setonseekbarchangelistener(new seekbar.onseekbarchangelistener() { @override public void onstoptrackingtouch(seekbar seekbar) { } @override public void onstarttrackingtouch(seekbar seekbar) { } @override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { progress = progress * 2; numweightsrow1 = progress; numweightsrow1 = numweightsrow1 / 2; numrow1.settext("" + progress); updateweight(); } }); i have tried

ASP.NET MVC and Angularjs vs ASP.NET MVC and Reactjs -

i have used angularjs on top of asp.net mvc projects. though both angularjs , asp.net based on mvc architecture can see advantages when using angularjs on top of asp.net mvc projects. main advantage see in approach better rendering of views. if why not use reactjs asp.net mvc since purely focusing on views. why have mess 2 mvc frameworks. won't better use reactjs on top of asp.net mvc using angularjs , asp.net mvc combination (note use asp.net mvc , don't want use pure javascript framework). please correct me if wrong. in advance. i've used both angular , react in projects in past. angular dirty html markup angular code. react it's encapsulated in component. never expert angular may not have used best of it's ability me reactjs seems better framework , seems better fit asp.net mvc. i don't believe there 1 correct tool job though. it's whatever suits needs , comfortable with. suggest giving reactjs shot though.

Django CSRF Verifcation failed - Class based views -

i'm using class-based views. class usercreate(view): def post(self, request): data = request.data.get social_id = data('social_id') social_source = data('social_source') user = user(social_id=social_id, social_source=social_source, access_token=access_token) user.save() return jsonresponse({'response':200}) whenever post data on url, says csrf token missing or incorrect. curl -x post --header "content-type: application/json" --header "accept: application/json" -d "{ \"social_id\": \"string\", \"social_source\": \"fb/gmail\", \"access_token\": \"string\" }" "http://127.0.0.1:8000/users/" i've had problem while getting data form in function views. there used add @csrf_exempt on view , work. when added @csrf_exempt post method, not work. how can post data? this because class_based

call php-cgi from c++ with REQUEST_METHOD="POST" -

i want convert shell script c++. please me. this shell script file. worked well, when move c++, not work correctly test.sh #!/bin/sh request_data="var_1=val_1&var_2=val_2" export gateway_interface="cgi/1.1" export server_protocol="http/1.1" export query_string="test=querystring" export redirect_status="200" export script_filename="/test.php" export request_method="post" export content_length=${#request_data} export content_type="application/x-www-form-urlencoded;charset=utf-8" echo $request_data | /usr/bin/php-cgi and test.php is <?php print_r($_post); ?> when run sh test.sh , got response: x-powered-by: php/5.6.13 set-cookie: phpsessid=f4ntbasno365p08tf94drl7026; path=/ expires: thu, 19 nov 1981 08:52:00 gmt cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 pragma: no-cache content-type: text/html; charset=utf-8 array ( [var_1] => val_1

java - onPostExecute() invoked before doInBackground() method in the case of AsyncTask -

consider code below: package com.reallybelievebig.asynctaskextracredit; import android.os.asynctask; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.textview; import android.widget.toast; public class asynctasktestactivity extends appcompatactivity { private static final string tag = asynctasktestactivity.class.getsimplename(); protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_async_task_test); new testtask().execute("execute"); log.d(tag, "in ui thread!"); } private class testtask extends asynctask<string, integer, string> { @override protected string doinbackground(string... params) { (int = 0; <= 100; i+=20) { try {

regex - C++ regular expression over a stream -

i have large text file (up few hundred mb) process stl regular expression. matching region looking spans several lines , happens @ least few thousand times in file. can use stream iterators purpose? i've tried std::istream_iterator, no luck. 1 post minimal working example? note, looking solution involving stl. in perfect solution iterate on matches. edit once i've read comment, understand not possible. maybe there way iterate on regex matches found in large text file: #include <regex> #include <iostream> #include <string> const std::string s = r"(quick brown fox jumps on several lines)"; // @ least 200mb of multiline text here int main(int argc,char* argv[]) { std::regex find_jumping_fox("(quick(?:.|\\n)+?jump\\s*?)"); auto = std::sregex_iterator(s.begin(), s.end(), find_jumping_fox); (std::sregex_iterator = it; != std::sregex_iterator(); ++i) { std::smatch match = *i;

Delays on ffmpeg with rtsp streaming -

i have command ffmpeg -threads 0 -i rtsp://user:pass@10.10.10.1 -threads 0 -i rtsp://user:pass@10.10.10.2 -map 0:1 -map 1:1 -filter_complex amix=inputs=2:duration=first:dropout_transition=3 -muxdelay 0 -ar 22050 -vn -f flv rtmp://10.10.10.3:1935/live/stream1 -map 0:0 -map 0:1 -muxdelay 0 -ar 22050 -f flv rtmp://10.10.10.3:1935/live/stream4 -map 1:0 -map 1:1 -muxdelay 0 -ar 22050 -f flv rtmp://10.10.10.3:1935/live/stream5 it 3 things: 1) takes audio both ip cameras (10.10.10.1 , 10.10.10.2) - , muxes them in 1 mp3 stream (stream1). 2) takes audio , video cam 10.10.10.1 , streams rtmp://10.10.10.3:1935/live/stream4 3) takes audio , video cam 10.10.10.2 , streams rtmp://10.10.10.3:1935/live/stream5 problem: delays: 1) delay reality: smile in cam1 , see smile on stream4 in 4-5 seconds. 2) different delays on different cameras. both cameras @ me, "hello". first camera shows "hello", in 4-5 seconds second camera shows "hello", , in 2-3 second hear &q

Pandas/Python ruining JSON data in DataFrames -

i'm interacting api , getting json data back. @ top level of json object have 'regular' data fields have more advanced structures: { "foo": 1, "bar": "string", "spam": { "egg":"green", "ham":"yum", "ran": { "out_of":"fake_words" } } } i need preserve these advanced structures ("spam") valid json i'm getting data using requests , loading pandas dataframe so: api_result = api.get_data().json() #the json output of request object df = read_json(json.dumps(api_result)) this gives me nice dataframe 3 columns, expect (this want). problem comes strings: foo bar spam 1 'string' {'egg':'green','ham':'yum','ran':{'out_of':'fake_words'} pandas or

android - Customize NavigationDrawer with RelativeLayout? -

i want picture on top of navigationdrawer , below listview contains navigation items. set linearlayout navigationdrawer contains imageview , listview . unfortunately doesnt work , error: 10-22 16:39:00.609 6555-6555/com.example.pymdev.pym_app e/androidruntime: fatal exception: main 10-22 16:39:00.609 6555-6555/com.example.pymdev.pym_app e/androidruntime: java.lang.runtimeexception: unable start activity componentinfo{com.example.pymdev.pym_app/com.example.pymdev.pym_app.menuactivity}: java.lang.illegalstateexception: specified child has parent. must call removeview() on child's parent first. 10-22 16:39:00.609 6555-6555/com.example.pymdev.pym_app e/androidruntime: @ android.app.activitythread.performlaunchactivity(activitythread.java:2114) 10-22 16:39:00.609 6555-6555/com.example.pymdev.pym_app e/androidruntime: @ android.app.activitythread.handlelaunchactivity(activitythread.java:2139) 10-22 16:39:00.609 6555-6555/com.example.pymdev.pym_app e/androidruntime: