Posts

Showing posts from June, 2012

python - Variable Explorer in Jupyter Notebook -

Image
is there variable explorer in jupyter (ipython) in spyder? uncomfortable having print list of variables time each time run through test code. has feature been implemented yet? if so, how enable it? update scroll down section labeled update less convoluted method. old answer here notebook on how make own variable inspector . think written when jupyter notebook called ipython notebook works on latest version. i'll post code below in case link breaks. import ipywidgets widgets # loads widget framework. ipython.core.magics.namespace import namespacemagics # used query namespace. # example, hide these names, avoid polluting namespace further get_ipython().user_ns_hidden['widgets'] = widgets get_ipython().user_ns_hidden['namespacemagics'] = namespacemagics class variableinspectorwindow(object): instance = none def __init__(self, ipython): """public constructor.""" if variableinspectorwindow.instance not

issues in buiding Slate with Docker -

i have tried build slate using docker, modified changes not affected when compile source. in source path have below files. dockerfile from debian:latest maintainer fed volume /usr/src/app/source expose 4567 run apt-get update && \ apt-get install -y ruby git ruby-dev make gcc zlib1g-dev nodejs && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* run gem install bundler run git clone https://github.com/tripit/slate.git /slate workdir "/slate" run bundle install cmd ["bundle", "exec", "middleman", "server", "--force-polling"] docker-compose.yml slate: build: . ports: - 4567:4567 volumes: - ./source:/slate/source - ./build:/slate/build makefile .phony: build build: docker-compose build up: docker-compose compile: docker-compose run slate bundle exec middleman build --clean when tried make compile output shows docker-compose run slate bundle exec middleman build -

android - Can't run monkeyrunner recorder -

Image
i'm trying use monkeyrunner project. understood there 2 basic scripts that: monkey_recorder.py: https://android.googlesource.com/platform/sdk/+/ics-mr0/monkeyrunner/scripts/monkey_recorder.py monkey_playback.py: https://android.googlesource.com/platform/sdk/+/ics-mr0/monkeyrunner/scripts/monkey_playback.py so, monkey_recorder.py recording actions , , monkey_playback.py reproducing these actions . i found here , can run recorder line: ./monkeyrunner monkey_recorder.py i tried execute command directory: /users/user/programs/android-sdk-macosx/tools and got error: imac-developer-2:tools user$ ./monkeyrunner monkey_recorder.py can't open specified script file usage: monkeyrunner [options] script_file -s monkeyserver ip address. -p monkeyserver tcp port. -v monkeyserver logging level (all, finest, finer, fine, config, info, warning, severe, off) so, expected, window opened: os: os x yosemite, v10.10.5 please, me solve

linux - Gnu sort: stray characters in field specification -

sort doesn't seem key specification. why? ~/tmp $ sort --version sort (gnu coreutils) 8.25 packaged cygwin (8.25-1) ~/tmp $ echo 'a;b;c;d;e;f;g'|sort --field-separator=';' --key=1,5,2 sort: stray character in field spec: invalid field specification '1,5,2' from man page: -k, --key=keydef : sort via key; keydef gives location , type keydef f[.c][opts][,f[.c][opts]] start , stop position, f field number , c character position in field; both origin 1, , stop position defaults line's end. since .c , opts part in keydef optional, key specification f,f,f (i.e. field numbers) should correct. did wrong? btw, environment cygwin, running z-shell. the 2 fields in -k arg start , end fields. can specify -k number of times, sort on multiple keys. so, -k 1,1 -k 2,2 -k 3,3 sort first on field 1, field 2 field 3.

hadoop - How to subtract months from date in HIVE -

i looking method helps me subtract months date in hive i have date 2015-02-01 . need subtract 2 months date result should 2014-12-01 . can guys me out here? select add_months('2015-02-01',-2); if need go first day of resulting month: select add_months(trunc('2015-02-01','mm'),-2);

spark process tracking with 'groupByKey' -

i log spark process. assume code 'groupbykey' spend time lot, no way check out. way check how 'groupbykey' function flows in app? if want monitor flow best solution spark web ui : https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-webui.html

aws lambda - DynamoDB indexing on payload -

