Posts

Showing posts from January, 2013

from GAP to java or C or something -

recently discovered alogrithm pretty creates numbers prime , prefixes prime.unfortunatelly me it's written in gap,how can write code in java? digitstoint:=function(d) return sum([1..size(d)],i->10^(size(d)-i)*d[i]); end;; nestprime:=function(d) local i,k; in [1,3,7,9] d:=concatenation(d,[i]); k:=digitstoint(d); if(isprimeint(k)) print(k,"\n"); nestprime(d); fi; d:=list([1..size(d)-1],j->d[j]); od; end;; d in [[2],[3],[5],[7]] k:=digitstoint(d); print(k,"\n"); nestprime(d); od;

java - Destroy foreground notification when the service get killed -

i have foreground service download contents form web. unfortunately, due bug reported here service being killed when receiver received broadcast within service it's notification won't killed , saw following log in logcat: i/activitymanager(449): killing 11073:my-package-name/u0a102 (adj 0): remove task is there anyway to destroy foreground notification when it's parent service killed os? use stopforeground: @override public void ondestroy() { // bug seems exists android 4.4 if (android.os.build.version.sdk_int == android.os.build.version_codes.kitkat) { stopforeground(true); } super.ondestroy(); } or public void ontaskremoved (intent rootintent) { // bug seems exists android 4.4 if (android.os.build.version.sdk_int == android.os.build.version_codes.kitkat) { stopforeground(true); } }

Qt can't kill process -

in qt app run process under push-button click.the process run gnome-terminal.my problem when kill qt process run push-button click button pid,its shows error."kill: sending signal 19771 failed: no such process" still terminal running.and if kill app,but still terminal running. qprocess *p = new qprocess(this); if (p) { p->setenvironment( qprocess::systemenvironment() ); p->setprocesschannelmode( qprocess::mergedchannels ); qstring program = "gnome-terminal"; qstringlist arguments; arguments << "-x" << "bash" << "--rcfile" << "./auto.sh"; p->start(program, arguments); pid= p->pid(); } button2 cod is: qprocess::startdetached("kill -9 "+qstring(pid)); how can kill process , terminal click push-button?

javascript - How to email blocks input field like the one in gmail? -

in gmail when input email , press pace bar, email form light blue box, , can type in email separated. (similar tags in stackoverflow?) how can 1 achieve it? have looked tagit , it's no longer under active development. suggested select2 alternative, don't see how can achieve desired effect no predetermined list of accepted values (all emails should accepted!). any idea how make it? best not use jquery ui :). check out auto tokenization select2. allows users insert non predefined tags (or email adresses in case). make sure define tokenseparators , example: $("#input").select2({ tokenseparators: [",", " "]} );

c# - MVVM: Loading large data records -

as i've learned mvvm pattern there observablecollection in every viewmodel holds models. have viewmodel implemented this: public class viewmodel { public void loaddata() { items = new observablecollection(_logic.select()); isdataloaded = true; } } let's _logic.select() returns list<> of records in table. if data large? if have thousands or maybe hundred thousands of records in table? should load them in observablecollection ? takes lot of time them loaded. you shouldn't load data database, load need. think how badly hurt performance load 1000 registries if need one: you need query db. use server create , execute query , keep data somewhere, in memory. send client. client need keep data somewhere. as said before, can use server side paging and/or filtering. the logic simple, on server have "return myentity;" or method that. instead of doing it, why not implement "take" exten...

node.js - Node js read a value from json array -

