Posts

Showing posts from April, 2010

android - Populate ListView from SQLiteDate sorting by Distance from user -

i working on first app, , want make list pull venues database , sort them distance user positions. haven't done coding users position know there plenty of tutorials that, , can use fixed arbitrary point. what need calculating distance , using distances build list. making database scratch can use lat, long position or else, instance if addresses useful(i figured lat, long straight forward). i don't know begin not familiar sql know if there way query such thing. in terms of sorting it, database doesn't have distance column (yet, if recommend it) , need updated every time user moved. other thought convert cursor array , create distance variable way. i hope have described problem in enough detail , apologize not providing code. in advance recommending methods approach this.

android - UserRecoverableAuthException: intent not firing up -

i trying fire window application asks user give consent application access user data via googleauthutil.gettoken(). however cannot see activity fired userrecoverableauthexception. i've searched not found helpful posts resolve issue. anyone have ideas? (the "shoot2!" printed out nothing happens in logcat after that). @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); system.out.println("here!!!"); system.out.println(calendarscopes.calendar); new asynctask<void, void, void>() { @override protected void doinbackground(void... params) { try { system.out.println("hello2!"); string token = googleauthutil.gettoken(eventsactivity.this, "jdoe@gmail.com", "oauth2:" + calendarscopes.calendar); system.out.println("token"); system.out.println("hello3!"); } catch (googlepla

c++ - How to deploy boost library? -

i have used boost library (particularly, boost filesystem) project in visual studio c++ (9.0 version). boost library installed in c drive. project finished, therefore, have corresponding debug , release. now, want include particular dlls of boost filesystem debug , release, first question dlls need copy? shows many dlls filesystem. ones tried "boost_filesystem-vc90-mt-1_40.dll" , "boost_filesystem-vc90-mt-gd-1_40.dll" . since, got idea "vc90", think means visual studio 9.0? second question, if don't include these boost filesystem dlls debug or release, exe file of project still working? can please explain why happening? tried check if have boost library path somehow in environment variables, but, unfortunately not find them there. lot. p.s.: beginner in both c++ , boost. and, library using opencv, copied corresponding dlls (core, highgui , imgproc) debug , release , 1 working perfectly. you have 2 options: a. deploy boost dlls bi

android - How to read NFC tags to prevent system dialogs NFC starter list and Tags being displayed -

i working on nfc rfid tag reading application needs read nfc id number , write edittext in not main activity. nfc reading 1 of hundred functions in app. when test on panasonic dl1 cell phone , when touch nfc tag phone first time phone displays me dialog app choice handle - 2 app shown "tags" , "starter list nfc". if choose starter list nfc taken through long process of registering ic card , naming , - picking app should start automatically on when tag close. if choose tags - display "tag unknown" comment in list. application has these features , filters: <activity android:name="pl.infis.spedycja.activities.loginactivity" android:label="@string/app_name" android:theme="@style/infistheme" android:windowsoftinputmode="stateunspecified|adjustpan" > <intent-filter> <action android:name="android.intent.action.main" />

ios - Object became nil after view will appear -

