Posts

Showing posts from July, 2012

Adding Command Line Arguments to Python Twisted -

i still new python keep in mind when reading this. i have been hacking away @ existing python script "put" few different people. the script designed load it's 'configuration' using module named "conf/config.py" python code. setting_name='setting value' i've modified instead read it's settings configuration file using configparser: import configparser config_file_parser = configparser.configparser() config_file_name = "/etc/service_settings.conf" config_file_parser.readfp(open(r'' + config_file_name)) setting_name = config_file_parser.get('basic', 'setting_name') the problem having how specify configuration file use. have managed working (somewhat) having multiple tac files , setting "config_file_name" variable there using module hold variable value. example, have module 'conf/configloader.py": global config_file_name then tac file has: import conf.configloader

javascript - What is the Best way to assign attributes by their index -

i have wrapper has children need specific positions. let's have markup so: <div class="wrapper"> <div class="slider" data-position=""></div> <div class="slider" data-position=""></div> <div class="slider" data-position=""></div> </div> the last child should have position of infront, second last child should have position of behind , every other slider should have position of limbo. demo: http://jsfiddle.net/l5lpp/1/ i'm not fan of massive chain of if , else statements.... is there better more elegant way achieve this? try this: var sliders = $("div.slider").data("position", "limbo"); sliders.last().data("position", "infront"); sliders.eq(-2).data("position", "behind"); edit: using classes: var sliders = $("div.slider").removeclass("l

Rails encoded url query plus sign not properly decoded -

raw email abc+2@gmail.com for haml file, have javascripts this $('#search_email').on('click', function(e){ var val = encodeuricomponent($('#search_email').val()); window.location.search = 'email='+val; }); in query url, shows correctly as url?email=abc%2b2%40gmail.com however, controller, when use debugger monitor, shows only params[:email] = "abc 2@gmail.com" does know happens, why rails decodes directly , in wrong way. thanks.

python - Re-Parsing JSON -

i have tweet data need parse: "{u'contributors': none, u'truncated': false, u'text': u'', u'in_reply_to_status_id': none, u'id': 325495490122772480l, u'favorite_count': 0, u'source': u'<a href=""http://itunes.apple.com/us/app/imdb-movies-tv/id342792525?mt=8&uo=4"" rel=""nofollow"">imdb movies & tv on ios</a>', u'retweeted': false, u'coordinates': none, u'entities': {u'symbols': [], u'user_mentions': [{u'indices': [56, 68], u'id_str': u'244186942', u'screen_name': u'ploughman71', u'name': u'paul hughes', u'id': 244186942}], u'hashtags': [{u'indices': [50, 55], u'text': u'imdb'}], u'urls': [{u'url': u'...', u'indices': [27, 49], u'expanded_url': u'...', u'display

Multiple forms in a single page using flask and WTForms -

i have multiple form on same page send post request same handler in flask. i generating forms using wtforms. what best way identify form submitted ? i using action="?form=oneform" . think there should better method achieve same? i've been using combination of 2 flask snippets. the first adds prefix form , check prefix validate_on_submit(). i use louis roché's template determine buttons pushed in form . to quote dan jacob: example: form1 = forma(prefix="form1") form2 = formb(prefix="form2") form3 = formc(prefix="form3") then, add hidden field (or check submit field): if form1.validate_on_submit() , form1.submit.data: to quote louis roché's: i have in template : <input type="submit" name="btn" value="save"> <input type="submit" name="btn" value="cancel"> and figure out button passed server side have in views.py file: if reque

design patterns - Javascript: How can two self executing function access each other -

i javascript self executing anonymous function is: (function(){ console.log('hello world!'); })(); and can pass in parameters: (function(window){ window.location(...); })(window); but if have 2 self executing anonymous functions, can each 1 access other? specifically, how can first function call method second, passing variable? (function(){ function foo () { return 'foo'; } // how can call "bar('my name is')" })(); (function(){ function bar (str) { return str + ' bar' ; } })(); thanks listening. they can't , that's kinda point. wrapping code this, inaccessible outside. if don't care such accessibility protections other things is: function foo() { bar() } // call bar foo(); // execute function bar() { // stuff } bar(); // execute

Is it OK to use `git push` to restore a remote repository? -

suppose have lost remote repository, because accidentally typed following command. rm -rf ourrepo.git in order restore it, plan use 1 of top-voted answers earlier question. however, observed none of solutions mentions following three-step strategy. use git init --bare recreate remote repository. set new remote git remote add origin <new repository url> . use git push origin master 1 of machines has up-to-date copy of repo i have tried on toy respository , appears work, 1 of colleagues claims there problem without being able pinpoint why. can either confirm or deny whether reasonable way restore lost remote? no, there shouldn't wrong proposed strategy, , in fact typical way restore remote repository (though not way). don't forget push tags along branches: git push origin --tags --all that command push branches under .git/refs/heads/ , tags under .git/refs/tags/ . if don't want push of branches, name each branch want push instead

node.js - MongoDB/Mongoose aggregation or $or not working as expected? -

have checkbox buttons in html filter results via api on.click, on ajax. there 3 kinds of results: upvoted, novote, downvoted. subject of checkboxes checked, combination of upvoted, novote, , downvoted docs appear user. the ajax calls url of api, , data reaches database call correctly after running through following loop in node.js api, loops through array of strings ["upvoted", "novote", "downvoted"] (or combination thereof) , assigns boolean value of true respective variable: var upvoted = false; var novote = false; var downvoted = false; storyfiltering.foreach(storyfiltering); function storyfiltering(element, index, array) { if (element == 'upvoted') {upvoted = true} else if (element == 'novote') {novote = true} else if (element == 'downvoted') {downvoted = true} } console.log('upvoted: ' + upvoted + ', novote: ' + novote + ', downvoted: ' + downvoted); these variables match booleans o

java - Is this good practice for caching database data on my HTTP servlet? -

i'm writing http servlet (hosted on amazon elastic beanstalk) serves application server android app. application request data servlet, in turn pull database (simpledb). since client requests may frequent, wanted implement cache on servlet cache requested data cut down on database reads. currently, initialize "servercache" object member variable of servlet. servercache contains lists cached data, , populate these go. looks this. public class servercache { /** * servercache responsible caching data on server. * create several data structures on server cache buy/sell listings listing objects. * now, able cache entirety of database contents. * -es * * 1 servercache should ever made, @ init() of server */ private list<buylisting> listbl; //what danger of having public vs. private private list<selllisting> listsl; public string bllasterror; public string sllasterror; public servercache() { this.listbl = new arraylist<buylisting>();

sql - Would splitting a query by an indexed ID field avoid ORA-01555: snapshot too old error? -

i have queries of form: select * main.my_table id in (select id other.other_table type = 'banana'); where id indexed on main.mytable , not indexed on other.other_table recently these have been erroring ora-01555: snapshot old . my understanding this due query taking long undo space. this due being peak business season , databases being under heavy load. the question is, if split query several queries of form: select * main.my_table id in (select id other.other_table type = 'banana') , id >= 0 , id <1000; select * main.my_table id in (select id other.other_table type = 'banana') , id >= 1000 , id <2000; select * main.my_table id in (select id other.other_table type = 'banana') , id >= 2000 , id <3000; on 1 hand seems each query take less time initial query. on otherhand, seems such obvious optimisation, think oracle anyway. why don't try optimising query d

web optimization - Unable to minify css in asp.net mvc -

i trying minify css file using system.web.optimizations , won't work var fontawsomebundle = new bundle("~/bundles/css/font-awsome", new cssminify()) .include("~/content/packages/font-awesome/css/font-awesome-{version}.css", new cssrewriteurltransform()); i have run site optimizations enabled , debug=false there no pre-minified file in same location .net 4.5, iis express system.web.optimizations 1.1.0.0, webgrease 1.6.5135.21930. tried updating webgrease latest, didn't work i not getting minification errors in bundle file, unminified version of file tried version well. fontawsomebundle.transforms.add(new cssminify()); you should use stylebundle .css , scriptbundle .js. var fontawsomebundle = new stylebundle("~/bundles/css/font-awsome", new cssminify()) .include("~/content/packages/font-awesome/css/font-awesome-{version}.css", new cssrewriteurltransform());

java - Protect and unprotect file to avoid accidental elimination in Android by bugged cleaning apps -

in android app save files data file using fileoutputstream savedlist = new fileoutputstream(path); in folder named myapp located in sd storage unfortunately have noticed cleaner apps, not implemented, popular (e.g. cleanmaster) wrongly remove files every time user perform temp\trash file cleaning causing problems. is there way protect (and unprotect writing) file programmatically avoid this? how change file permissions? since aren't used file extensions recognize file format, how change metadata of file used determine file format these file see documents these apps? suppose scan of these cleaners use strategy based on linux file format recognition , remove object files. android allows have private directory on sd card app. can path private directory app follows. file mydir = getexternalfilesdir(null); //the null parameter indicates going store type of files in directory mydir.mkdirs(); log.d("info", mydir.getpath()); it same directory o

Swift Types inside Parentheses -

i playing around swift today, , strange types started crop up: let flip = int(random()%2) //or arc4random(), or rand(); whatever prefer if type flip xcode 6 (beta 2), auto-complete pops up, , says flip of type (int) instead of int . this can changed: let flip : int = int(random()%2) let flop = random()%2 now flip , flop of type int instead of (int) playing around more, these "parentheses types" predictable , can cause them adding parentheses in part of variable's assignment. let g = (5) //becomes type (int) you can cause additional parentheses in type! let h = ((5)) //becomes type ((int)) let k = (((5))) //becomes type (((int))) //etc. so, question is: difference between these parentheses types such (int) , type int ? partly it's parentheses meaningful. let g = (5) ...means g tuple consisting of 1 int, symbolized (int) . it's one-element version of (5,6) , symbolized (int,int) . in general need quite careful

java - Extract all classes under in "model" packages to a separate Maven module -

i have maven module src directory looks this: src/ main/ foo/ model/ modela.java bar/ model/ modelb.java what easiest way extract classes under in "model" packages separate maven module? (i.e. want move modela , modelb separate module) you can define copy-resources plugin in pom.xml: <plugin> <artifactid>maven-resources-plugin</artifactid> <version>2.4.3</version> <executions> <execution> <id>copy-models</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputdirectory>{code_base}/new-module/src/main/foo/model> <!-- location models need copied --> <overwrite>true</overwrite> <resources> <resource> <directory>src/main/*/mo

tfs2010 - What's DNS suffix when configuring the Lab Environment in TFS? -

i'd set lab environment tfs. i have scvmm server , hyper-v hosts. but when configure lab environment in tfs, requires dns suffix in network isolation tab. what's dns suffix , can find it? i'm in domain controlled one. if it's info entry domain controller, mean have set private domain environment? you need give dns suffix of primary domain. though may end setting private domains within lab environment, dns suffix provide there publicly addressable 1 use connect/route lab environments mtm , dev machines.

play framework 1.2.4 multiple footer in mutiple PDF page -

i need render multiple types of footer , header in different pdf pages. how can that? single kind of footer in pdf pages. multipdfdocuments documents = new multipdfdocuments(); pdfdocument document = new pdfdocument(); document.template = "@template1"; options options = new options(); options.pagesize = ihtmltopdftransformer.a4l; document.options = options; documents.add(document); document = new pdfdocument(); document.template = "@template2"; options = new options(); options.pagesize = ihtmltopdftransformer.a4l; document.options = options; documents.add(document); file file = new file("c:/users/pdf.pdf"); pdf.writepdf(file,documents);

Add Spinning Wheel Progress Bar In Android -

i try add spinning wheel progress bar in module in android.but not working. by click on send button want add spinning wheel.tell me add , how add. my code is: fragment send job.java public class fragmentsendjob extends fragment implements onclicklistener { // fragment called mainactivity textview newmember,forgot,view; edittext uedit,pedit; vibrator vibe; string euid,epass; string name,pass; string status_key; private static mydialog dialog1; bitmap bitmap1, bitmap2,bitmap3; bitmap[] bitmap; string[] driver_details; private byte imageinbyte1[],imageinbyte2[],imageinbyte3[] ; private context mcontext; private string mname,mobile,desc; public string advertisement_count; private button submit,cancel; private edittext ename,mobno,picktime,unit,street,suburb,destination,fare,city; private spinner state,group; private viewgroup vgroup ; // name of para meter on send job module private string s

Strategies for Custom Array Functionality in PHP -

i find myself struggling finding solution various array arrangement problems in php fall outside of solutions have implemented before. currently, starting array: $tags = array( array('tag_id' => 1, 'tag_name' => 'hello', 'album_id => 1'), array('tag_id' => 1, 'tag_name' => 'hello', 'album_id => 2'), array('tag_id' => 2, 'tag_name' => 'world', 'album_id => 1'), array('tag_id' => 2, 'tag_name' => 'world', 'album_id => 2'), array('tag_id' => 3, 'tag_name' => 'again', 'album_id => 3') ); and want organize such: $organized_tags = array( array('tag_id' => 1, 'tag_name' => 'hello', 'album_ids' => array(1,2)), array('tag_id' => 2, 'ta

iphone - Rate This App - iOS -

can use same "rate app" url updated version of app? eg: itms-apps://itunes.apple.com/webobjects/mzstore.woa/wa/viewcontentsuserreviews?type=purple+software&id=12345698 *so in above example, if have used above url version 1.0 of app. 1. can use same url updated version 1.1 of app ? 2. url work once v1.1 of app uploaded on app store ? 3. or id number change incase of newer app version ? *

finding non empty indices of a pre-allocated vector C++ -

is there simple way find indices of non empty entries of pre-allocated vector? 1 way loop through vector. slow if memory allocated vector large , number of non empty entries less. below example code. in have entries indices 5,9,9,15 , task identify indices 5,9,15 vector x of size 20 . please suggest simple way or better data structure helpful. #include "stdafx.h" #include <string> #include <iostream> #include <vector> using namespace std; int main(int argc, char* argv[]) { vector <map<int,int>> x(20); x[5].insert({ 4,10002 }); x[9].insert({2,20}); x[9].insert({ 3, 60 }); x[15].insert({ 11, 60 }); return 0; } first, assume 0 entry mean empty entry (a map without elements). i don't think possible remove iteration cost, moved other points of program (initialization, element insertion, ...) point want identify index. for example, can encapsulate 2 containers in class: vector propose, , set<size

.net - Deploy MVC 3 and MVC 5 website on same server IIS 7 -

i've mvc 3 application running on iis 7. i've upgraded mvc 5. possible to deploy both applications i.e mvc 3 , mvc 5 on same server using iis 7? yes can host both mvc 3 mvc 5 application on iis 7 no issue. if had upgraded mvc 5 why want mvc 3 version of application. could please provide more details on this.

java generics, how to extend from two classes? -

i want have class object, want force whatever class represents extend class , class b. can do <t extends classa & classb> but not possible extend both classes, there way this? in java cannot have class extends 2 classes, since doesn't support multiple inheritance. can have, so: public class ... public class b extends ... public class c extends b ... in generic signature, can specify t must extend c : <t extends c> . you give @ default methods (if working java 8), methods declared within interfaces, , in java, class can implement multiple interfaces.

Margin not showing with 100% width & height -

i trying build myself portfolio site. when thought finish building basic template, margin , media queries stuff totally drove me crazy. here temporarily hosted domain, www.kenlyxu.com/portfolio_new i made pages fit whatever browser size using html, body { margin:0; padding:0; width:100%; height:100%; i'm trying make 10px margin on side , on every page use container. #thecontainer { margin: 10px; background-color: #f29e28; height: 100%; width: 100%; } #workcontainer { margin: 10px; background-color: #f29e28; width: 100%; } i hope end result orange background white margins on sides. when seeing site on desktop, margin-right , margin-bottom not showing. show when use width: 98.5%; also, orange background color should expand according size of browser. on iphone 5 portrait view, orange background not extent bottom part. tried use standard media queries it, don't know values should give each of mobile devi

c - Objdump gives Segmentation Fault with -S option -

i trying use objdump display source disassembly using -s option. running objdump on cygwin. built objdump arm on cygwin. compiler build gcc. the elf file built arm processor using thumb2 instruction set using ti arm compiler. i able run objdump extract disassembly(using -d option). however, getting segmentation fault when try use display source well. crashes reaches .text section. output of using objdump -mforce-thumb -s prog.out is: prog.out: file format elf32-littlearm disassembly of section .text: 000000c0 <add_function> : segmentation fault (core dumped) objdump not decompiler, disassembler. disassembly (comparatively) simple, provided binary not using anti-disassembly tricks. decompilation, contrast, difficult thing do, , objdump makes no attempt it. can dump source if binary included it. that's not common native binaries, heard, java binaries tend include source.

ios - Tabbar disappears after segue -

Image
hi guys have main navigation controller , tab bar controller, have 4 viewcontrollers , works fine. have open viewcontroller button push segue, problem tabbar disappears once that. there simple solution solve issue? make tabbarcontroller initialviewcontroller , embed viewcontrollers uinavigationcontroller . not hide tabbar bottom.

c++ - remove a sprite in cocos2d-x -

i new cocos2d-x.i developing game in xcode using cocos2d-x. in game, have sprite animation(man) , moving obstacles , coins. making collision sprite animation & coins. when 10 coins, adding life(adding sprite life). question when collision happening between sprite animation(man) & obstacles, life should decrease(i mean life sprite should remove) not removed. using following code. if(coincount%10==0) { lifecount=lifecount+1; } if(lifecount==1) { life = ccsprite::create("life.png"); life->setposition( ccp(winwsize/2, winhsize/1.08) ); this->addchild(life, 5); } else if(lifecount==2) { life1 = ccsprite::create("life.png"); life1->setposition( ccp(winwsize/1.8, winhsize/1.08) ); this->addchild(life1, 5); } else if (lifecount==3) { life2 = ccsprite::create("life.png"); life2->setposition( ccp(winwsize/1.6, winhsize/1.08) ); this->addchild(life2, 5); } if (manrect.intersectsrect(obs5rect)) { if(lifecount>=1) { life

Reuse components in AngularJS -

as new angularjs developer (coming php+laravel world) i'm facing troubles designing architecture of new app. best way implement crud app entities used more once along app? for example: have entities 'document' , 'project'. documents can listed , viewed alone, can attached projects. inside project detail view include attached documents, using same template used when listing documents alone. widget should have own controller , methods, since need make api calls , apply business logic; , receive parent project data in way. what should use document listing? directive, ng-include or other? you should use module use reusing component. https://docs.angularjs.org/guide/module

android - custom listview inside custom dialog -

i want ask listview , dialog i have dialog show custom layout edit text, text view, , listview the problems is, when dialog loaded up, everthings inside dialog work fine handled clicklistener, but... the listview not responding onitemclicklistener... i ve search there s no solution problems... hope can me figure out... many ^^ here code li = layoutinflater.from(this); somelayout = (linearlayout)li.inflate(r.layout.d_bon_rokok_add_main, null); lbldate = (textview)somelayout.findviewbyid(r.id.d_bonrokokaddmain_lbltgl); txtstartdate = (edittext)somelayout.findviewbyid(r.id.d_bonrokokaddmain_txtstartdate); lblto = (textview)somelayout.findviewbyid(r.id.d_bonrokokaddmain_lblto); txtenddate = (edittext)somelayout.findviewbyid(r.id.d_bonrokokaddmain_txtenddate); btnsearch = (button)somelayout.findviewbyid(r.id.d_bonrokokaddmain_btnsearch); ll_add = (linearlayout)somelayout.find

jquery - $.when multiple ajax how to get multiples responses -

i trying improve code , until now, every time use $.when getting multiples ajax call before doing something, take response of each call global variable, way can use them in .then part is there way these responses without doing this? mean, in success: function(response){...} part of each ajax, can change that? in .then(function(...) add parameters each response?

sql server - Error genereating publish script: the select permission was denied on the object __refactorlog? -

in ssdt project, why getting error? "the select permission denied on object __refactorlog?" there refactorlog item in project. i select generate publish script inside vs. edit: target production server, don't have permissions create tables or select data there, have create deployment script, , there no table __refactorlog anyway.. you need greater permissions have on server in order generate publish script. verified there call "select object_id(n'dbo.__refactorlog')" in code handling refactor operations checks if table exists. it's code failing @ point don't have permissions ask select object. can check running query against database , seeing if error. suggestions determining permissions need: try right-clicking on database , choosing "create new project". if can't extract database definition project it's clear sign don't have view definition privileges on database if that's not case, issue nee

asp.net - Load page title initial automatically -

today: on every page "load" event- page.title = defaultpagetitle + page.title; "defaultpagetitle"- string taken "basepage", means every new page, have copy&paste line. my goal: automatically load initial title suffix every page.. defaultpagetitle="xxx- " if aspx code file title tag <title>page1</title> the page title "xxx- page1" in general practice create base class called pagebase inherits system.web.ui.page. inherit aspx pages base class. in way can refactor common code base class. you can override onload event in pagebase , move code event. need not write code in each page. other option if using master page, write code set page title in page_load event of master page

javascript - 'undefined is not a function' with google charts when using JSON -

i have json data , wanted try out google charts. used examples documentation here , here <head> <!--load ajax api--> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> // load visualization api google.load("visualization", "1", {packages:["corechart"]}); // set callback run when google visualization api loaded. google.setonloadcallback(drawchart); function drawchart() { var jsondata = $.ajax({ url: "get-stats.php", datatype:"json", async: false }).responsetext; var options = { title: 'stats' }; // create our data table out of json data loaded server.

javascript - In Cucumber.js is it possible to list all of the available steps? -

other versions of cucumber, possible dump list of steps. not supported in javascript. example: cucumber -f usage --dry-run if can access world object or cucumber, think there might way list of regexps / functions cucumber uses parse .feature files. know inner workings of javascript version point me in right direction? i found easier write own, require of steps outputs them found. var container = { myfn: function(type, regexp, fn) { console.log(type +' '+regexp.tostring()); }, given: function(regexp, fn) { this.myfn('given', regexp, fn); }, : function(regexp, fn) { this.myfn('then', regexp, fn); }, when : function(regexp, fn) { this.myfn('when', regexp, fn); } }; var steps = require('./stepdefinitions'); steps.apply(container); // stepdefinitions module.exports = function() { this.given(/^i run cucumber protractor$/, function(next) { next(); }); };

jquery - How can I decide the priority between media queries and css? -

i have page.css used master page others pages. in file have property div: <div class="classdivone">hello</div> is: .classdivone{ margin-top:5px; } now, windows explorer fine. instead chrome need fix margin-top:0px; . i used media queries (inside master page) in way: <style type="text/css"> @media screen , (-webkit-min-device-pixel-ratio:0) { .classdivone{ margin-top:0px; } } </style> but noted file css primary choice , media screen chrome not used. if put div style="margin-top:0px" have same result. how can set priority choice of css div? or there different solution? write way <style type="text/css"> @media screen , (-webkit-min-device-pixel-ratio:0) { .classdivone.classdivone{ margin-top:0px; } } </style> or <style type="text/css"> @media screen , (-webkit-min-device-pixel-ratio:0) {

ios - How to go to particular viewcontroller from leftviewcontroller in IIViewDeck in storyboard? -

i having difficulty using iiviewdeck in app. using storyboard. have managed bring leftviewcontroller tableviewcontroller cells supposed segue particular viewcontroller in storyboard. how do this? have put in appdelegate. uistoryboard* mainstoryboard = [uistoryboard storyboardwithname:@"main" bundle: nil]; uiviewcontroller *menucontroller = [mainstoryboard instantiateviewcontrollerwithidentifier:@"mainsidenavmenu"]; uinavigationcontroller* navigationcontroller = (uinavigationcontroller *) self.window.rootviewcontroller; self->viewdeckcontroller = [[iiviewdeckcontroller alloc] initwithcenterviewcontroller:navigationcontroller leftviewcontroller:menucontroller rightviewcontroller:nil]; self.window.rootviewcontroller = self->viewdeckcontroller; you can manage code, didselectrowatindexpath method of table view. - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { uistoryboard* sb = [uistoryboard stor

What is .arm in assembly code ? -

the following code taken https://github.com/xilinx/linux-xlnx/blob/master/arch/arm/kernel/head.s i have never done arm assembly programming can me understand going on in these lines? .ar.? etc: .arm __head entry(stext) thumb( adr r9, bsym(1f) ) @ kernel entered in arm. thumb( bx r9 ) @ if thumb-2 kernel, thumb( .thumb ) @ switch thumb now. thumb(1: ) also kindly point me tutorials getting starting with. plenty of arm microcontrollers have 2 different instruction sets: the default 32 bit arm instruction set the lightweight 16 bit thumb instruction set during program execution, arm chip can switch between 2 modes in order run instructions of these sets. the purpose of these lines seems selection of right mode (i.e., .arm or .thumb) in order execute subsequent code. edit: sorry, made mistake. real purpose specify set of instruction used in generated code. example,

mysql - How to restore auto IDs in transaction rollback -

i not sure if behavior of db or application . if transaction fails @ point records had been added table auto-generated ids, id 22 , , there's rollback there way re-use id 22 ? way table restored -- regards next auto id -- before failed transaction. here code have been running point of failure indicated: transaction { grc = ormexecutequery( "from relation1 somid=#form.someid#" ); if( arraylen( grc ) gt 0 ) { ogr.id = []; for( =1; lte arraylen(grc); = + 1 ) { grcnew = entitynew( "relation2" ); grcnew.setfirstname( grc[i].getfirstname() ); ......... entitysave( grcnew ); ormflush(); ogr.id[i] = grcnew.getid(); entitydelete( grc ); //<<--- **point of failure** } } } how can prevent losing ids in relation2 whenever there's transaction rollback due failure delete corresponding entity/record in relation1 ? database

python - BeautifulSoup to extract URLs (same URL repeating) -

i've tried using beautifulsoup , regex extract urls web page. code: ref_pattern = re.compile('<td width="200"><a href="(.*?)" target=') ref_data = ref_pattern.search(web_page) if ref_data: ref_data.group(1) data = [item item in csv.reader(output_file)] new_column1 = ["reference", ref_data.group(1)] new_data = [] i, item in enumerate(data): try: item.append(new_column1[i]) except indexerror, e: item.append(ref_data.group(1)).next() new_data.append(item) though has many urls in it, repeats first url. know there's wrong except indexerror, e: item.append(ref_data.group(1)).next() this part because if remove it, gives me first url (without repetition). please me extract urls , write them csv file. thank you. although it's not entirely clear you're looking for, based on you've stated, if there specific elements (classes or id's or text, instance) associated links yo

android - Shared Preference String Variable does not work in if statement -

i can not use string value shared preference in if statement. here's brief description: if(jm == "mute"){ // } this statement works when string jm = "mute"; but doesn't work when prefs = getsharedpreferences(pref_name, 0); string jm = prefs.getstring("key", ""); //which returns mute use .equals in if statement work change if(jm == "mute"){ to if(jm.equals("mute")){ for more info see how compare strings in java?

process - C - running program accept input -

this beginner-level question in c. don't know start looking/searching. so, if have program continuously running in c, best way accept input through command line program? ex, mysql running, can process command call mysql select * * do need different program write file/stdin?enter code here clarification: so, mysql seems able take in commands while running... possible in c? goal: have hooks open gl es, , want run continuous draw loop in background, while having ability call commands such glhookprogram make "object1" model "triangle" program "default" glhookprogram attr "object1" position "1.0, 1.0, 0.0" scale "2.0" rotation "45, 0, 0" this way, can have node server run hw-accelerated animations in javascript on rpi. looks need (and i'm sorry - won't going details there plenty of sources on web that): a "server" - background process stays running in memory , can ac

c# - Error when counting a specific word in a string with Regex.Matches -

i tried find method count specific word in string, , found this. using system.text.regularexpressions; matchcollection matches = regex.matches("hi, hi, everybody.", ","); int cnt = matches.count; console.writeline(cnt); it worked fine, , result shows 2. when change "," ".", shows 18, not expected 1. why? matchcollection matches = regex.matches("hi, hi, everybody.", "."); and when change "," "(", shows me error! error reads: system.argumentexception - there many (... i don't understand why happening matchcollection matches = regex.matches("hi( hi( everybody.", "("); other cases seem work fine need count "(". the first instance, . , using special character has different meaning in regular expressions. matching of characters have; hence getting result of 18. http://www.regular-expressions.info/dot.html to match actual "." character,

IIS/Firefox can't display gif file. Error: The image "http://....*.gif" cannot be displayed because it contains error -

on window, iis/firefox displays directory contents follow: 6/29/2014 12:23 38481 _jmeter_latency_06-29-2014-00_23_59.gif 6/29/2014 12:25 42308 _jmeter_latency_06-29-2014-00_25_48.gif when clicking gif file, displays "the image " http://ip/..../ *.gif" cannot displayed because contains errors. http://*.gif doens't work. should use image

playframework 2.3 - running activator h2-browser can not successfully open H2 browser -

i'm running activator h2-browser command in ubuntu 14.04 system in directory containing associated files of play framework project. when command executed web application running on localhost:9000. after running activator h2-browser in root directory of project following message in terminal: [info] loading project definition /xxxx/project [info] set current project xxxx (in build file:/xxx/) tcp server running @ tcp://127.0.1.1:9092 (only local connections) pg server running @ pg://127.0.1.1:5435 (only local connections) web console server running @ http://127.0.1.1:8082 (only local connections) after executing command 127.0.1.1:8082 opened. expect see h2-browser the connection reset on firefox. how can possibly fix it? mine worked said in documention : you can browse contents of database typing h2-browser @ play console. sql browser run in web browser. to play console , tried activator first , @ prompt, entered h2-browser .

setcontentview - Application Forces to close when I start another activity through Intent and display a text -

app force closes when try start intent , display text have included setcontentview(r.layout.activity_try_text); public class trytext extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_try_text); textview text = (textview)findviewbyid(r.id.textview11); text.settext("hi"); } } and here logcat 06-30 12:03:05.115: i/process(698): sending signal. pid: 698 sig: 9 06-30 12:03:11.802: d/androidruntime(1327): shutting down vm 06-30 12:03:11.802: w/dalvikvm(1327): threadid=1: thread exiting uncaught exception (group=0x41b7bd40) 06-30 12:03:11.807: e/androidruntime(1327): fatal exception: main 06-30 12:03:11.807: e/androidruntime(1327): process: com.example.bag, pid: 1327 06-30 12:03:11.807: e/androidruntime(1327): java.lang.runtimeexception: unable start activity componentinfo{com.example.bag/com.example.bag.trytext}: java.l

c# - How to update an entity using Entity Framework from Business Layer? -

i web application structured 3 layers, controller, business logic , repository. from bl layer updating entity following code. can see updating property property. i know if there better way it, removing manual mapping. ---------------------- controller public ihttpactionresult put(int id, devicedto dto) { gadevice device = mapper.map<gadevice>(dto); devicebll.update(id, device); return ok(); } ---------------------- bl public void update(int id, gadevice entity) { bool hasvalidid = getbyid(id) != null ? true : false; if (hasvalidid == true) { gadevice device = devicerepo.getbyid(id); device.cannotifypc = entity.cannotifypc; // not sure here device.cannotifyprinter = entity.cannotifyprinter; device.locationid = entity.locationid; device.name = entity.name; device.note = entity.note; device.operativefromtime = entity.

Generate a function based upon name data in a csv file opened in R -

i have dataframe of variable names , weightings. example: names <- c("a","b","c") weightings <- c(1,2,3) df <- cbind(names,weightings) i need generate function data such. myfun <- function(x,data){ data[x,"a"]*1+data[x,"b"]*2+data[x,"c"]*3} i have dataframe named data column names match a, b, , c , apply myfun data on rows. the issue have size of names , weightings vector can vary. working 5 names , weightings want generate new function "myfun" such. newnames <- c("a","b","c","d","e") newweightings <- c(1,2,3,4,5) myfun <- function(data){ data[x,"a"]*1+data[x,"b"]*2+data[x,"c"]*3+data[x,"d"]*4+data[x,"e"]*5} is there easy way automate creation of function give code, , .csv file of column names , weightings , generate new function. what strategy this. use function mak

c# - How to require two different types of authentication within same WCF service -

i have existing wcf service uses transportwithmessagecredential security. requires username , password , uses customauthorizationpolicy , customusernamevalidator. configured within web.config in bindings / behaviors , works fine. however, have requirement add new method service new vendor, , i'm being told new vendor uses java client , not able figure out how authenticate credentials in header, required other methods in service. so i've been asked take username , password arguments new method instead, , use manually authenticate against our user store in database. my question is, since want method included in same service requires authentication every other method, possible implement way single method exempt authorization / authentication policy other methods require? you add endpoint doesn't use custom validator

c# - XML Xpath doesn't return what I want -

i have xml <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc="http://open-services.net/ns/core#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> <oslc:responseinfo rdf:about="https://timo-pcvirtual:9443/qm/oslc/users"> <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/dave" /> <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/al" /> <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/ccm_user" /> <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/guest" /> <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/qm_user" /> <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/build" /> <rdfs:member rdf:resource=&quo