Posts

Showing posts from July, 2013

Python Removing Duplicates in a String Using in and not in -

i'm trying use in , not in operators accumulator pattern remove duplicate letters string , return new string while maintaining order. withdups = "the quick brown fox jumped on lazy dog" def removedups(s): alphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" swithoutdups = "" eachchar in withdups: if eachchar in alphabet: swithoutdups = eachchar + swithoutdups return swithoutdups print(removedups(withdups)) my current code returns first letter of string. i'm new python , coding in general, please excuse if i'm overlooking simple, current code not right direction, or if i'm posting shouldn't be. withdups = "the quick brown fox jumped on lazy dog" withoutdups = "" letter in withdups: if letter not in withoutdups: withoutdups += letter print withoutdups have in mind whitespaces considered character too.

c++ - Convert a String to an int and store the result in a variable -

int units; void input(int i) { char temp[50]; printf("enter class id #%d > ", + 1); readline(classid); printf("enter name #%d > ", + 1); readline(classname); printf("enter description #%d > ", + 1); readline(description); printf("enter pre-reqs #%d > ", + 1); readline(prereqs); printf("enter units > "); readline(temp); // write method convert string temp integer , store in units field i think need nested loop not sure how go conversion please help. use atoi() function cstdlib (you need include cstdlib @ top of file): units = atoi(temp); it converts char array integer. see here . you can use strtol() allows error checking, see here details. credit: @nathanoliver

html - How to make the objects stay after dropping to another column -

i have drag , drop functionality on html page. once drag box 1 column another, want box stay in new column user. so, if user signs in back, should see box in new column. here html code: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <meta name="description" content="drag , drop table content javascript"/> <meta name="viewport" content="width=device-width, user-scalable=no"/><!-- "position: fixed" fix android 2.2+ --> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> <link rel='stylesheet' href='/stylesheets/bootstrap-theme.css' /> <link rel='stylesheet' href='/stylesheets/bootstrap-theme.min.css' /> <link rel='stylesheet' href='/

python - Get data from cell in pandas and user it in calculations -

i've got csv file loading in table using pandas. rank player nat tot mtchwin-loss tie brkwin-loss \ 0 1 novak djokovic srb 5-0 0-0 1 2 roger federer sui 1-1 0-1 2 3 andy murray gbr 0-0 0-0 3 4 rafael nadal esp 11-3 2-1 4 5 kei nishikori jpn 5-0 0-0 5 6 milos raonic can 2-1 1-0 6 7 tomas berdych cze 4-1 2-0 7 8 david ferrer esp 10-2 2-2 8 9 stan wawrinka sui 1-1 0-0 9 10 marin cilic cro 2-2 1-0 10 11 grigor dimitrov bul 3-1 0-0 11 12 feliciano

python - Why do Datastore datetimes look different in appengine console vs appengine dashboard? -

i have simple ndb model i'm entering date-of-birth user: class contact(ndb.model): first_name= ndb.stringproperty() last_name= ndb.stringproperty() dob = ndb.datetimeproperty() contact1_dob = datetime.strptime('12/17/1989', "%m/%d/%y").date() contact1 = contact(first_name='homer', last_name='simpson', dob=contact1_dob ) contact1_result = contact1.put() loading datastore works fine, , when @ data via google appengine dashboard https://appengine.google.com/ dob looks perfect e.g. 1989-12-17 00:00:00 but when @ data via appengine console https://console.developers.google.com dob 4 hours behind (i'm in new york) e.g. 1989-12-16 20:00:00 i can guess timezone issue if wouldn't dates in both dashboard , console match? also if retrieve entity via .get() call , view raw data date entered it, e.g. 1989-12-17 00:00:00, want. so why appengine console not rendering datastore dates accurately? the old dataviewer di

C# Siteminder Authentication -