following situation: i got 2 views. on firstview m display event data, on seconde can edit these data. if switch seconde view , edit value , return firstview works should. if dont change data , return back, event objecct nil. the funny part is: before switch second view user can decide(uiactionsheet) wich changes (name etc.). @ point m logging object , nil. on viewwillappear - seconde time view loads - object not nil. i changed property attribute of event object ( strong , nonatomic), when dont change object still exists.. i provide code m @ home, maybe have idea.. firstview - (void)viewdidload { [super viewdidload]; // additional setup after loading view nib. [advthememanager customizeview:self.view]; [self initviewdata]; [self editviewstyles]; } - (void)viewwillappear:(bool)animated{ [super viewwillappear:yes]; nslog(@"view appear!!"); nslog(@"eventname: %@", eventobject.name); nslog(@"userid: %@",

lab management - TFS2012 LabDefault.11 template deploy scripts fail with "Team Foundation Server could not complete the deployment task" -

i having security issues lab management , standard environments. i have tfs2012 update 2 installed in domain "devdomain". have separate build/lab machine in "devdomain" on both build controller, build agents , test controller same collection "collectiona" installed. automated builds work perfectly. i have deployment target pcs in "devdomain" , in "testdomain" (more on later). to take next level, want automatically deploy tfs build agent constructed software test rig machines; want have deployment script uninstall existing product, copy updated installer onto target pc , install it. my first foray define standard environment in "devdomain" , deployment part of lab build working within same domain. this worked. here did; the automated build (using defaulttemplate.xaml process) creates msi file want use deployment, , powershell script want run orchestrate deployment. (the script attempts run msi via msiexec unin

vb.net - How to check whether an input is numeric or not in multiple TextBoxes? -

i working on exam in programming using vb, , trying make 2 subs text input , numeric values. code 1 textbox easy, cant seem remember how multiple textboxes use sub call if sentence up. (i use handles textchange in vb control input) here code used checking 1 textbox: if not regex.match(txtregansnr.text, "^[a-å]*$", regexoptions.ignorecase).success msgbox("kun bokstaver tillatt.", , "feil") txtregansnr.clear() txtregansnr.focus() end if i have tried modify code cant work want to. put inside textchanged event handler: dim txtbox textbox = directcast(sender, textbox) if not regex.match(txtbox.text, "^[a-å]*$", regexoptions.ignorecase).success msgbox("kun bokstaver tillatt.", , "feil") txtbox.clear() txtbox.focus() end if append textboxes handles list of above handler: sub textchanged(sender object, e system.eventargs) handles txtregansnr.textchanged, txtbox1.textchanged, txtbox2

ios - How to make a custom button with highlighted -

this question exact duplicate of: how highlight uibutton subclass? 2 answers i create custom button, because want gradient button. use code implement it. @implementation custombutton - (id)initwithframe:(cgrect)frame { if((self = [super initwithframe:frame])){ [self setupview]; } //[self addobserver:self forkeypath:@"highlighted" options:0 context:nil]; return self; } - (void)awakefromnib { [self setupview]; } # pragma mark - main - (void)setupview { self.layer.cornerradius = 10; self.layer.borderwidth = 1.0; self.layer.bordercolor = [uicolor colorwithred:167.0/255.0 green:140.0/255.0 blue:98.0/255.0 alpha:0.25].cgcolor; self.layer.shadowcolor = [uicolor blackcolor].cgcolor; self.layer.shadowradius = 1; [self clearhighlightview]; cagradientlayer *gradient = [cagradientlayer layer]; gradi

node.js - Possible to evaluate an if block to more than just true or false in meteor -

i have helper function meteor template , ideally have 3 different outcomes appear. 1 correct outcome inccorect outcome , 1 if user denies access browser access location, see below: template.header.created = function() { navigator.geolocation.getcurrentposition(success_callback,error_callback); function success_callback(p){ // building latitude = 51.522206 // building longitude = -0.078305 var lat = parsefloat(p.coords.latitude); var lon = parsefloat(p.coords.longitude); if( lat >= 51.521606 && lat <= 51.522606 && lon >= -0.078805 && lon <= -0.077705 ) { session.set("locationcheck",true); } else { session.set("locationcheck",false); } } function error_callback(p){ session.set("locationcheck",false); } } as can see depends on whether callback successful or not. if trying pass more boolean logic function, should use string or number return. can acheived by: template

ios - How to correctly transliterate Cyrillic, without diacritics, using CFStringTransform? -

i trying use cfstringtransform transliterate names entered in russian safe ascii credit card processing. however, when stripping diacritics č becomes c, not transliteration. there anyway can use cfstringtransform, without diacritics? in other words, ч, should return ch, it's supposed in every standard http://en.wikipedia.org/wiki/romanization_of_russian nsmutablestring *name = [@"романчук" mutablecopy]; cfmutablestringref nameref = (__bridge cfmutablestringref)name; cfstringtransform(nameref, null, kcfstringtransformtolatin, false); //name romančuk cfstringtransform(nameref, null, kcfstringtransformstripcombiningmarks, false); //name romancuk create category nsstring , add these methods: - (nsstring *)tolatinwithdictionary { nsmutablestring *newstring = [nsmutablestring string]; nsrange range; nsstring *symbol; nsstring *newsymbol; (nsuinteger = 0; < [self length]; ++) { // take regular symbol range = nsmakera

how to change a number in xpath with any number in selenium ide -

i want text xpath , text appears in last row of table number of rows changing. i want change number 6 here number. possible? //*[@id='entire_ajax_table']/tbody/tr[6]/td/span/input last() gives access last element in sequence. //*[@id='entire_ajax_table']/tbody/tr[last()]/td/span/input

How to style internal elements of a Dart Web Component? -

i playing popover component in dart "bee" web components package ( bee ) however, can't see way of changing default styling internal elements of component. want change style of <div class="x-popover-dialog"> has rounded corners. however, if add following app's css file, gets removed time gets "out" folder. .x-popover-dialog { border-radius: 6px; } is possible, or way modify web component (or perhaps extend it)? thanks. okay, there number of factors here. first, cannot redefine class defined within component. can apply own styling component if element not specify own styles. instance, can change font-size on on 'p' elements within component. or div#someid { color: red; } cannot redefine class, or add definitions class. the fact can modify styles @ all, unless explicitly allowed, bug in web_ui. tracked as: issue 374 : support apply-author-styles. ideally, when full support implemented, not able apply own s

c# How can i sort a listview when the form loads -

i have listview (lvmap) 3 columns (map, from, to) trying write method called form loads. method should @ listview items , and sort them 2 columns "map" , "from" in ascending order, dont want sort "to" column. have written code below sorts every single column, there way leave column out of sorting procedure. thanks. private void sortlistvieworder() { lvmappings.sorting = sortorder.ascending; lvmappings.sort(); } i suggest consult following msdn article, hopeful answers question: http://support.microsoft.com/kb/319401 basically need create listviewcolumnsorter instance , add listview control. from there on article have enough information :)

dynamics nav - Role Tailored Client register custom page -

i'm working dynamics nav 2009 r2, created new page object 50011 shipment types , not appear in role tailored client, if search shipment types don't results. page not accessible via menu tree on left. i assume somehow need register new page role tailored client, , assign department in roles tree on left. can't find documentation explains how works. after creating new page should add menu suite. should open classic client, go object designer (shft + f12) , edit following menu suite: 1090 - dept - company. if isn't there, should add it. after new page accessible in rtc.

asp.net - VB.net Mouse click single cell of gridview, change backcolor and output cell position (col and row) to textbox -

i have gridview in webform , know how can select single cell anywhere in gridview using mouse click. the selected cell's background colour changes specific colour , textbox on form displays row number , column number pass parameters stored procedure. when subsequent cell selected last selected cell reverts it's original colour , new cell's background colour changed , textbox updates new cell's row number , column number. the closest i've got far selecting whole row, affects first cell of row background-wise. underline affects cells in row. protected overrides sub render(byval writer system.web.ui.htmltextwriter) each row gridviewrow in gvprogressgrid.rows if row.rowtype = datacontrolrowtype.datarow row.attributes("onclick") = "this.style.cursor='pointer';this.style.ine';this.style.backgroundcolor ='#eee'" end if next mybase.render(writer) end sub basically: in code

android - Lazy loading carousel -

Image
i fetch link of images , want put them in carousel image below. must lazy loading. prior loading images, substitute image used, after loading images (from url) replaced. there carousel codes couldn't find lazy loading one.

php - session is not started. but still displaying the error that it has already started -

Image
this question has answer here: how fix “headers sent” error in php 11 answers i included login.php , loggedin.php files in index.php. both login.php , index.php has no session_start(); , loggedin.php has session_start(); in it. but still getting following errors when open index.php: warning: session_start() [function.session-start]: cannot send session cookie - headers sent (output started @ /home/content/98/10855698/html/symp13/index.php:110) in /home/content/98/10855698/html/symp13/loggedin.php on line 2 warning: session_start() [function.session-start]: cannot send session cache limiter - headers sent (output started @ /home/content/98/10855698/html/symp13/index.php:110) in /home/content/98/10855698/html/symp13/loggedin.php on line 2 the loggedin.php follows: <?php session_start(); if (isset($_session['username'])) { echo 'you logged in

html5 - vb.net + webbrowser/webkitbrowser + collada viewer -

Image
i working on vb.net application (winforms) , task somehow import collada files(.dae) files , make them viewable inside application. what worked me this: in simple html5 webpage, used three.js, colladaloader.js , able view animation in web browser. so thought can import vb.net application using webrowser/webkotbrowser toolbox component. alas, worked in normal html browser did not inside application. the browser import in application doesn't support webgl (even webkit version doesn't support it). this instead of animation again, works fine inside web browser chrome or safari, not ie. any make possible in vb.net highly appreciated. you have use non-ie based web browser control, see post: what best web browser control use on windows form application? his geckofx link outdated think... http://webkitdotnet.sourceforge.net/ https://bitbucket.org/geckofx/ this 1 costs money: http://awesomium.com/

dsl - XText Chained Dependencies in Type Inference -

in experiments, appears xtext cannot resolve variable types when there chain of dependencies across multiple xexpression blocks. a minimal example, illustrate. have grammar: grammar eg.types.inference.typeinferenceexample org.eclipse.xtext.xbase.xbase generate typeinferenceexample "example.org/types/inference/typeinferenceexample" model: blocks += block* ; block: '{' 'name' ':' name=qualifiedname 'from' ':' ('none' | from=[block|qualifiedname]) 'block' ':' expression=xblockexpression '}' ; an interface: package eg.lib; public interface imodelblock { public void push(org.eclipse.xtext.xbase.lib.pair<string, ?> topush); } and jvmmodelinferrer: package eg.types.inference.jvmmodel import com.google.inject.inject import eg.lib.imodelblock import eg.types.inference.typeinferenceexample.block import eg.types.inference.typeinferenceexample.model

jquery - Simulate C# Lambda methods in Javascript -

i simulate c# any() method, can used determine whether if collection has matching objects based on lambda expression. i used jquery's $.grep make things easier: array.prototype.any = function (expr) { if (typeof jquery === 'undefined') throw new referenceerror('jquery not loaded'); return $.grep(this, function (x, i) { return eval(expr); }).length > 0; }; var foo = [{ a: 1, b: 2 }, { a:1, b: 3 }]; console.log(foo.any('x.a === 1')); //true console.log(foo.any('x.a === 2')); //false i know eval() bad practice obvious reasons. ok in case, since won't use related user inputs? can done without eval() ? can't figure out way pass expression function without evaluating it. http://jsfiddle.net/dggvn/ i suggest take @ js closures. in particular, did there can done natively in js using array.some method: [{ a: 1, b: 2 }, { a:1, b: 3 }].some(function(x) { return x.a === 1; }); // true [{ a:

html - Auto stretching vertical columns (divs) -

Image
check fiddle please: i want following: red column has text, yellow dynamic content, green has nothing, color. want both red , green columns height yellow content. height: 100% didnt work you can use negative margins achieve result the floating divs should wrapped in container overflow:hidden fiddle code #container { overflow:hidden; } #container div { padding-bottom:2000px; margin-bottom:-2000px; }

java - Listing or bundling all needed dependencies of a Jar file. How? -

i'm working .jar file needs other .jar files work correctly. problem of jar dependencies depend yet in other jar dependencies. game goes on. i'm in tool allow me either give original jar file , set of possible jar files / folders dependencies must , have tell me ones needed or tool bundle them together. the first option preferred one, although second 1 alright, too. what's simplest way accomplish task? (this isn't maven project). thanks if you're using apache maven , can use shade or onejar plugin accomplish that. can use onejar apache ant .

r - place a legend for each facet_wrap grid in ggplot2 -

Image
i have data frame: date server filesystem percentused 1 12/1/2011 / 60 2 1/2/2012 /var 50 3 2/1/2012 tmp 90 4 2/10/2012 /db 86 5 2/13/2012 /app 90 6 12/1/2011 b c: 67 7 1/2/2012 b d: 67 8 2/1/2012 b f: 34 9 2/10/2012 b /restore 89 10 2/13/2012 b g: 56 11 12/1/2011 c / 90 12 1/2/2012 c /tmp 78 13 2/1/2012 c /data 67 14 2/10/2012 c /storage 34 15 2/13/2012 c /database 12 dput(x) structure(list(date = structure(c(2l, 1l, 3l, 4l, 5l, 2l, 1l, 3l, 4l, 5l, 2l, 1l, 3l, 4l, 5l), .label = c("1/2/2012", "12/1/2011", "2/1/2012", "2/10/2012", "2/13/2012"), class = "factor"), server = structure(c(1l, 1l, 1l, 1l,

Call a Servlet from a jsp -

can call servlet jsp, come , display response data servlet in same jsp? possible that? basically, have pop in user gives input. pass servlet , servlet gives me acknowledgement number. display acknowledgement number in same pop up. in meantime, during servlet gives response, can display hour glass in pop up. possible? someone please me example please. option 1 can submit form in popup jsp , forward same jsp servlet. option 2 can use ajax , call servlet , send response (e.g. json) servlet , update need using javascript, jquery.

Remove noise in a graph -

let g=(v,e) dag. v set of vertices in graph, while e set of edges connecting vertices in v . assume noise introduced in graph, i.e., non-existing edges inserted in e . in way: roots may "hidden" in graph, becoming internal nodes leaves may become internal nodes too cycles inserted in graph i looking algorithm removes cycles while still preserving topology of initial dag. using dfs now: when encounter loop, 1 of edges composing loop deleted. however, not assure roots , leaves recovered. can found useful in state of art? thanks in advance. i'm afraid there not enough information available achieve goal: imagine degenerate tree consisting of single path v1...vn only. after insertion of spurious edge (vn, v1) graph, graph topology not provide hint on edge delete in order restore original. in particular not able reconstruct former root , leaf.

Header inside a header? (HTML5) -

this seems strange me oddly there reason use <header> inside <header> . with <hgroup> remove spec i'm seem @ weird state should/could doing following bit of code. <header> <header> <h1>maecenas faucibus</h1> <p class="h1-sub">donec sed odio dui.</p> </header> <section> <img src="..." alt="faucibus"> <img src="..." alt="faucibus"> <img src="..." alt="faucibus"> </section> </header> this appear in header portion of <article> wonder if visually appear there should still define <header> or should wrap in like: <section class="article-header"> <header><h1>...</h1><p>...</p></header> <section>...</section> </section> i've not come across said <header>

What's the most efficient way to render a template that changes based on primary key of a table (Django) -

i creating search page users can search parameters. search parameters change based on category searching in. there approximately 100 categories , each has own unique search parameters. currently have if statement in view checks 100 categories , renders 1 of 100 corresponding forms, feel it's not efficient. efficent/best way this? currently think this if category.id == 1: # render form1 elif category.id == 2: # render form2 elif category.id == 3: # render form3 .... i'm gonna give answer here may simplify problem little. if have 100 forms , need code them all. maybe may declare sort of global dictionary or array , @ end of each form definition, include them in it, example: # dict way category.id -> form class form_storage = {} form1(forms.form) #fields #methods form_storage[1] = form1 form2(forms.form) #fields #methods form_storage[2] = form2 ... then in views might receive get parameter category needs rendered instead of:

objective c - iOS - Moving from iCal Event into Application -

i'm in middle of planning project utilise ability create custom events within ios application. at moment i've found plenty of code allows ideally user able navigate application once ical reminder has fired, in similar way push notification once user hits view button. i've had detailed around cannot find anything, know if possible? if it's not possible, know of way create dynamic push notifications within app? thanks in advance.

ios - Key-value observation: Can I observe for changes on ALL properties? -

whenever property on object changed or updated want change variable (nonce variable). nonce time-based. everytime property updated nonce gets updated current time. is there way automatically listen key changes on object? or have manually maintain keyvalue observers each property separately? many thanks did take @ obj-c runtime functions? see here in docs. example, gives list of properties in class lender . (btw: i'm not @ mac, straight out of docs): @interface lender : nsobject { float alone; } @property float alone; @end you can list of properties using: id lenderclass = objc_getclass("lender"); unsigned int outcount; objc_property_t *properties = class_copypropertylist(lenderclass, &outcount); you can name of property: const char *property_getname(objc_property_t property) if pipe names addobserver:forkeypath:options:context should golden.

python - processing urls with hashes like jsbin -

jsbin, on browsers not support (window.history && window.history.pushstate) modify url via window.location.hash = data.edit; ( details here ). this creates urls http://jsbin.com/#/imetor/1/edit how django's urls.py process url that? i not sure hash being sent server . if not being sent server, technique jsbin uses pass parameters server? fwiw, not work: url(r'^#/(?p<project_id>[0-9a-za-z]{6,})', 'mysite.views.project_hash', name='project_hash'), you right. part past # not sent server. in django, if want see url sent server, can print request.get_full_path() in case of jsbin, server returns page contains javascript code reads url params , executes code personalize page. example of javascript code parses url , executes function backbone.router ( http://backbonejs.org/#router ).

how can I covert int to char in C -

i'm trying covert int char . there way that? for example: { int i; char d; = 55; d = i; printf("%c\n", d); } how make d = 55 ? if want put number 55 string, use sprintf

windows - SAPI: Speech to Text example -

i new sapi, , appreciate if of can provide me speech text hello world example in sapi. know ms got examples "dictation" etc, start small one. glad if can help. i played bit windows voice recognition using sapi, isn't user friendly. here example of code wrote (in c++) : #include <sphelper.h> #include <sapi.h> #include <iostream> #include <string> const ulonglong grammarid = 0; const wchar_t* rulename1 = l"rulename1"; int start_listening(const std::string& word); isprecogrammar* init_grammar(isprecocontext* recocontext, const std::string& command); void get_text(isprecocontext* reco_context); void check_result(const hresult& result); int main(int argc, char** argv) { start_listening("hello"); return exit_success; } // function exits when word passed parameter said user int start_listening(const std::string& word) { // initialize com library if (failed(::coinitialize(nullptr))) {

ember.js - Get object from belongsTo relationship -

let's have model like: app.employee = ds.model.extend({ name: ds.attr('string'), department: ds.belongsto('app.department') }); in controller can say var name = thisemployee.get('name'); but can't say var department = thisemployee.get('department'); so question how reference object on other side of relationship. i assume problem lies in fact maybe don't have specified how relationships should load... try setting adapter map this: app.adapter.map('app.employee', { department: {embedded: 'always'} }); this should side load department relationships automatically on requesting parent model employee e.g. app.employee.find(); . hope helps

php - How can I block requests for a file or directory unless it comes from a specified file? -

in .htaccess file have following rewriterules: rewriterule ^content/(.*)\.(txt|md|mdown)$ error [r=301,l] rewriterule ^site/(.*) error [r=301,l] these work blocking direct access txt|md|mdown file types , entire site/ directory. that said, i'm working on building out .appcache file cache site offline viewing , need able access these files , directories .appcache file. have .appcache file set , i'm getting following error in browser: application cache error event: resource fetch failed (-1) http://website.com/site/panel/blueprints/home.php is possible update rewriterule allow access file? rewritecond %{http_referer} !^$ rewritecond %{http_referer} !^http://(www\.)?yoursite.com.br/.*$ [nc] rewriterule .*\.(pdf|cdr|indd|psd|jpg|jpeg|ai|zip|rar|7z)$ - [f] just replace yoursite.com site , .*$ specific file need.

c# - Map List<> with Automapper? -

i have 2 classes: public class customerdto { public string name {get;set;} public list<order> orders {get;set;} } public class orderdto { public string name {get;set;} public string description {get;set;} public decimal cost{get;set;} } i using automapper .net 3.5 , doing following in application_startup: mapper.createmap<customer, customerdto>(); mapper.createmap<order,orderdto>(); this simplified example named dto properties different entity properties, used formember, unclear on how map orders customer: i tried: mapper.createmap<customer, customerdto() .formember(dest => dest.orders, opt=> opt.mapfrom(src=>src.orders)); but not find src.orders . if indeed need have both createmap statements, automapper "automatically" link objects customer orders ? yes, need tell automapper each mapping. not guess you. so, if orderdto should map order , must tell automapper that. must specify reverse relationship if that'

django admin super(type, obj) -

well, let me explain this. i working on simple django admin project. in admin.py file, have following admin classes: class a_admin(admin.modeladmin): #some stuff class b_admin(admin.modeladmin): #some stuff i want override get_urls() method of a_admin if click button on a_admin instance change page, redirect page b_admin changelist page. (i know there many ways want , mentioned above not best, want. let skip discussion why insist on solution.) i want following: def get_urls(self): #django's code #inside urlpattern urlpattern = ( #default urls django admin ..... url(r'^some_url$', wrap(super(b_admin, self).changelist_view), name='%s_%s_delete' % info), ....) return urlpatterns this not working, since 'self' a_admin class object rather b_admin obejct. so there way proxy of calss a_admin inside b_admin? wanna override changelist_view of , call inside b. i

dictionary - Replacing single value in dict in python list comprehension with other items -

currently populating generator networkx 's multidigraph module, in way: new_u0_edges = ((u, new_u1, key, edata) u, v, key, edata in self.g.edges_iter(u0, data=true, keys=true) if v == path[0]) but update single key, value pair in edata dict, edata['label'] . slow way of doing lists instead of generators is: new_u0_edges = ((u, new_u1, key, edata) u, v, key, edata in self.g.edges_iter(u0, data=true, keys=true) if v == path[0]) u, new_u1, key, edata in new_u0_edges: edata['label'] = u0[0] + new_u1` fyi, u0 , new_u1 both strings. yes, debruijn graph in case you're interested. my question is: is there way modify edata dict in generator? dict.update([iterable]) doesn't return value necessary generator, , list comprehensions don't seem allow reassigning. thanks! update: example variable data (still testing it's silly looking): u0 = 'defghij' new_u1 = 

excel vba - How to open and display text file at specific line from VBA -

i have vba userform handy open associated text file in textpad. can achieve following: call shell("c:\program files\textpad 5\textpad.exe " & "c:\testfile.txt", vbnormalfocus) however, i'd have text file displayed @ specific line number. there way pass line number argument shell call? i'm @ loss here. you can accomplish using wscript.shell.sendkeys trigger goto line shortcut within textpad (ctrl-g) dim wshshell set wshshell = createobject("wscript.shell") call shell("c:\program files\textpad 5\textpad.exe " & "c:\testfile.txt", vbnormalfocus) application.wait (10) wshshell.sendkeys "^g" 'ctrl-g application.wait (10) wshshell.sendkeys "15" 'desired line number application.wait (10) wshshell.sendkeys "{enter}" 'enter you might have mess wait lines add or remove delays between commands, tested within vba module in excel , worked. i aware sendkeys ca

Defining shared library in Typescript and Visual Studio Express -

i have projecta set compiling , running in visual studio typescript. want set projectb, , use of code projecta so if directory structure is: c:\workspace\projecta\src c:\workspace\projectb\src c:\workspace\shared\src is possible edit projecta , projectb .csproj files point shared typescript code? thanks i have tested placing shared files (the typescript file , associated files) in shared folder , using add > existing item , selecting add link when add files. if using reference comments, you'll need use relative path - if drag shared file onto local typescript file generate you: /// <reference path="../../shared/logger.ts" /> you need consider deployment strategy. 1 way set javascript files copy on build, appear in bin folder. you might want consider packaging shared stuff - make nuget packages them example.

ios - AVCaptureSession rotation -

i'm trying app create uiimage correct way round. most of code taken apple examples... @interface cameramanager () <avcapturevideodataoutputsamplebufferdelegate> @property (nonatomic, strong) cicontext *context; @property (nonatomic, strong) avcapturedevice *rearcamera; @end @implementation cameramanager - (id)init { if ((self = [super init])) { self.context = [cicontext contextwithoptions:nil]; [self setupcamera]; [self addstillimageoutput]; } return self; } - (void)setupcamera { self.session = [[avcapturesession alloc] init]; [self.session beginconfiguration]; [self.session setsessionpreset:avcapturesessionpresetphoto]; nsarray *devices = [avcapturedevice deviceswithmediatype:avmediatypevideo]; self.rearcamera = nil; (avcapturedevice *device in devices) { if (device.position == avcapturedevicepositionback) { self.rearcamera = device; break; } } nserror

apache - htaccess redirect not working in Chrome or other browsers -

i hosting separate site in subfolder. rules have set in .htaccess file follows: rewritecond %{http_host} www.example.com rewritecond %{http_host} example.com rewritecond %{request_uri} !subfolder/ rewriterule ^(.*)$ subfolder/$1 [l] this works fine in firefox (example.com redirects www.example.com), not in other browser. any idea doing wrong? i've cleared cache, etc., problem persists. update i apologize, should have explained better. there 2 sites here, 1 main folder , 1 subfolder. full htaccess file below. rewriteengine on rewritecond %{http_host} ^mainsite.com [nc] rewriterule ^(.*)$ http://www.mainsite.com/$1 [r=301,nc] rewritecond %{http_host} www.secondarysite.com rewritecond %{http_host} secondarysite.com rewritecond %{request_uri} !subfolder/ rewriterule ^(.*)$ subfolder/$1 [l] the first chunk main site, second secondary site, pointing subfolder. try keep 1 condition , tell me if worked : rewriteengine on rewritecond %{http_host} !^(www\.exam

java - Drawing Polylines with an incomplete list of LatLng's in Android (Google Maps) -

i have requirement draw out route on android app using google maps. have list of latlngs must use customer unfortunately not complete list of lats , longs partial webservice trying iterate through list of waypoints webservice , draw correct route uses these points. unfortunately draw straight line between waypoints or latlng's. suggestions on how iterate through , draw route? my code: private void showevacuationroute(list<latlng> latlnglist){ latlng currentloc = null; polylineoptions rectline = new polylineoptions().width(5).color(color.red); (latlng latlng : latlnglist){ (int = 0; < latlnglist.size() - 1; i++) { if (i % 2 == 0){ currentloc = new latlng(latlng.latitude, latlng.longitude); } else { latlng topostion = new latlng(latlng.latitude, latlng.longitude); gmapv2direction md = new gmapv2direction(); document doc = md.getdocument(currentloc, top

treating \r as \n in c# regex -

i have c# function finds patters of text in side input , processing. (i using 3.5 version of .net framework) public void func(string s) { regex r = new regex("^\s*pattern\s*$", regexoptions.multiline | regexoptions.explicitcapture ); match m = r.match(s); //do m } a use of function might this string s = "pattern \n pattern \n non-pattern"; func(s); however, finding input looking more this string s = "pattern \r pattern \r non-pattern" func(s); and not being matched. there way have \r treated \n within regex? figure replace \r s \n s, hoping minimize operations if regex @ once. unfortunatly, when have run in similar situations situation found works 2 passes regex (like hoping avoid), first 1 normalizes line endings 2nd 1 can search normal, there no way multiline trigger on /r find. public void func(string s) { s = regex.replace(s, @"(\r\n|\n\r|\n|\r)", "\r\n"); regex r = new regex("

jquery - Wrap text inside html tag -

i trying wrap text in inside <span> tag using jquery. below code not working. please point out going wrong. please suggest better/different approach. var mysearch = '(05/13/2012-11/13/2012)'; $('table:eq(0) tr:eq(1) th:contains("' + mysearch + '")').filter(function () { return this.html().replace('(05/13/2012-11/13/2012)', '<span class = "red"> (05/13/2012-11/13/2012)</span>'); }); demo on jsfiddle this in code dom element object doesn't have html method, don't need filter method, can use html method. $('table:eq(0) tr:eq(1) th:contains("' + mysearch + '")').html(function(_, html) { return html.replace('(05/13/2012-11/13/2012)', '<span class="red"> (05/13/2012-11/13/2012)</span>'); }); if content of th equal mysearch string, can use wrapinner method: $('table:eq(0) tr:eq(1) th').filter(functi

Javascript: how to check if a text exists in a web page -

let's string "done successfuly" displayed somewhere in webpage , there way know if string exist using javascript ? thanks. more details help. there may better ways. best given information you've provided: if ( ( document.documentelement.textcontent || document.documentelement.innertext ).indexof('done successfuly') > -1 ) { // something... } if know id or class-name or can otherwise select element directly contains text (e.g. h1#someheading span ... ) should more performant , cleaner approach. edit worth noting: approach pick text within script , style tags too, not want. both textcontent , innertext have various quirks across browsers too. see more info .

css - hide div tag on mobile view only? -

i'm creating fluid layout site. i'm trying hide contents of <div> or whole <div> in mobile view, not tablet , desktop view. here's i've got far... #title_message { clear: both; float: left; margin: 10px auto 5px 20px; width: 28%; display: none; } i have display set 'none' mobile layout , set block on tablet/desktop layouts... there easier way that, or it? you need 2 things. first @media screen activate specific code @ screen size, used responsive design. second use of visibility: hidden attribute. once browser/screen reaches 600pixels #title_message become hidden. @media screen , (max-width: 600px) { #title_message { visibility: hidden; clear: both; float: left; margin: 10px auto 5px 20px; width: 28%; display: none; } } edit: if using css mobile add visibility: hidden; #title_message . hope helps you!