async.series([ function(callback){ geen.api('openorders', function(error, data) { callback(null, data.result['open']); if(error) { console.log(error); } }); } ], function(err, results){ console.log(results[0]['ojvbce-kz7sx-snnaap'].status) // undefined }); }); returns json: [{ 'ojvbce-kz7sx-snnaap': { refid: null, userred: null, status: 'open', opentm: 1397461378.8155 } }] how acces this? example: results['ojvbce-kz7sx-snnaap'].status undefined. it's array , ojvbce-kz7sx-snnaap @ first position so: results[0]['ojvbce-kz7sx-snnaap'].status if access way show have have array formed this: var results = []; results['ojvbce-kz7sx-snnaap'] = { refid: null, userred: null, status: 'open', pent...

bash - Adding at the end of single line by matching using shell scripts -

i have shell script test.sh , content whithin shell script i'm using exec command run java command export t1= exec java -xx:+useconcmarksweepgc -xx:+printclasshistogram .. dosomething now have modify argument dymanically add " -dfile.encoding=utf-8" in solaris, , i'm using sed command to export t1 exec java -xx:+useconcmarksweepgc -xx:+printclasshistogram -dfile.encoding=utf-8 ... dosomething i;m new sed commad , it's not working can have other alternatives sed -e "s/^\(exec \java.*\)$/\1 -dfile.encoding=utf-8/" test.sh > $test.sh.tmp you can use sed: sed -i.bak '/exec java/s/$/-dfile.encoding=utf-8/' test.sh cat test.sh export t1= exec java -xx:+useconcmarksweepgc -xx:+printclasshistogram -dfile.encoding=utf-8 .. dosomething

Insert footer image in Wordpress -

i have following worpress theme ( http://alethemes.com/socha/ ) , trying insert footer image it. have tried following code in appearance -> editor -> footer.php happens text in alt="image description" displayed in footer section - no image. image source have uploaded image wordpress , have copied images link url defined in media -> media library. url in code below example of url , not actual url. </div> <footer id="footer-main" role="contentinfo"> <?php if (ale_get_option('copyrights')) : ?> <p class="copy"><?php echo ale_option('copyrights'); ?></p> <!-- footer image here --> <img src="http://mydomain.com/myimagefolder/image.format" alt="image description"> <?php else: ?> <p class="copy">&copy; <?php _e('2013. socha responsive theme. rights reserved.', 'aletheme'...

html - Displaying CDATA in XML with XSLT -

hey have xml file "course_desc" element copy/pasted value(the unit description multiple paragraphs , formatting) website want display in cdata , retain it's original formatting. <courses> <course> <course_desc> <![cdata[ course structure contains information units comprise course credit points required complete it. students must complete programme outlined below. semester enrolments subject unit availability , students must consult course coordinator prior enrolling. work integrated learning students in course have opportunity seek work integrated learning placement industry partner equivalent 1 semester of fulltime study. such placements available students have: completed prerequisite units, completed @ least 2 thirds of requirements towards degree and, have weighted average mark (wam) of 65% or higher across course, or have wam of 70% or higher 2 semesters preceding application. students meet these criteria , wish participate in work...

Making magento admin field dependent on more than one value or field? -

first of have seen question can magento adminhtml field depend on more 1 field or value? talks system/configuration fields, not looking for. i trying create form in magento backend. have dropdown dropdown values 1, 2 , 3. need field x displayed when select 1 or 2. how do ? i able display x depending on single value of dropdown, not multiple values. this how have done: $this->setchild('form_after',$this->getlayout()->createblock('adminhtml/widget_form_element_dependence') ->addfieldmap($x->gethtmlid(), $xl->getname()) ->addfieldmap($dropdown->gethtmlid(), $dropdown->getname()) ->addfielddependence($x->getname(), $dropdown->getname(), 1) ); where $x , $dropdown variables stores addfield() result you can. more fields : add more dependency: ->addfielddependence($x->getname(), $dropdown_1->getname(), $value_dw_1) ->addfielddependence($x->getname(), $dropdow...

javascript - How to add 12 to a string? -

hi have string contains url in below http://www.myurl.com/abc/asdd/asd/rwewe/saaa/all-makes?expanded=no&s=true&searchlimit=12&searchoffset=24 i storing url in js string below var backtosearch = $(location).attr('href'); //typeof(backtosearch); i want add 12 searchoffset , set cookie mycookie. $.cookie('mycookie', backtosearch , { path: '/' }); when 12 added http://www.myurl.com/abc/asdd/asd/rwewe/saaa/all-makes?expanded=no&s=true&searchlimit=12&searchoffset=36 how add 12 string? how about; url = url.replace(/searchoffset=(\d+)/, function(a, b) { return "searchoffset=" + (parseint(b, 10) + 12); })

php - Convert BLOB jumble to 0s and 1s [byte stream to binary string] -

i have blob column in mysql table. when echo value of field using php sbĎ„f¶☼╢ñ═∩p╙ _Ă« ☺k ☺♦ Ă…☼♂↔☻ ♥ is there way me convert binary string of 0s , 1s? this data not image , not text, small udp packages of data 0s , 1s have significance , need load data , interpret it i couldn't find solution this, i'm going reinvent wheel bit. function bindigitsfromstring($str) { $r = ''; for($i=0; $i<strlen($str); $i++) $r .= sprintf("%08b",ord($str[$i])); return $r; }

python - Convert a while loop to something reusable -

i find myself using pattern this: num_repeats = 123 interval = 12 _ in xrange(num_repeats): result = ... if result meets condition: break time.sleep(interval) else: raise failed despite multiple attempts basically, repeats code until correct result returned, or counter expires. although works, looks verbose me. possible "parametrize" loop reusable function or context manager, example with repeat(num_repeats, interval): code or maybe there's in standard library trick? you can use generator sleeps before returning repeated results. advantage caller still genuine loop, break , continue , else semantics still in tact. def trickle_range(num_repeats, interval): yield 0 k in xrange(1, num_repeats): time.sleep(interval) yield k k in trickle_range(num_repeats, interval): ... stuff, iterate or break ...

c# - how to run periodic tasks every 5 minutes or more frequently in windows phone 8 -

in wp8 application need download json data every 5 minutes. in msdn it's written periodic tasks run every 30 minutes. are there workarounds run periodic tasks in background every 5 minutes? there other ways of doing without periodic background tasks? currently i'm using periodic task download json data here code public class scheduledagent : scheduledtaskagent { public string url { get; set; } private static flightfornotificationdatamodel _flightfornotificationdata; private static notificationdataviewmodel _notificationdata; public observablecollection<notificationviewmodel> notifications { get; set; } /// <remarks> /// scheduledagent constructor, initializes unhandledexception handler /// </remarks> static scheduledagent() { // subscribe managed exception handler deployment.current.dispatcher.begininvoke(delegate { application.current.unhandledexception += unhandledexcept...

jquery - Caption on slider behaving incorrectly -

i have issue caption adding slider when scaling page height inconsistent. isn't sitting on page in absolute position. if add position absolute vanishes? heres code: <div style="heigt: 500px;"> <div class="callbacks_container"> <ul class="rslides" id="slider4"> <li><img src="img/businessbig.jpg" alt=""> <p class="caption">welcome ashley tate <br /> thank finding time visit our website – whether looking purchase or considering selling business here help. <br /> experience counts in business sales , principle people @ ashley tate have each been involved in business sales , acquisitions more thirty years. <br /> our approach business sales refreshingly different; our objective deliver professional advice , guidance borne out of understanding of sales process , of market place. ...

python - PyCUDA demo example error on OSX 10.9.2 + CUDA 5.5 + EDP 2.7.3 -

i'm getting pycuda runtime error (very similar 1 @ https://stackoverflow.com/questions/20078191/opencv-2-4-7-mac-osx-10-9-python-2-7-6-cuda-5-5 ) below. error when executing example is cordelia:examples xxx$ python demo.py traceback (most recent call last): file "demo.py", line 3, in <module> import pycuda.driver cuda file "/users/xxx/canopy/lib/python2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.6-x86_64.egg/pycuda/driver.py", line 2, in <module> pycuda._driver import * importerror: dlopen(/users/xxx/canopy/lib/python2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.6-x86_64.egg/pycuda/_driver.so, 2): library not loaded: @rpath/libcurand.dylib referenced from: /users/xxx/canopy/lib/python2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.6-x86_64.egg/pycuda/_driver.so reason: incompatible library version: _driver.so requires version 1.1.0 or later, libcurand.dylib provides version 0.0.0 and shows again on command line, s...

java - how to build a textfield with caption and text area in the same line Vaadin -

i implementing text field user data (new vaadin) when initialize textfield using new textfield("caption"); i using reindeer theme how can text field : caption: textarea //same line instead of caption: //different lines textarea should override default css , how it????? or there method availble this?????? you have use formlayout . formlayout fl = new formlayout(); textfield tf = new textfield("caption"); fl.addcomponent(tf); more information in vaadin book here .

javascript - Accordion Menu PlusMinus change FontAwesome - Change Class Name -

i want change plusminus added text -> fontawesome icons . need it. the code plus $(".plusminus").text('+'); that minus checkelement.parent().find(".plusminus").text("-"); jsfiddle demo add fontawesome reference , change simple text + or - plus-minus icons using fontawesome rules, like: var content = '<span class="cnt">' + count + '</span><span class="plusminus"><i class="fa fa-plus"></i></span>'; and checkelement.parent().find(".plusminus").html("<i class='fa fa-minus'></i>"); demo using fontawesome 4.0.3 : http://jsfiddle.net/irvindominin/779r7/ ref: http://fortawesome.github.io/font-awesome/get-started/

ember.js - Emberjs create a table with CollectionView -

i wanted generate table array have in controller don't understand how collectionview working. here array : app.applicationview = ember.view.extend({ accountprofile: null, // actions: { [...] //action initialize accountprofile (object) } }) my array accessible => view.accountprofile.dialinnumbers when want display on template. so have table, must respect standards : <table class="table-history"> <tr> <td class="col-left">+44734567890</td> <td> <div class="ph-img"></div> </td> <td> <div class="tr-img"></div> </td> </tr> </table> most have in <tr> tag must generated view. have first <td> change array in view. others <td> meant same every row. my problem don't know how can manage create collectionview , add different class na...

sql server - Handling files with different structure For each Loop SSIS -

there 3 files in directory , 2 of them same structure , 3rd 1 has 3 more column in end of file. file 1: columna,....,columnz file 2: columna,....,columnz file 3: columna,....,columnz,column1,column2,column3 is possible import these files using single connection in each loop container? if flat file connection connection based on file 3 . no not possible in ssis. using flat file connection designed file 3 corrupt data loaded files 1 & 2. i build 2 flat file connections different layouts, within each loop container build 2 data flow tasks 2 layouts. disable data flow tasks using expression, appropriate data flow task executes against each file.

To open settings page of chrome browser in android programmatically? -

i building android application in need open settings page of chrome browser. have researched lot didn't found satisfactory result.i have used intent default browser not working in case of chrome browser. has idea ? thankyou in advance ! chrome not appear export activity, cannot started third-party apps. even if did, behavior vary version version of chrome android. google not document or support access such activities of commercial apps, let alone chrome.

bash - Need to add mysql query in cron job -

i need add mysql query in cron job. tried suggestions here not able do. my query: mysql -u root -pitvitv -e "use tvbsadmin; show full processlist;"> /mydirectory/processlist_auto.txt. tried write script below: #!/usr/local/bin/bash /usr/local/bin/mysql -u root -pitvitv -e "use tvbsadmin; show full processlist;"> /seachange/processlist_auto.txt and added in cron job as: 05 * * * * root /mydirectory/processlist.sh please correct me if trying wrong. in advance added mysql queries in script , included in crontab. script: #!/bin/bash echo $(date >> /seachange/unassigned_count.txt) mysql -d tvbsadmin -u root -pitvitv -e "select count(*) eam_package status in (1,3);" >> /seachange/unassigned_count.txt echo $(date >> /seachange/processlist_may07.txt) mysql -u root -pitvitv -e "select time,info information_schema.processlist info !='null';" >> /seachange/processlist_may07.txt cron entr...

Finding all web elements using Ruby and Selenium -

i'm ruby , selenium webdriver noob... instead of grabbing 1 element @ time , placing variable, i'd grab of web elements @ 1 time, includes buttons, fields, etc. i've tried grabbing examples of find_elements off web it's not working, i'm doing wrong. so need grab elements of web page , how use specific one? thanks, scott forgive ignorance of ruby having field decorators or way use pagefactory in java. there several great articles , blog posts using page object model , pagefactory. may not you're looking maybe ruby has similar. the gist of pagefactory basically, creating class page , add webelement fields elements have id or name attribute. use same id/name value variable names. can use field decorators pass findby. call pagefactory.init(factory, object) in constructor , pagefactory find elements or list of elements. let's see if can give qad example can idea , research using pom. public abstract class pagebase implements wrapsdrive...

json.net - How to update JSON data object in the isolated storage of my Windows Phone 8 application -

i have listpicker item contain list of expense. on clicking it, new xaml page opened , details of expense obtained. there option edit , save. so how should update particular json data object stored in isolated storage when user clicks update button. my code here: https://onedrive.live.com/redir?resid=83f2a501543779d4%211229 thank you here code in updatexpenses.xaml.cs. please let me know going wrong. after navigation page protected override void onnavigatedto(system.windows.navigation.navigationeventargs e){ base.onnavigatedto(e); string datafromappsettings; expencesgroup data; navigationcontext.querystring.trygetvalue("selectedexpenceobject", out selectedindex); navigationcontext.querystring.trygetvalue("typeoftransaction", out transactiontype); if (transactiontype == expencesmodel.expencesgivenkey) { if (isolatedstoragesettings.applicationsettings.trygetvalue(expencesmodel...

python - Replace each variable with specific values associated to them -

for university's project i'm developing inference engine written in python , i'm trying introduce in features clips has, 1 of them variables. actually, in grammar provide way in order specify condition in rule has got variables in using '?' character. in particular, can have rule defined in way: (rule (father ?x ?y) (assert (parent ?x ?y)) supposing in working memory there these facts: (father john tom) (father john liz) (father alex mat) (father alex andrew) with defined rule assert these facts doing variable pattern matching: (parent john tom) (parent john liz) (parent alex mat) (parent alex andrew) this situation in , i'm able correctly match each variable possible values present in wm. in case create dictionary keys variables's identifier (?x or ?y) , values values present in wm associate variables (e.g {?x:[john, alex], ?y:[tom, liz, andrew]}) my question is: how can correctly dispose variables' possible values in correct manne...

c# - Remove object from List<> on condition -

i creating ant simulation program ants travel around , collect food , bring nest. when number of ants have collected food want food source disappear. have separate class antobject, foodobject , nestobject. i have 'int foodleft = 25' variable in stationaryfood class. foodobjects placed onto screen when user clicks, , added list object 'foodlist'. draw method draws objects in list. cannot figure out how make specific food object disappear when 'foodleft' variable hits 0! here draw method in stationaryfood class - public void draw(spritebatch spritebatch, list<stationaryfood> foodlist) { foreach (stationaryfood food in foodlist) { spritebatch.draw(foodimage, foodboundingrectangle, foodcolor); //draw each food object in foodlist } } and here attempted solution problem in main 'game1' class in update method if (foodlist.count > 0...

java - Android app dev, custom numberpicker for api level 8 -

i trying create custom number picker applications require minimum of api level 8, far got code, simple don't know how fix error get. the code far this: package com.example.symbol_temp; import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.view.view; import android.widget.button; import android.widget.textview; public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); integer counter=0; button add,sub; final textview display; add = (button) findviewbyid(r.id.plus); sub = (button) findviewbyid(r.id.minus); display = (textview) findviewbyid(r.id.showtemperature); add.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { counter++; display.settext( "" + c...

android - Sending GIF images to WeChat -

i working on android app in sending gif images wechat. sending image using wechatsdk problem not able see animated image, i'm getting static image instead. you can send animated gif in wechat. save gif image send image i have had mixed results method, work gif files

javascript - What is the "//= require bootstrap/affix" notation for? Is there any grunt tool that uses it? -

lately switched bootstrap-sass repository bootstrap-sass-official , noticed unfamiliar in bootstrap.js file, namely: //= require bootstrap/affix //= require bootstrap/alert //= require bootstrap/button //= require bootstrap/carousel //= require bootstrap/collapse //= require bootstrap/dropdown //= require bootstrap/tab //= require bootstrap/transition //= require bootstrap/scrollspy //= require bootstrap/modal //= require bootstrap/tooltip //= require bootstrap/popover i understand include 1 file (bootstrap.js) tells require (import) partials bootstrap directory. however, sure not part of native javascript, , couldn't find on google it. can enlighten me , tell piece of software should understand notation , reponsible building/getting partials code? or simple comment (if is.. why on earth create seperate file this?)? edit: use grunt build assets. there grunt tool uses notation or ignore , reference partials in layout? loostro, ruby on rails for, compile asset...

c# - Better way of reading and accumulating data from sql -

i'm working through possibilities of reading data c# sql, , i'm sure better ways exist. what have (fairly complex) sql select statement returns 3 columns. eg. personnel id, taskid , hoursworked what want do, populate table 2 columns , data should like: col1 | col2 --------------------- "john" | "tsk01 (2 hours), tsk02 (7 hours), tsk03 (4 hours)" "peter" | "tsk01 (4 hours), tsk03 (2 hours), tsk04 (3 hours)" so, 1 obvious way put sql statement in data reader (sorted person), iterate through , write data second table every time new person. feels cumbersome. there must easier way? it cumbersome , inefficient. there considerations here should make: do not violate atomicity of database fields. 1 piece of information per field. let database engine work before fetch data code

android - Intent.FLAG_ACTIVITY_CLEAR_TOP not working -

my application flow: login->profile->updateprofile->changepass all of activitys extends fragmentactivity when press button in changepass activity call code: intent intent=new intent(getapplicationcontext(),loginactivity.class); intent.setflags(intent.flag_activity_clear_top); startactivity(intent); so should start loginactivity , when press loginactivity application should close...but when press button login activity flow is: changepass->updateprofile->profile->login why stack not cleared ? note: i have applied these solutions not working: 1.link 2.link try following way - intent intent = new intent(getactivity(), loginactivity.class); intent.addflags(intent.flag_activity_clear_top | intent.flag_activity_new_task); intent.addflags(intent.flag_activity_no_history); startactivity(intent); finish(); for more alternatives , details check intent-flag-activity-clear-top-doesn't-deletes-the-activity-stack . post explains result co...

multithreading - Check if data available on input-port -

i have tcp-connection between server , client , i'm looking way poll input-port on server side. if there data available, should read , put list. tried putting inside thread, blocks until can read something, , not want. want thread run "in background". wondering if possible in racket. i have following code: (define in '()) (define out '()) (define data '()) (define listener (tcp-listen 8085)) (define (discover) (define (loop) (if (tcp-accept-ready? listener) (begin (let-values (((pi po) (tcp-accept listener))) (set! in pi) (set! out po) (thread (read-thread pi))) (loop)) 'done)) (loop)) (define (read-thread port) (let ((d (read port))) (set! data (cons d data))) (sleep 2) (read-thread port)) the thread procedure takes thunk run in new thread. code doing reading before second thread ever created (and ...

SQL Server - Stored procedures slow vs "Giant" script -

i have large number of stored procedures (about 200) need executed sequentially. ideally wanted create single "master" stored procedure execute each of individual stored procedures 1 after another. however, when execute master stored procedure consistently freezes after running long time. being said, if take sql code 200 individual stored procedures , create 1 giant sql script file, runs without issue. the sql code queries separate tables , inserts subset of data master "summary" table. any ideas why happen? there stored procedures take more memory? prefer keep in stored procedures manage security , updates easier. any ideas why happen? compilation. the master script compiled batch batch using statistics valid @ point. the sp compiled once @ start, , if statistics change during run - typial sequence of loads - there go. if statistical change significant during processing. stats @ teh beginning - when things compiled - totally off compare...

php - auto loading class in symfony2 -

i use bundle: http://jmsyst.com/bundles/jmsi18nroutingbundle , way explained in site occured error classnotfoundexception: attempted load class "jmsi18nroutingbundle" namespace "jms\i18nroutingbundle" in c:\xampp\htdocs\symfony\app\appkernel.php line 20. need "use" namespace? my configuration this: in app/autoload.php wrote add namespace alias: $loader->add('jms', __dir__ .'/../vendor/bundles'); and in app/appkernel.php register bundle, in section error occured when register bundle. new jms\i18nroutingbundle\jmsi18nroutingbundle(), i copy library vendor/budles/jmsi18nroutingbundle see - https://github.com/schmittjoh/jmsi18nroutingbundle/blob/master/composer.json as can see, there defined full-path namespace "autoload": { "psr-0": { "jms\\i18nroutingbundle": "" } }, try define $loader->add('jms\\i18nroutingbundle', __dir__ .'/../vendor/bu...

Print and use array element in C -

so i'm trying input array , using elements. eg: #include <stdio.h> #include <string.h> int main() { int s[100],i; for(i=0; < strlen(s); ++i) {scanf("%d",&s[i]);} printf("s[1] = %d",s[1]; } if input 12345, want return s[1], 2. know how print whole array, want 1 or more elements, , seems can't figure seemingly easy problem. for(i=0; < strlen(s); ++i) using uninitialised (indeterminate) variable can have surprising results. anyway, want element count here: sizeof s/sizeof *s . {scanf("%d",&s[i]);} always test how many elements assigned in scanf . second condition abort btw. also, if want convert 1 digit, use field length: "%1d" if input 12345, want return s[1], 2. know how print whole array, want 1 or more elements, , seems can't figure seemingly easy problem. that looks wanted read string of digits , , not numbers . use this: char digits[100]; if(scanf("%99[0-9]"...

ios - Populating Core Data into Table View -

i trying display data in custom tableview. idea in viewcontroller populate data core data entity, in viewcontroller b retrieve data core data entity , display in table view no problem. here comes problem. if delete data entity , tableview in viewcontroller b, go viewcontroller , add new item core data again, not appear in tableview when go viewcontroller b. if close , open application again, item appears there again. so problem item appear in core data after deleting item , inserting again, doesnt appear in tableview. maybe have update tableview somehow, tried [self.tableview reloaddata]; , did not help. code below. ideas??? viewcontroller a #import "listitem.h" #import "vieworders.h" #import "mainview.h" #import "order_list.h" #import "appdelegate.h" @interface listitem () @property (nonatomic, strong) nsmanagedobjectcontext *managedobjectcontext; @property (nonatomic, retain) nsfetchedresultscontroller *results; @proper...

How to append html to a website response before it reaches the browser in Java? -

recently used mac application called spotflux. think it's written in java (because if hover on icon literally says "java"...). it's vpn app. however, support itself, can show ads... while browsing. can browsing on chrome, , page load banner @ bottom. since vpn app, can control goes in , out of machine, guess appends html website response before passing browser. i'm not interested in making vpn or that. real question is: how, using java, can intercept html response website , append more html before reaches browser? suppose want make app literally puts picture @ bottom of every site visit. this is, of course, hypothetical answer - don't know how spotflux works. however, i'm guessing part of vpn, installs proxy server . proxy servers intercept http requests , responses, variety of reasons - corporate networks use proxy servers caching, monitoring internet usage, , blocking access nsfw content. as proxy server can see http traffic betwee...

javascript - How to get text from paragraghs while preserving a space at the beginning of each? -

example: <div id="input-content"> <p>1 2 3</p> <p>4 5 6 7</p> </div> if do: $("#input-content").text(); i get: "1 2 34 5 6 7" how can "1 2 3 4 5 6 7" instead? one possible way texts in array , join elements ' ' separator: $('#input-content > p').map(function() { return $.text(this); }).get().join(' '); demo: http://jsfiddle.net/y25yg/

windows 8.1 - API to check OneDrive file status -

is there api in windows 8.1 check status of onedrive file? know whether file has been replicated local disk or dummy representation of file in cloud doesn't take local disk space this information can retrieved calling storagefile.properties.retrievepropertiesasync() ( http://msdn.microsoft.com/en-us/library/windows/apps/hh770652.aspx ) method , passing "system.offlineavailability" ( http://msdn.microsoft.com/en-us/library/windows/desktop/bb787532(v=vs.85).aspx ) in list of properties retrieved. function return dictionary contain 1 of 3 possible values: 0 - not available offline 1 - available offline 2 - not applicatble (not skydrive/onedrive file)

android - Status Bar hide/show Galaxy S5 -

so have app utilizing: android:theme="@android:style/theme.notitlebar.fullscreen" i smallest cheapest phones have nice experience. push menu button , menu pops up... works great. however samsung has decided implement menu button via holding down on multitask button.... , of course folks have bought thing don't read manual hitting me saying app has no menu. so have tell them press , hold multitask button... anyway, know use different theme larger screens , show taskbar, in turn show menu option on screen, hate having different user experience because 1 vendor did stupid. have other suggestions? know there aren't ton of small screen devices out there anymore, still. any other suggestions on how best handle this?

ember.js - How to I specify a primary key for Ember Data? -

my server uses sensorid primary key on sensor model. i've tried following app.sensorserializer = ds.restserializer.extend({ primarykey: "sensorid" }); based on see in this test , it's not working. i'm getting error: error while loading route: error: no model found '0' i'm using custom adapter. response jsonp: jquery203041337518650107086_1397489458691([{"sensorid":1,"address":"xxx, yyy","latitude":"nnnn","longitude":"mmmm"... but when inspect data gets returned, it's normal array: // app.sensoradapter findall: function(store, type, sincetoken) { var url = 'http://blahblahblah/?callback=?'; var query = { since: sincetoken }; return new ember.rsvp.promise(function(resolve, reject) { jquery.getjson(url, query).then(function(data) { debugger; // data.foreach(function(s) { // s.id = +s.sensorid; // }); ember.ru...

jquery - Move Object and Viewport -

so have following code: http://jsfiddle.net/pt22r/3/ it works great i'd able move viewport while player moves can see object on side. this want have when move player left arrow key: http://i.imgur.com/klebmmn.png case 37: // add here? $div.css('left', $div.offset().left - 10); rather moving player , keeping object halfway hidden is. this should simple enough, i'm not sure call for. p.s: i'd keep overflow: hidden thanks in advance!

c# - How to prevent MS Outlook to send winmail.dat attached in a plain text email? -

Image
i'm working web service has reply email customers if error happens or if data sent not in correct format. i'm using class mapimessage send mails maked "unread" in microsoft outlook account opened in computer runs service. this code of method sends emails. private void enviarmail(string destinatarios, string cc, string bcc, string asunto, string texto, byte[] buffer, string nombrearchivo) { if (string.isnullorempty(destinatarios)) throw new argumentnullexception("destinatarios", "el destinatario de correo no puede estar vacĂ­o"); try { if (_mapi.openoutbox()) { mapimessage message = new mapimessage(); if (message.create(_mapi, mapimessage.priority.importance_normal)) { message.setsendername(settings.default.remitente); message.setsenderemail(settings.default.remitentecorreo); ...

html - How to make an image respect web page limits? -

i wanted in css javascript ok too. i have png image use menu bar put on background image. theres part of image exceeds page right. want cut out of screen instead of strectching web page , making white line appear right of background image. just in case css: position:absolute; left:2%; width:120%; top:-220px; height:700px; z-index:6; any appreciated! thank you! may set width 100% or less!

Issues deploying django-nvd3 charts on heroku -

did 1 try deploy django-nvd3 charts on heroku success? trying deploy django application using nvd3 charts on heroku whole weekend no luck. works fine in dev enviornment (ubuntu). when try push heroku, facing sorts of errors. on dev environment installed npm (this includes node.js) , later installed bower , installed django-bower; suggested on https://github.com/areski/django-nvd3 . tried different charts , work okay, no issues however, when trying push code on heroku, hitting quite few errors. fixing 1 leads others. wondering, if need add package.json (to list npm dependencies bower) , bower.json (to list bower dependencies d3, nvd3) files repo, in first place? i googled lot documentation gives gun-shot info on this(django, nvd3, bower, npm/node married together), couldn't see any note: try post heroku logs more info. bower.json given like: { "dependencies": { "d3": "3.3.6", "nvd3": "1.1.12-beta" } pa...