i trying write code connect https site uses siteminder authentication. i keep getting 401. ideas? i have read few different things on here none have seemed helpful. using fiddler/firefox tamper snoop what's going on. here i've got far in regards code: try { uri uri = new uri("https://websiteaddresshere"); httpwebrequest request = (httpwebrequest)webrequest.create(uri) httpwebrequest; request.accept = "text/html, application/xhtml+xml, */*"; request.useragent = "mozilla/5.0 (windows nt 6.1; wow64; trident/7.0; rv:11.0) gecko"; // request.connection = "keep-alive"; // request.method = "get"; // request.accept = "text"; request.allowautoredirect = true; request.automaticdecompression = decompressionmethods.gzip | decompressionmethods.deflate; cookie emersoncookie = new cookie("

javascript - Issue with jQuery Dropdown -

i have simple website has select menu. when select usa in dropdown secondary dropdown appears called state . when select georgia should show georgia entries, however, doesn't work. can show me how fix bug? demo: http://jsfiddle.net/28zwwwsw/ jquery('#cat').change(function () { var val = jquery(this).val(); jquery("#statecat").toggle(val == "usa"); if (val == "0") jquery('#countries_select').siblings('div').show(); else { jquery('form').siblings('div').hide(); jquery('.' + val).show(); } }); jquery('#statecat').change(function() { jquery('.state1').hide(); if(jquery(this).val() == '0'){ jquery('.state1').show(); }else{ jquery('.' + jquery(this).val()).show(); } }); jquery("#countries_select select").change(function(){ i

html5 - JQuery Mobile data-role initialization on a included html -

i have parent.html in 1 of including child.html: $("#mydiv").load("child.html"); the problem here mobileinit called @ parent. child.html had div data-role. is there way force data-role attribute rendered in child.html? mobileinit event triggered once in jquery mobile application lifecycle. if load additional content must manually trigger pagecreate event instead. $("#newpage").trigger('pagecreate'); where "newpage" name of page loaded inside child.html

multithreading - C++11 std::thread accepting function with rvalue parameter -

i have homework, , have troubles understanding, (probably) how passing parameters std::thread constructor works. assume following code (i deleted unneeded parts) template<typename t, typename task> class scheduler { private: typedef std::unordered_map<std::size_t, t> results; class solver { public: solver(task&& task) : m_thread(&solver::thread_function, std::move(task)) { m_thread.detach(); } solver(solver&& solver) = default; // required vector::emplace_back ~solver() = default; private: void thread_function(task&& task) { task(); } std::thread m_thread; }; public: scheduler() = default; ~scheduler() = default; void add_task(task&& task) { m_solvers.emplace_back(std::move(task));

arduino - How to detect which way and how fast a ball is rolling? -

opinion time. have large ball use controller. i detect way ball rolling , how fast going using arduino , sensor board. thinking of maybe imu, maybe gyro , accelerometer work? i have issue sensor moved around lot, , possibly upside down sometimes, because: ball. what think best approach follow this? thanks!

android - Using Observable.interval() to advance time for "time blocks" stored in an array -

new rxjava - looking feedback. scenario: have list of time blocks of various lengths (i.e 1 5 minutes long, 30 seconds, etc). use observable.from create observable: timeline = observable.from(timeblocks); i'd mix interval observer, observable<long> intervalobs = observable.interval(1000, timeunit.milliseconds); progress through time each time block in sequence. if first time block's duration 5 minutes , 5 minutes have passed move on next time block in sequence. some other details: the list can change (i'm not sure best way deal using rx) block can added/removed/have duration changes/re-ordered. timer needs able pause/stop other components need tap stream (to update ui example) right have after trying several approaches seems work seems inefficient , looks wrong (i subscribe when time starts , unsubscribe when pausing/stopping): intervalobs .subscribe(new subscriber() { @override public void oncompleted() {

apache - MAMP on OSX Yosemite - Virtual host name gives 404 error -

i installed mamp v3.2.1 on new macbook pro running osx yosemite (10.10.3). localhost running expected, can browse http://localhost , no problem. however, amiss named virtualhost - when browse site 404. edit: i'm seeing 'this webpage not available - err_connection_timed_out' (in chrome) i've read , checked other threads on similar issues, none of them has far resolved issue. i'm hoping can me, i'm totally stuck. here's i've done , tried: in /private/etc/hosts 127.0.0.1 mysitename.dev ::1 mysitename.dev and in /applications/mamp/conf/apache/httpd.config , uncommented include virtualhosts file in extra/httpd-vhosts.conf and added directive in vhosts file so: namevirtualhost *:80 <virtualhost *:80> documentroot "/applications/mamp/htdocs" servername localhost </virtualhost> <virtualhost *:80> documentroot “/users/myname/sites/mysitename“ servername mysitename.dev serve

using Oracle SQL - regexp_substr to split a record -

i need split record column cmd.num_mai may contain ',' or ';' . did gave me error: select regexp_substr (expression.num_mai, '[^;|,]+', 1, level) (select cmd.num_cmd, (select comm.com comm comm.cod_soc = cmd.cod_soc , comm.cod_com = 'url_dsd') cod_url, nvl (contact.nom_cta, tiers.nom_ct1) nom_cta, nvl (contact.num_mai, tiers.num_mai) num_mai, nvl (contact.num_tel, tiers.num_tel) num_tel, to_char (sysdate, 'hh24:mi') heur_today cmd, tiers, contact ( (cmd.cod_soc = :cmd_cod_soc) , (cmd.cod_eta = :cmd.cod_eta) , (cmd.typ_cmd = :cmd.typ_cmd) , (cmd.num_cmd = :cmd.num_cmd)) , (tiers.cod_soc(+) = cmd.cod_soc) , (tiers.cod_trs(+) = cmd.c

c++ - Getting the IP address of a received message in boost -

how can retrieve ip address boost when receive udp message(using boost::asio::ip::udp)? thanks! you can using boost::asio::ip::udp::socket::async_receive_from() or boost::asio::ip::udp::socket::receive_from() functions, have endpoint_type & sender_endpoint output parameter. returned endpoint can used resolve sender ip address.

How can I save my Azure sql database as an mdf file? -

Image
i using azure mobile services , want export database mdf file can use in (test) applications expect mdf. how can it? another way can ui export database .bacpac file. download bacpac storage account exported to. import bacpac local machine through ssms. access mdf file right-click on database , under database properties, see location of mdf file let me know if helps, vin

objective c - Convert double to NSNumber keeping decimal part even if there are 0s -

i download json data has inside price, price gets downloaded double example if have 10.50 value assigned variable 10.5, how can keep 0 after first decimal number? this code used create nsnumber: nsnumber *numprice = jsonelement[@"price"]; //the json 10.50 numprice becomes 10.5 nsnumberformatter *formatter = [[nsnumberformatter alloc] init]; [formatter setnumberstyle:nsnumberformatterdecimalstyle]; [formatter setmaximumfractiondigits:2]; [formatter setroundingmode: nsnumberformatterroundup]; nsstring *numberstring = [formatter stringfromnumber:numprice]; for output purposes can set nsnumberformatter to have 2 decimal digits like [formatter setminimumfractiondigits:2]; [formatter setmaximumfractiondigits:2]; this displaying 2 decimal numbers. internally nsnumber stored of course single digit, if possible.

java - How to build CLM in android -

i building clm in android, .mk file this local_path := $(call my-dir) include $(clear_vars) opencv_install_modules:=on local_module := sample_clm_so_file file_list := $(wildcard $(local_path)/*.cpp) local_src_files := $(file_list:$(local_path)/%=%) file_list1 := $(wildcard $(local_path)/users/caffe/caffe-android-lib/boost-for-android/build/lib/*.a) local_src_files := $(file_list1:$(local_path)/%=%) local_cpp_includes := /users/caffe/caffe-android-lib/boost-for-android/build/include/boost-1_55/boost local_cpp_includes := /users/caffe/caffe-android-lib/opencv2/jni/include include $(build_shared_library) the .so file generated .o file isn't. i got answer build clm in android using androidndk. in application.mk file did mistake didnt add cpp_flags -std=c++11. my application.mk file this app_stl := gnustl_static app_cppflags := -frtti -fexceptions -std=c++11 app_abi := armeabi-v7a app_platform := android-9 finally build generation clm

java - EJb, direct ServerSocket or any other implimentation -

i working on chatting website project provide similar features yahoo messenger chat rooms... multiple clients connect central server , chatting(communication) , file sharing(if possible) take place. did bit of research , came out following choices: for client use either winforms or wpf c# and server confused between, direct servesocket based application deployed on vpn or dedicated server, or ejb based something, or other technology may suggest suitable this. kindly keep somethings in mind: 1. should scalable enough able sustain 100 - 1000 1,00,000 clients 2. server should serve android app client end. 3. deployment details requested

javascript - Is it possible to highlight part text of input button value? -

i'm trying bold part of text inside input button value. html doesn't work inside value attribute, tags <b> , <strong> , methods bold() won't work. is possible bold part of text? using input of type button , adding html value won't work, can use button element instead <button><strong>hello</strong> kitty</button> fiddle

javascript - How can I wrap jQuery Justified Gallery in an Ember Component? -

i'm trying wrap plugin justified gallery in ember component. main problem i'm facing list of photos in gallery come api, they're part of model. have far: app.justifiedgallerycomponent = ember.component.extend({ _init: function() { this.$().justifiedgallery({ rowheight: 150, fixedheight: false, margins: 7 }); }.on('didinsertelement') }); template {{#each photo in items}} <div> <img src={{photo.thumburl}} /> </div> {{/each}} but can't work, because list of photo inside each loop, , when plugin applied photos still not in dom? approach problem? thanks! edit: taking reference component masonry i've got sorted, first time navigate url nothing shows, if go second route (inside ember app) , go gallery displays fine , justified. component now: import ember 'ember'; var getoptions = function (keys) { var properties = this.getproperties(keys); objec

c# - XML Parsing Error: not well-formed error -

i trying parse database feed data xml, on client side keep getting error: xml parsing error: not well-formed location: http://localhost:12736/test.aspx line number 7, column 26: <publication date>29/04/2015 09:40:53</publication date> ------------------^ i have tried converting datetime parameter 'activatedate' string, still getting same error on 'publication date' node. have tried looking online solution still unable solve this. here server code further reference: response.clear(); response.contenttype = "text/xml"; using (xmltextwriter xml = new xmltextwriter(response.outputstream, encoding.utf8)) { xml.formatting = formatting.indented; xml.indentation = 4; xml.writestartdocument(); xml.writestartelement("items"); foreach (datarow ofeeditem in dt.rows) { // datetime dtt = datetime.parse(ofeedite

php - Can't use DB Transactions in Controllers in laravel (DB::beginTransaction) -

i have doctorscontroller has store method. i'm testing method , want models not insert data in testing environment. i'm using db::begintransaction , db::rollback() , db::commit() methods in controllers , testing method prevent insert queries. problem => database having records while tests running. don't want inserts during tests. my test code : public function teststoremethod() { /* * test when validation fails */ $data = include_once('doctorscontrollerformdata.php'); foreach($data $item){ db::begintransaction(); $response = $this->call('post', 'doctors', $item); $this->assertresponsestatus(400, "response's http code not 400 : " . implode('\n',array_flatten($item))); log::debug($response); db::rollback(); } } my doctorscontroller code snippet : (which calls userscontroller's store method) public function store() { //some

grafana - Posting graphite events to Hosted Graphite -

i'm using hosted graphite , trying add deploy events grafana dashboard. first attempted use method described here . the metric added graphite simple line @ end of deploy script: echo "$hostedgraphite_api_key.events.$environment.api.deploy 1" \ | nc -uw0 carbon.hostedgraphite.com 2003 i can show data points in simple graph, using annotations feature "regular metric query" doesn't seem adding graphs. i'm more interested in using real events, based on: http://obfuscurity.com/2014/01/graphite-tip-a-better-way-to-store-events . should allow tag event with, example, commit hash or git tag. unfortunately, can't find in hosted graphite documentation how these data graphite. can't find in graphite docs . despite lack of docs, tried posting few endpoints, hoping lucky. of these returned 404: https://${hostedgraphite_api_key}@www.hostedgraphite.com/api/v1/events https://${hostedgraphite_api_key}@www.hostedgraphite.com/api/v1/sink/event

c# - How can i get the correct information to display in my listbox? -

i have 2 listboxes can move exercises available list of exercises list of selected exercises specific user. current problem selected list (aka regimeitems) shows exercises of users. i believe problem lies in chosenexercises(at bottom of controller) getting null reference exception at: var regimeids = model.savedrequested.split(',').select(x => int.parse(x)); controller.cs [httpget] public actionresult exerciseindex(int? id, userexerciseviewmodel vmodel) { user user = db.users.find(id); user.regimeitems = chosenexercises(); userexerciseviewmodel model = new userexerciseviewmodel { availableexercises = getallexercises(), requestedexercises = chosenexercises(user, vmodel) }; user.regimeitems = model.requestedexercises; return view(model); } [httppost] public actionresult exerciseindex(userexerciseviewmodel model, string a

google play - Android Wear app. This app is incompatible with your device -

i published app wear devices, watch face, don't have ui phone app. uploaded google play. says app incompatible device. users or devices. anyone have idea? since android wear application in sync handheld device, needs have corresponding application in handheld device. let me make little more clear: install on android wear, need have corresponding application mobile, sync corresponding wear part , install same on wear. so go ahead develop dummy kind of application handheld.

meteor - Reinitialize library when new data is available -

i'm developing meteor application use video.js-library. i have following template: template(name='foo') .video.embed-responsive.embed-responsive-16by9 richmediacontent video#video.video-js.vjs-default-skin.vjs-big-play-centered(controls='' preload='auto') source(src='{{video.videourl}}' type='video/mp4') p.vjs-no-js {{i18n 'videotagnotsupported'}} initializing video.js-library after template rendered works fine. template.foo.onrendered -> videojs document.getelementsbyclassname('video-js')[0], {} but videojs-library not reinitialized if same template rendered different video (with different richmediacontent). i've tried move video-part in own template , included in foo-template onrendered-call should called every time new video loaded. doesn't seem work. do have idea how can reinitialize library if video changes? thanks in advance! new answer indeed, when

c# - How to prevent postback from asp.net linkbutton -

asp: <asp:linkbutton id="lbsave" onclick="lbsave_click" runat="server">save</asp:linkbutton> html: <a id="contentmain_lbsave" href="javascript:__dopostback(&#39;ctl00$contentmain$lbsave&#39;,&#39;&#39;)">save</a> code-behind: public void lbsave_click(object sender, eventargs e) { if (strp != "") { scriptmanager.registerstartupscript(this.page, typeof(page), "diffuser", "showdiffuser();", true); } else { //do else... } } jquery: function showdiffuser() { $("#dvhide").fadein("slow"); $("#backoverlay").fadein("slow"); } when click button, want page not postback , run jquery function. instead, when click link refreshes page , executes jquery function. how can prevent postback. i tried following: onclientclick='javascri

Undefined Index for Valid key from array in PHP -

while parsing csv file(i have used class found on google), ran problem. here example of array made .csv file(print_r): array ( [0] => array ( [site] => viralnova [impressions] => 104719 [ctr] => 0.30% [clicks] => 311 [average cpc] => $ 0.400 [cpm] => $ 1.19 [conversion rate] => 1.29% [actions] => 4 [cpa] => $ 31.100 [spent] => $ 124.40 ) [1] => array ( [site] => tmz - desktop [impressions] => 103276 [ctr] => 0.29% [clicks] => 295 [average cpc] => $ 0.400 [cpm] => $ 1.14 [conversion rate] => 0.68% [actions] => 2 [cpa] => $ 59.000 [spent] => $

objective c - How to add box around NSString inside NSTextView -

Image
i'm working on os x application , i'm pretty stuck @ this. have text inside nstextview , put box around strings (i have ranges substrings). any ideas? also, perfect solution create similar xcode has, when type example [nsstring stringwithformat: (nsstring *), ..)]; screenshot: i'm interested in blue box suggests type expected. appreciated! this question not entirely related possible duplicate question, since working on ios application different approach. i'm pretty sure xcode achieves these effects using nstextattachment objects embedded within nsattributedstring instances. (the same sort of effect can seen in nstokenfield control, uses approach). it's pretty big topic though: need proficient attributed strings, text attachments, nstextattachmentcell class , few other bits , pieces cocoa's text architecture. job made more difficult fact there's little documentation (official or unoffical) doing sort of thing.

php - How can i pass two different variables to View -

how can pass 2 different variables view controller(i using codigniter framework). my fist variable has data records, , second variables has images data. $dirname = "uploads/"; $images = glob($dirname."*"); // second variable. $this->load->view('includes/template',$data,$images); // not working. it should be $dirname = "uploads/"; $data['images'] = glob($dirname."*"); // second variable. $this->load->view('includes/template',$data); you asccess variable in view using $images

How to do case insensitive regex on an Nginx server? -

a serious problem happened after migrating server ubuntu debian. debian won't allow 2 files, example " a.html " , " a.html " in same directory. my server gets 3 types of requests , current status: requests such /archive/2014/www.test.com supplied file: /archive/2014/blank.html requests such /archive/2015/test.com , /archive/2015/www.test.com supplied file /archive/2015/t.html requests such /archive/2015/test.com , /archive/2015/www.test.com supplied file /archive/2015/t.html i want last 2 types of requests supply file /archive/2015/t.html in both cases (in case insensitive way). how achieve outcome? the current server settings are: server { listen 127.0.0.1:80; server_name 127.0.0.1; access_log /srv/siteone/logs/access.log; error_log /srv/siteone/logs/error.log error; location / { root /srv/siteone/html; index index.html index.htm; expires 1d; } rewrite ^/archive/2014/(.+)$ /ar

android - Now Playing Card -

i need displaying playing card in recommendations row. read post in android developers site, did not me much. i have service streams mp3 data without problems. added following code, there's no playing card... @override public void oncreate() { log.i(tag, "oncreate called"); msession = new mediasession(this, "musicservice"); msession.setcallback(new mediasessioncallback()); msession.setflags(mediasession.flag_handles_media_buttons | mediasession.flag_handles_transport_controls); msession.setactive(true); } private class mediasessioncallback extends mediasession.callback { } edit: added code meta-data: @override public void oncreate() { log.i(tag, "oncreate called"); msession = new mediasession(this, "musicservice"); msession.setcallback(new mediasessioncallback()); msession.setflags(mediasession.flag_handles_media_buttons | mediasession.flag_handles_transport_contr

C# multilevel json array parsing -

i'm having trouble parsing json string. can jobject or jarray fine , use json.net's serialize method dynamic object. problem need in model object rather loose guess. format specific json same except entries few nodes missing. the dynamic object i'm getting after parsing (from the path of exile api ): type: array isreadonly: false hasvalues: true first: { "id": "standard", "description": "the default game mode.", "registerat": null, "event": false, "url": "http://www.pathofexile.com/forum/view-thread/71278", "startat": "2013-01-23t21:00:00z", "endat": null, "rules": [] } last: { "id": "aug 12 3h hc race", "description": "a 3 hour hc race event prizes. see beta status forum details.", "registerat": null, "event": false, "url": null, "startat":

php - Calling Array Function -

how create input argument , call function defined below? function insert_data ($var) { $set_entry_array = array( array('name' => 'name' ,'value' => $var['phone']), array('name' => 'email' ,'value' => $var['circle']), array('name' => 'assigned_user_id' ,'value' => 1), ); } i want call function pass actual value in name , email parameter. your function accepts array. need define array, , pass function. appears function expects 2 array keys set: phone , circle . need set them. $myarray = array(); $myarray['phone'] = '555-1234'; $myarray['circle'] = 'foo@bar.com'; insert_data($myarray);

javascript - Vertical grid lines for fullcalendar -

Image
i'm using fullcalendar.io wonder, how can make show vertical grid, table lines? i added css style horizontal lines visible. how same thing vertical ones? make css class like: .fc .fc-agendaweek-view .fc-bg tr > td{ border: 2px solid grey; } the vertical lines in .fc-bg (background) table of fullcalendar.

php - HTML Forms two actions -

so have form action link verifies user's username , password (can't post link not belong me) , if it's correct gives me "ok" or else "no" how can make in way if yes directs me index page , if no gives error or reloads page or something. way general html appearance is: <form method="post" action="https://***************/login"> <label for="book">username:</label> <input type="text" name="username" id="username" placeholder="enter username"> <label for="course">password:</label> <input type="password" name="password" id="password" placeholder="enter password"> <input type="submit" value="log in"> </form> so if change way want action should change verify.php have appearance of <?php # how use if link usin