this question has answer here: indexing on nested field 1 answer my dynambodb row item looks this: (it given me) { "id":"123456", "date_time":"01062016 143212", "payload":{ "type":"a", "value":"temp value", } } i added indexes on id + date_time. how can add index on payload.type ? thanks dynamodb doesn't support indices on nested fields inside map . see official documentation improving data access secondary indexes in dynamodb . the key schema index. every attribute in index key schema must top-level attribute of type string, number, or binary. other data types, including documents , sets, not allowed.

javascript - ESLint prefer-arrow-callback error -

i've got problem eslint here function: $productitem.filter(function (i, el) { return el.getboundingclientrect().top < evt.clienty }).last() .after($productitemfull) and here eslint tell me: warning missing function expression name func-names error unexpected function expression prefer-arrow-callback how solve error? it saying use arrow function syntax in filter callback function. $productitem.filter((i, el) => el.getboundingclientrect().top < evt.clienty) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .last() .after($productitemfull); here's eslint documentation prefer-arrow-callback says arrow functions suited callbacks, because: this keywords in arrow functions bind upper scope’s. the notation of arrow function shorter function expression’s. and, in following cases error thrown /*eslint prefer-arrow-callback: "error"*/ foo(function(a) { ret

ios - SpriteKit SKCameraNode unable to animate zoom -

for ios game using spritekit. have camera node in scene. var cam = skcameranode() self.camera = cam //this works, view zoomed out 2x cam.setscale(2) //i want animate zoom out, doesn't work let zoomoutaction = skaction.scaleto(2, duration: 1) cam.runaction(zoomoutaction) i fixed it, added line: self.addchild(cam) var cam = skcameranode() cam.position = cgpointmake(size.width/2, size.height/2) self.addchild(cam) self.camera = cam

java - How can I continue the test flow even if the element cant be located in Selenium? -

i getting input data excel sheet, iterate rows using for-loop. if suppose element not found, flow stops. want continue flow taking screenshot @ page failed move on next. i tried using below method: @aftermethod public void teardown(itestresult result) { if (itestresult.failure == result.getstatus()) { try { takesscreenshot ts = (takesscreenshot) driver; file source = ts.getscreenshotas(outputtype.file); fileutils.copyfile(source, new file("d:\\screenshot" + result.getname() + ".png")); system.out.println("screenshot taken"); } catch (exception e) { system.out.println("exception while taking screenshot " + e.getmessage()); } } } i input separate class, how can continue for-loop without interrupting flow of loop. hope made clear. thanks in advance. try catch need inside loop , if catches take screenshot , continue next element i

ruby on rails - Bundle install still not working after gem install bundler -

i tried using bundle install got error 'command not found.' tried gem install bundler then tried bundle install, still got same error, 'bundle: command not found.' for reference: rubygems environment: - rubygems version: 2.5.1 - ruby version: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15] - installation directory: /usr/local/opt/gems - user installation directory: /users/willashley23/.gem/ruby/2.3.0 - ruby executable: /usr/local/opt/rbenv/versions/2.3.1/bin/ruby - executable directory: /usr/local/opt/gems/bin - spec cache directory: /users/willashley23/.gem/specs - system configuration directory: /usr/local/opt/rbenv/versions/2.3.1/etc - rubygems platforms: - ruby - x86_64-darwin-15 - gem paths: - /usr/local/opt/gems - gem configuration: - :update_sources => true - :verbose => true - :backtrace => false - :bulk_threshold => 1000 - remote sources: - https://rubygems.org/ -

angularjs - show validation for my login form if no already exist in backend -

i'm using directive populating front-end validation if number present in back-end shows validation every number, whether it's present in back-end or not. below code sample: html <div class="col-xs-8"> <md-input-container> <md-icon md-svg-icon="assets/images/device.svg"></md-icon> <input type="number" placeholder="enter user mobile no" name=mobile" id="mobile" ng-model="mobile" required minlength="10" ng-pattern="/^[789]\d{9}$/" phone-number-validator> <div ng-messages="myform.mobile.$error"> <div ng-message="required">registered mobile no.</div> <div ng-message="phonenumber">the mobile no entered has been registered</div> <div ng-message="test">too short</div> </div> </md-input-container>

javascript - How to extract data from url fetch response -

i implemented fetch method using google script , returns me following log: [16-06-10 14:06:03:942 eest] { "accesstoken": "data", "userid": 3096, "created": "2016-06-10t05:06:03.799-06:00" } does know how can extract value accesstoken ? here gs code: var url = "https://example.com" var payload = { 'username' : "user", 'password' : "pass", } var options = { 'method' : 'post', 'payload': json.stringify(payload), }; var urlresponse = urlfetchapp.fetch(url, options); logger.log(urlresponse); //this returns me log shown above basically want add "data" value accesstoken variable getdata . i think if variable urlresponse object return string value. should try that: var data = json.parse(urlresponse.getcontenttext()); logger.log(data.accesstoken);

checkbox - Setting CheckBoxes from another userform in VBA -

i have userform contains number of checkboxes 1 100. have written simple code when submit form creates binary string represents state of 100 checkboxes, 0 false , 1 true. code here: private sub busrulessubmit_click() dim mybinarystring string dim nm string dim c control busruleidx = 1 100 nm = "checkbox" & busruleidx set c = controls(nm) if c.value = true mybinarystring = mybinarystring & "1" else mybinarystring = mybinarystring & "0" end if next msgbox mybinarystring end sub i want open userform form, have similar binary string, , use string set values of checkboxes true or false appropariate. having issues when setting control. code here: private sub populatebusrules() dim c control dim mybrbinary string mybrbinary = "000000000011100000000000000000000000000000000000000000000000000000000010000000000000000000000000000" busruleidx = 1 100 nm = "businessrules.checkbox" & busrulei

android finish() vs activity.finish() -

i working on legacy code android app, , in activities when want finish activity write finish() and in other places write activity.this.finish() what difference? actvity.this transparent in activity class, because references itself, can call class method both using , not using in java

matplotlib - How do I create a bar chart that starts and ends in a certain range -

Image
i created computer model (just fun) predict soccer match result. ran computer simulation predict how many points team gain. list of simulation result each team. i want plot confidence interval, using bar chart. i considered following option: i considered using matplotlib's candlestick, not forex price. i considered using matplotlib's errorbar, since turns out can mashes graphbar + errorbar, it's not aiming for. aiming nate silver's 538 election prediction result. nate silver's complex, colored distribution , vary size of percentage. want simple bar chart plots on range. i don't want resort plot bar stacking shown here matplotlib's barh (or bar ) suitable this: import numpy np import matplotlib.pylab pl x_mean = np.array([1, 3, 6 ]) x_std = np.array([0.3, 1, 0.7]) y = np.array([0, 1, 2 ]) pl.figure() pl.barh(y, width=2*x_std, left=x_mean-x_std) the bars have horizontal width of 2*x_std , start @ x_mean-x_std , c

angularjs - remove an object from an object array in javascript -

i have object like: object {w74: object, w100: object,w12: object,w3: object} i need eleminate 1 of them have object {w74: object, w100: object,w3: object} how can remove in javascript use delete operator : var ob = {w74: {number: 1}, w100: {number: 2},w12: {number: 3},w3: {number: 4}}; console.log(ob); delete ob.w74; console.log(ob);

go - JSON encoding a zero value embedded json.Marshaler panics, would you consider this a bug? -

json.newencoder(os.stdout).encode(struct { m json.marshaler }{}) panics: panic: interface conversion: interface nil, not json.marshaler https://play.golang.org/p/vur0jjq6sf i'd explicitly state interface should marshal itself: type thing interface { json.marshaler type() string .... } would consider bug? if no, why not?

mysql - Update table if certain fields are null with related values from a different column -

i writing etl in kettle pentaho create table various sources including google analytics. so table 1 = data website joined google analytics information table 2 = duplicate data table 1 joined google analytics information my problem info on table 1 has google analytics information missing table 2 shows data google analytics on same reference_number so want lookup [reference_number] table 1 table 2 , populate table 1 columns null info on table 2 quick example edit* table 1 (main table) * *this table has index built in on website_reference number (unique)* website_reference_number ga_info_1 ga_info_2 a1 null null a2 x y table 2 (duplicates table 1) eventlabel ga_info_1 ga_info_2 a1 z z a2 x y my output should following table 1 (main table) ref_number ga_info_1 ga_info_2 a1 z z a2 x y i

sql - MySQL Insert with functionality similar to Window's default file naming -

i have table name column. name not added table add default name when new row inserted, window's functionally when creating new file. i'm trying figure out how query number suppose next in sequence. for example, if table looks this: id | name ========== 1 | new name (1) 2 | real name 3 | new name the next inserted row's name should "new name (2)". if table looks this: id | name ========== 1 | new name (2) 2 | real name or this: id | name ========== 1 | name 2 | real name the next inserted row's name should "new name". if table looks this: id | name ========== 1 | new name (2) 2 | real name 3 | new name 4 | new name (3) the next inserted row's name should "new name (1)". far able create query existing numbers ("new name" = 0) select substring_index(substr(d.name,instr(d.name,'(') + 1), ')', 1) data d d.widget_name regexp '^new[[:space:]]name[[:space:]]\\([[:digit

python tkinter display time in a windows -

i starting gui in python tkinter.and want display current time hh:mm:ss in center of windows(with big digit if possible).this app code: basic full screen windows background picture. import tkinter tk tkinter import tk, frame, both import tkinter pil import image, imagetk root = tk.tk() root.attributes('-fullscreen', 1) im = image.open('spring.png') tkimage = imagetk.photoimage(im) myvar=tkinter.label(root,image = tkimage) myvar.place(x=0, y=0, relwidth=1, relheight=1) root.mainloop() edit: by current time mean keep updating time clock add compound parameter myvar object value tkinter.center , text parameter time string. create time string add import time time_string = time.strftime('%h:%m:%s') now myvar like myvar=tkinter.label(root,image = tkimage, text = time_string, compound = tkinter.center) for further reference see: python time: https://docs.python.org/2/library/time.html#time.strftime python tkinter label : http://effbot.or

python - Normalize adjency matrix (in pandas) with MinMaxScaler -

Image
i have adjency matrix (dm) of items vs items; value between 2 items (e.g., item0,item1) refers number of times these items appear together. how can scale values in pandas between 0 1? from sklearn import preprocessing scaler = preprocessing.minmaxscaler() however, not sure how apply scaler pandas data frame. you can assign resulting array dataframe loc: df = pd.dataframe(np.random.randint(1, 5, (5, 5))) df out[277]: 0 1 2 3 4 0 2 3 2 3 1 1 2 3 4 4 2 2 2 3 4 3 2 3 1 1 2 1 4 4 4 2 2 3 1 df.loc[:,:] = scaler.fit_transform(df) df out[279]: 0 1 2 3 4 0 0.333333 1.0 0.0 0.666667 0.000000 1 0.333333 1.0 1.0 1.000000 0.333333 2 0.333333 1.0 1.0 0.666667 0.333333 3 0.000000 0.0 0.0 0.000000 1.000000 4 1.000000 0.5 0.0 0.666667 0.000000 you can same (df - df.min()) / (df.max() - df.min()) .

android - ScrollView is only showing single view inside its sub-hierarchy -

i supposed add scrollview , enable user scroll down after button. however, not showing supposed show. whatever add after button , doesn't show on device/emulator. supposed add imageview under button , seem not displaying after button . following xml: <?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:fillviewport="true"> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="1"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" androi

GNURadio: file not received when repeat option is set to 'No' -

i've built simple gnuradio project trying send simple text file (called txf.txt) containing sentence "hello everyone!". following blocks i've used: file source -> packet encoder -> gmsk mod -> throuttle -> gmsk demod -> packet decoder -> file sink block settings follows: file source: txf.txt, repeat = yes packet encoder: sample/symbols = 1, bits/symbol = 1 gmsk mod: sample/symbol = 4 file sink: rxf.txt, unbuffered = on when set repeat option in source file 'yes', "hello everyone!" repeated many times in received file, rxf.txt. however, when set repeat option in source file 'no', received file, 'rxf.txt', created contains nothing in (no matter amount of time wait before stop project). when replace text file in source , sink blocks .png photo, , set repeat option 'no', receive part of source photo (usually more 3 quarters of photo), while rest of photo never gets received (no matter how long

spring integration - Multiple @ServiceActivator methods with the same inputChannel and different signature -

i'm trying implement annotation driven event bus (e.g. guava event bus ) using spring integration. have publishsubscribechannel publish events , idea use methods annotated @serviceactivator event handlers. each method can have different signature based on event (payload) need handle. what noticed when event published, all instances of serviceactivatinghandler created serviceactivatorannotationpostprocessor called , exception each method has signature not match payload. e.g. caused by: org.springframework.expression.spel.spelevaluationexception: el1004e:(pos 8): method call: method handle(model.api.serviceavailableevent) cannot found on service.eai.testserviceactivatorimpl2 type is there way define @serviceactivator method specific payload types? that's correct, subscribers publishsubscribechannel accept same message. , if there no chance convert incoming payload expected method argument type, exception. if filter unexpected types, have use @filter

javascript - Can't able to insert data into database using jQuery & AJAX in php -

i can insert data database using pure php , mysql. can't able insert data database using jquery & ajax in php. 1 error showing ajax error: i.e please check network connection. please me solve problem. my jquery ajax code, php code, html code given below. html --- news.php <div id="error"></div> <form method="post" class="form-horizontal" role="form" name="newsform"> <div class="form-group"> <label class="control-label col-sm-2">news heading</label> <div class="col-sm-10"> <input type="text" class="form-control" id="newsheading" name="newsheading" placeholder="enter news heading"> </div> </div> <!--news heading--> <div class="form-group"> <label class="control-label col-sm-2">news source url

Invoking a java function from JSP Script tag -

i have jsp file below <script> function validateevent(){ // want call java function myprofile() here } </script> <html:select property="event" styleclass="input" onchange="validateevent();"> </html:select> all want is, call java function myprofile() validateevent() function, gets triggered on change of value in event dropdown. in regard appreciated. you can't use <script> tag execute java method server-side client. tags corresponds javascript, executed on client side, , therefore doesn't have access what's going on on server directly. if need retrieve information server, have @ called ajax.

javascript - angular material assets not loaded -

i want make fresh angular project angular material. installed bower install, imported necessary files in index.html. styles aren't applied. my index file <!doctype html> <html lang="en" ng-app="yathzee" class="no-js"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>yathzee app</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link type="text/css" rel="stylesheet" href="assets/libs/bower_components/angular-material/angular-material.min.css"> <link type="text/css" rel="stylesheet" href="assets/libs/bower_components/angular-material/layouts/angular-material.layouts.min.css"> </head> <body>

c++ - Only int input recognized is 1 -

no matter input, int recognized in function 1. if else selected, do-while loop repeats. code worked fine without or operators, e.g. "while (input != 0)" void menu() { int input = -1; { cout << " ---------------" << endl << " - ou6 -" << endl << " ---------------" << endl; cout << "1. read transaction keyboard." << endl; cout << "2. print transactions console." << endl; cout << "3. calculate total cost." << endl; cout << "4. debt of single person." << endl; cout << "5. unreliable gold of single person." << endl; cout << "6. list persons , fix." << endl; cout << "0. save , quit application." << endl; cin >> input; } while (input != (0 || 1 || 2 || 3 || 4 || 5 || 6));

asp.net - What happens first? WebAPI Routing or web.config? -

i having issues routing web.config setup redirect needed thinking maybe web api taking control of routing. so wondering order routing in web api app. if set redirect index.html on web.config web api overwrite that? 1 happens first , 1 last? 1 overwrite other? if "web.config" , referring iis rewrite module , iis rewrite module runs first. web api routing happens in order in define in route table, important define routes most specific least specific allow routes near top miss in specific cases , allow more general routes run.

actionscript 3 - Flash AS3 | Creation of a Camera / Moving Viewport / Zoom -

i looking extend on question asked earlier here: flash as3 | pan / zoom mouse input the basis solution working, looking improve process more achieve higher quality result. what asking here if me find way make 'viewport' (what displayed on screen) tied or follows object around. pointing scope of sniper rifle example, see image through hud, , see different parts of image hud moves around. alongside this, there way me implement zoom feature? guess enlarge actual displayed image itself, on great! thanks once again guys! i think 1 way achieve effect you're looking take content want have on screen , put inside movieclip. then, when have name movieclip, can adjust it's positioned it's focused around 1 object, this: holder.x = screenwidth/2 - holder.object.x; holder.y = screenheight/2 - holder.object.y; this little bit of math takes object's position relative holder movieclip , adjusts whole movieclip moved, putting spot in center. once hav

Finding an Android XML tag -

i attempting fix error "your content must have listview id attribute 'android.r.list'. i have found answer following question on stack exchange: your content must have listview id attribute 'android.r.id.list' i had applied solution, wished ask question: "then how reference android-defined xml tag? however due reputation system, unable comment small question. apologise this, can please answer question? thank in advance. for information, listview: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <listview android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content"> </listview> </l

.htaccess - Avoid Too Many Redirects on Root level 301 -

i'm attempting change .htaccess on website such each page redirects specific page on website. i've managed non-root level pages redirect new domain no problem, seem try redirect root of old website end getting 'too many redirects' problem. feels pretty key optimizing someone's site when they've changed previous domain, useful know. the code i've got working this: redirect 301 /my_counselling.html newsite.org.uk/ redirect 301 /fees_and_contacts.html newsite.org.uk//?page_id=11 redirect 301 /qualifications.html newsite.org.uk/ redirect 301 /resources.html newsite.org.uk/ redirect 301 /abuse.html newsite.org.uk/ redirect 301 /drug_and_alchol.html newsite.org.uk//?page_id=57 redirect 301 /lgbt_sexuality.html newsite.org.uk//?page_id=13 redirect 301 /dyslexia.html newsite.org.uk//?page_id=8 but following attempts match root level fail: redirect 301 / newsite.org.uk/ or rewriterule oldsite.com/ newsite.org.uk [r=301,l,nc] or redirectmatch 301 ^

java - Reading file from path in Swing in different environments -

i creating swing application in of icons , images being loaded resource folder within project. file helpicon = new file("resources/icon/helpicon.png"); this working fine in windows in linux code giving error. how should handle in different operating systems (like windows, linux, macos)? try use getclass().getresources("path")

cakephp - How to process and change output before it is sent back to the browser? -

i want implement mechanism in cakephp shortcodes in wordpress. want save pages (in db) tokens, e.g. [form id=12] and then, after view got rendered , before sent browser, want search rendered view these tokens, , replace them else. i assume i'll have use beforefilter , afterfilter or beforerender , can't find documentation (including in cakephp's own documentation!) how these overriden functions can used change output. can help?

How to Access Model Dialog Box content developed in Bootstrap using Selenium Web Driver and Java -

Image
i trying access model dialogue box (developed in bootstrap) using selenium web driver in java, unable so. here wan tot access title, content , button. one more point here xpath dynamic, every time xpath generating differently. know can solved partially matching xpath. so me solve problem. here attaching image of model box design. here code snippet here code <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <div class="bootstrap-dialog-header"> <div class="bootstrap-dialog-close-button" style="display: none;"> <button class="close"> × </button> </div> <div class="bootstrap-dialog-title" id="5f663313-d82d-4ab8-9712-6665e80a3654_title"> member registrat

java - Cannot divide a long string into pieces -

there long string- "sourcemeaning" consists of sentences retrieved sqlitedatabase. used "&" separate sentences below: sentencea&sentenceb&sentencec ..... after long string has been retrieved, string divided to: sentencea sentenceb sentencec .... i used string array (meanings) store divided sentences , applied following codes finish task, throws stringindexoutofboundsexception when executing... string sourcemeaning=c.getstring(1); log.w("sourcemeaning",sourcemeaning); string[] meanings=new string[]{}; int j=0; (int i=0;i<=sourcemeaning.length();i++){ if (sourcemeaning.charat(i)!='&'){ meanings[j]=meanings[j]+sourcemeaning.charat(i); log.w("translated",meanings[j]); } else { j+=1; } } how divide sentences without error? you should split initial string in way string sourcemeaning=c.getstring(1); log.w("sourcemeaning",sourcemeaning); string[] meaning

ajax - Put jquery with django rest api -

i trying update data via ajax jquery. when use api update data works correctly. when try use ajax put not update. $.ajax({ type: 'put', url: "/api/attend/" + this.props.id + ".json", headers: { 'authorization': "token " + token }, data: json.stringify({attend_ts: '2016-07-05t13:44:21.855910z'}), success: (result) => { console.log("success") }, error: function (cb) { cb } }); the data not update, jquery returns success @ console. i found error, set datatype: $.ajax({ type: 'put', url: "/api/attend/" + this.props.id + ".json", headers: { 'authorization': "token " + localstorage.token }, data: { report: 'test' }, datatype: "json", succ

ios - UITextfield not removing the icon even after the textfield is cleared -

Image
i have form 2 textfields , want validate type. example: have email textfield , start typing tells me whether email has been used or not. if used shows 'x' icon in textfield , if it's not shows 'check mark'. validation works fine. problem facing when try clear textfield pressing delete button(not holding down) clears textfield , shows no icon because it's empty. if try clear textfield holding down delete button, icon not disappear. here's code: emailavailable.get(["email": newstring], handler: {(result: [basemodel]?, error: nserror?) in if let available = result as? [emailavailable] { self.emailimageview.image = available[0].available ? uiimage(named: "success") : uiimage(named: "failed") } else { self.emailimageview.image = uiimage(named: "failed") } }) i making api call here check whether email valid or not.

python - Function works correctly only the first time it is called -

this question has answer here: why can't call read() twice on open file? 7 answers i have following function, second function count_forbid(a) can work 1 time. in example count right value of word not contain letter 'c' , y return zero. means code can right first time , other time return zero: import string fin = open('words.txt') def forbid_or_not(word,forb): letter in word: if letter in forb: return false return true def count_forbid(a): count = 0 line in fin: word1 = line.strip() if forbid_or_not(word1,a): count += 1 return count x = count_forbid('c') y = count_forbid('d') after iterate through file with: line in fin: it going reach end , trying re-iterate have no effect. either change function use context manager re-opens file when fun

java - How to store hex colors in an array -

how store hex colors in following table in private array? name r g b black 00 00 00 navy 00 00 80 blue 00 00 ff the names of colors stored in public enum. array should class attribute. public enum color_names { black, navy, blue } you can use enum store values you: public enum colors { black(0x00, 0x00, 0x00), navy(0x00, 0x00, 0x80), blue(0x00, 0x00, 0xff); private int red; private int green; private int blue; private colors(int red, int green, int blue) { this.red = red; this.green = green; this.blue = blue; } public int getred() { return this.red; } public int getgreen() { return this.green; } public int getblue() { return this.blue; } }

sql - Temp table - group by - delete - keep top 10 -

i have temp table 50 000 records. if group by , count, this: +--------+--------+ |grpbyid | count | +--------+--------+ | 1 | 10000 | | 2 | 8000 | | 3 | 12000 | | 4 | 9000 | | 5 | 11000 | +--------+--------+ i delete records, each id's (1,2,3,4,5) have 10 records left after deletion. so if make new group by count, have this: +--------+--------+ |grpbyid | count | +--------+--------+ | 1 | 10 | | 2 | 10 | | 3 | 10 | | 4 | 10 | | 5 | 10 | +--------+--------+ can without fetch next ? to preserve arbitrary 10 per group can use with cte ( select *, row_number() on (partition grpbyid order grpbyid) rn yourtable ) delete cte rn > 10; change order by if need less arbitrary.

asp.net mvc - How can I retrieve the username from a CAS server in c# MVC -

i have searched boards , while have found information regarding cas(central authentication service), have not found information pertaining how 1 go retrieving username cas server after redirected client application. i have followed guidelines configuring web.config file according steps on github when using dotnetcasclient.dll. below web.config code: (note: had replace server names privacy reasons) ?xml version="1.0" encoding="utf-8"?> <!-- more information on how configure asp.net application, please visit http://go.microsoft.com/fwlink/?linkid=301880 --> <configuration> <!-- cas configuration --> <configsections> <section name="casclientconfig" type="dotnetcasclient.configuration.casclientconfiguration, dotnetcasclient" /> </configsections> <casclientconfig casserverloginurl="https://mycasserver/login" casserverurlprefix="https://myc

How can I open with VBA a attachment of excel file and verify inside the file before seva the message in a determined folder in outlook? -

i receive determined e-mails attached excel file , need know if email part of process before moving determined folder. the macro starts when email arrives. the macro verifies if email has excel attachment. if it's excel file, macro verifies if inside file first cell contains word "process". if true, macro moves email determined folder in outlook. i can first , second step, don't know if it's possble open excel file attachment , verify first cell. called rule. sub test1(o outlook.mailitem) dim xl excel.application if instr(1, o.attachments(1), ".xls") > 0 set xl = new excel.application xl.visible = 1 ' save attachment here strattachmentname xl.workbooks.open strattachmentname if xl.activeworkbook.worksheets(1).range("a1").value = "processing" o.move application.getnamespace("mapi").getdefaultfolder(olfolderinbox) end if

ios - Hiding a UILabel from a UITableViewCell doesn't resize the contentView -

i'm trying create dynamic uitableview cell can expand/collapse user selects cell . - (void)setupcell:(dynamictableviewcell *)cell atindexpath:(nsindexpath *)indexpath { cell.label.text = [self.datasource objectatindex:indexpath.row]; cell.secondlabel.text = [self.datasource objectatindex:self.datasource.count - indexpath.row - 1]; if ([self.isvisible[indexpath.row] isequal:@no]) { cell.secondlabel.hidden = yes; } else { cell.secondlabel.hidden = no; } } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { return 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return self.datasource.count; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { dynamictableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; [self setupcell:cell atindexpath:indexpath]; re

html - Work with bindings in angular components -

Image
hi i've use different angular components in code. 1 of input helper number fields in web application. important: please read description step step understand, because it's hard describe problem, gave best this. :) i have component has tag <input-helper></input-helper> , loads template of component. can put around random input in html , adds div in form of button on right side of input. have binding in component, pass throught value input (if there some) or update value, when it's clear , type component. looks this: <input-helper-addon current-value="inputvalue"> <input type="number" ng-model="inputvalue"> </input-helper-addon> in controller of input helper component have follow binding, catch value of input above, transcluded: static componentoptions = { transclude: true, bindings: { currentvalue: "=" } } in template of input helper component have this: <div cl

linux - `du -sh` produces different results on different machines for the same folder -

i used rsync sync 1 machine machine(so think should same folder containing same set of files--and contain files) when du -sh on original machine, produces: 4.0m . but on computer, produces: 3.5m . when ls -lh in folder on both machines, results same each file. i asked somebody, told me use du -bc , time results same now. the original server running "suse linux enterprise server 11 sp2" , computer running ubuntu 12.04. so seems there difference in implementation of du -sh ? or why different same set of files? du counts disk usage, not file size. differences in how filesystem allocate storages file may cause disk usage differ same set of files. some possible reasons why disk usage may differ, not exhaustive list: you use different filesystem (e.g. ext4 vs btrfs) the filesystem configured differently (e.g. different block size, journaling options, filesystem compression) allocation strategy used filesystem sparse file may appear large

html - Change style inline to css -

i have these form style inline, can't use in css because changes code when reference css in views: <style> body { background: url('http://digitalresult.com/') fixed; background-size: cover; padding: 0; margin: 0; } .form-login { background-color: #ededed; padding-top: 10px; padding-bottom: 20px; padding-left: 20px; padding-right: 20px; border-radius: 15px; border-color:#d2d2d2; border-width: 5px; box-shadow:0 1px 0 #cfcfcf; opacity: 0.8; } h4 { border:0 solid #fff; border-bottom-width:1px; padding-bottom:10px; text-align: center; } .form-control { border-radius: 10px; } .wrapper { text-align: center; } </style> @using (html.beginform("login", "account", new { returnurl = viewbag.returnurl }, formmethod.post, new { @class = "form-horizontal", role = "form"