Posts

Showing posts from May, 2015

jquery - Getting data iterating over wtform fields -

Image
i've got form, , number of dynamically adding fields, class editbook(form): title = textfield('title', validators = [required()]) authors = fieldlist(textfield()) that's how append them $('form').append('<input type="text" class="span4" id="authors-' + fieldcount +'" name="authors-' + fieldcount +'" placeholder="author ' + fieldcount +'">'); i want data theese inputs. how can iterate on them, using python? (or how can send collected data jquery server? i'm new js , jquery) guess inputs aren't connected authors fieldlist. update my inputs aren't connected editbook though append them it. form.data solve rest of problem, when attach inputs form. (now keyerror, trying access form.data['authors-1']) now try add single authors field copy later. renders invisible, unknown reason. in blank space should input, similar "author-1&

javascript - Bootstrap 2.3.2 typeahead trigger ENTER keyCode event when an item is clicked -

i have text input field , i'm using bootstrap typeahead set state names typeahead values. have function foo , takes event keycode input, , adds text field input value list (it's more complex that, details shouldn't important). user can input values field multiple times, , each time user inputs value , presses "enter", foo called , input field cleared. i've noticed that, if type few letters, use arrow keys select value want, , press "enter", foo gets called item , it's added list expected. however, when type few letters , use mouse click on value want, correct value gets put text field, foo not called. if user presses "enter" @ point foo called expected, want foo called user clicks value in typeahead list. i have tried 2 methods far. 1) add click event handler input such: $('input').on('click', function() { // call foo() passing enter event keycode }) this problematic because triggered whenever user cl

c# - Variable ViewBag name in MVC -

basically, i'm working on project , i'm not sure how can put variable viewbag name, want because following code inside of while loop. list<selectlistitem> permissionlevels = new list<selectlistitem>(); permissionlevels.add (new selectlistitem {//skipping section, not relevant viewbag.@contactname = permissionlevels; and in view have inside of foreach loop: @html.dropdownlist(_currentpermissions.name) (yes, _currentpermissions correct name located.) what i'm trying here @contactname variable i'm not sure how it, best guess , can't seem find way it you can't this. fear not! there's better way handle problem. if need list of objects returned view, store list in viewbag or store property on model. since sounds you're building list of permissions per user, might something this: var permissionsdictionary = new dictionary<string, list<selectlistitem>>(); foreach (var user in users) { var listitems

entity framework - c# How to convert from GetType() to T -

i have method receives generic t data.helpers.entitykeyhelper.instance.getkeynames<t>(this); where t should be: type entitytype = dbentry.entity.gettype(); so need pass: data.helpers.entitykeyhelper.instance.getkeynames<entitytype>(this); but it's sending me error: the type or namespace name 'entitytype' not found (are missing using directive or assembly reference?) any clue on how can covert dbentry.entity t? you can use makegenericmethod , first need getkeynames method then: method.makegenericmethod(dbentry.entity.gettype()) .invoke(yourinstance, new object[] { });

java - Could not invoke method getObjectInstance on object of type com.ibm.ws.naming.urlns.genericURLContextFactory error on JNDI lookup -

Image
do know why i'm getting exception ? string url = "corbaloc:iiop:localhost:2809"; string initial = "com.ibm.websphere.naming.wsninitialcontextfactory"; string jndi = "ejblocal:my/ejb/periodobo"; hashtable<string, string> pdenv = new hashtable<string, string>(); pdenv.put("java.naming.provider.url", url); pdenv.put("java.naming.factory.initial", initial); context initialcontext = new initialcontext(pdenv); try{ object ejbhome = initialcontext.lookup(jndi); // <-- here object obj = portableremoteobject.narrow(ejbhome, periodobo.class); }catch(namingexception e){ system.err.println(e.tostring()); } i'm sure jndi ok, struggling ( what's default jndi name of ejb in websphere application server 7 (was)? ). could me please? this run configuration : update, have got stack trace, i'm analyzing : wscl0910i: initializing component: com.ibm.ws.websvcs.component.wasaxis2clientimpl wscl091

Reload page with anchor using Javascript or Jquery -

i using anchors in url kind of variable javascript, eg: mysite.com/itempage.html#item75 this works when click link on other page, not on actual page in question (itempage.html). instead of reloading page, clicking link changes url. since page not reload, none of javascript runs again. does know way reload page new url? so far have tried: html <div id="itemmenu"> <a id="item75" href="#">item 75</a> <a id="item11" href="#">item 11</a> </div> jquery $( "#itemmenu a" ).each(function(index) { $(this).on("click", function(){ var linkid = $(this).attr('id'); var winloc = "mysite.com/itempage#" + linkid; window.location = winloc; }); }); this indeed expected behavior: not reloading page, , scrolling page anchor. also, "#..." part purely happening on client-side, , browsers don't send part

javascript - Can I hide all text in a page independently from parent elements? -

Image
i'd know how hide/show text in webpage js or css without hiding containing elements. i've looked , looked , can't find how this. is possible? obviously go around adding spans text. i'm looking shortcut, involving text nodes or css solution. edit: if not, simple work-around same effect? i've noticed can use rgba opacity 0 achieve effect without adding container elements. problem is, affects borders too. font-color:color useful css feature here... you can make text invisible using 1 line of css: body.hidetext { font-size: 0px !important; } -- toggle hidetext class: $('body').toggleclass('hidetext'); (note more specific font-size: !important elsewhere in css override one, however, may not flawless solution.)

php - Prevent manipulation cookie on client side -

i know cookie work string , not accept array... far creating , reading cookie: setcookie( 'name' , 'my name foo' ); echo $_cookie['name']; // output name foo if user change cookie name to: name[] changes cookie name in array , error: array string conversion. 1) how can prevent kind of safe handling of cookies? 2) if work class of cookie, method should return strings? you have 2 choices: use session variables instead of cookies. validate cookes when use them. 1 part of encrypting cookie value, , prepending private key before value. script can decrypt cookie , test whether begins private key. can test whether user renamed cookie array: if (is_string($_cookie['name'])) { ... }

postgresql - Connecting to database through ssh tunnel -

our production databases accessible production application servers. able login production app servers , psql db, setup ssh tunnel allow me access production db work box. ideally, single command run workbox set tunnel/proxy on production app server here have come with, doesnt work. user@workbox $ ssh -fnt -l 55555:db.projectx.company.com:5432 app.projectx.company.com user@workbox $ psql -h app.projectx.company.com -p 55555 psql: not connect server: no route host server running on host "app.projectx.company.com" (10.1.1.55) , accepting tcp/ip connections on port 55555? the reported ip address incorrect. when connecting tunnel endpoint, hostname local host, since that's forwarded port exposed. ssh -fnt -l 55555:db.projectx.company.com:5432 app.projectx.company.com psql -h localhost -p 55555 btw, pgadmin-iii provides ssh tunnel automation. on other hand, it's big gui app without psql 's handy \commands . it's pretty trivial write ssh

java - Avoiding unwanted whitespace in Eclipse code template -

i created following code template instance of google's userservice : ${:import(com.google.appengine.api.users.userservice, com.google.appengine.api.users.userservicefactory)} userservice usersvc = userservicefactory.getuserservice();${cursor} which results in code output this: // blank line here (had show somehow) userservice usersvc = userservicefactory.getuserservice(); is there way avoid blank line before code insertion? i know if write template on 1 line (which makes template unreadable) can avoid undesirable blank line — there better/more elegant solution?

IntelliSense Error C Programming -

i working on c assignment , being getting errors following code char ba[20] = "hellow there"; char *pba; *pba = &ba; there red line under * , & in third line of code. getting these errors: intellisense: declaration has no storage class or type specifier intellisense: value of type "char (*)[20]" cannot used initialize entity of type "int *" is there anyway solve this? actually, error @ line 3. char ba[20] = "hellow there"; char *pba; pba = ba; //note :- address must passed pointer, not value @ pointer, *pba means value @ pba this solve purpose! hope found mistake.

c++ - Prevent or generate warning for custom deprecations -

i'm using c++11's static_assert perform compile-time checks prevent use of insecure functions, and/or provide feedback user when new feature should used , relevant apis out of date (e.g. using std::strftime , std::to_string , etc.). i want force failure if source code attempts use outdated functions, need totally cross-platform, , bypass or workaround other 'helpers' such microsofts own deprecations. i see can use .sections when working gnu toolchain, can see definition in openbsd's cdefs.h ( http://ninjalj.blogspot.co.uk/2011/11/your-own-linker-warnings-using-gnu.html ) have nothing equivalent visual studio. for example, can use following code without problem prevent strcpy / strcat : # define compile_time_check(expression, message) static_assert(expression, message) # define guarantee_failure (0 == 1) # define disabled_functions_message_cstring "strcpy, strcat must replaced strlcpy , strlcat, respectively" # define

c# - Cron trigger in Quartz.Net for hourly values -

i checking out cron triggers quartz.net , noticed when use other trigger apart hourly, offsets time utc(which should case), when same hourly cron, picks local time. for example suppose start time 2014-05-31 15:44:00 for hourly schedule next 6 occasions cron expression: 0 0 0/1 1/1 * ? * is given 5/31/2014 5:30:00 pm +00:00 5/31/2014 6:30:00 pm +00:00 5/31/2014 7:30:00 pm +00:00 5/31/2014 8:30:00 pm +00:00 5/31/2014 9:30:00 pm +00:00 5/31/2014 10:30:00 pm +00:00 this shows time in localtime. but when try weekly schedule cron: 0 44 15 ? * sun,mon * the schedule comes as 6/1/2014 10:14:00 +00:00 6/2/2014 10:14:00 +00:00 6/8/2014 10:14:00 +00:00 6/9/2014 10:14:00 +00:00 6/15/2014 10:14:00 +00:00 6/16/2014 10:14:00 +00:00 which offset utc, right. this code using var cron = new quartz.cronexpression("0 0 0/1 1/1 * ? *"); datetimeoffset? nextfire = cron.getnextvalidtimeafter(convert.todatetime("5/31/2014 4:30:00 pm")); obviously,

scala - Spark and YARN. How does the SparkPi example use the first argument as the master url? -

i'm starting out learning spark, , i'm trying replicate sparkpi example copying code new project , building jar. source sparkpi is: https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/sparkpi.scala i have working yarn cluster (running cdh 5.0.1), , i've uploaded spark assembly jar , set it's hdfs location in spark_jar . if run command, example works: $ spark_classpath=/usr/lib/spark/examples/lib/spark-examples_2.10-0.9.0-cdh5.0.1.jar /usr/lib/spark/bin/spark-class org.apache.spark.examples.sparkpi yarn-client 10 however, if copy source new project , build jar , run same command (with different jar , classname), following error: $ spark_classpath=spark.jar /usr/lib/spark/bin/spark-class spark.sparkpi yarn-client 10 exception in thread "main" org.apache.spark.sparkexception: master url must set in configuration @ org.apache.spark.sparkcontext.<init>(sparkcontext.scala:113) @ spark.sparkpi$.m

ios - MultiPeer Framework Delegates Not Firing/Running (No UI) -

i've been stuck on problem while. i'm trying test multi peer framework. , i'm trying without ui. in other words, i'm inviting other peers manually through code. want able app come up, , peers automatically start looking each other , connect. to set class named sidewaysmanager so: /** sidewaysmanager.m */ #import "sidewaysmanager.h" #import "epbmyconfig.h" @implementation sidewaysmanager { nsstring *databasepath; mcsession *currentsession; mcnearbyservicebrowser *nearbybrowser; mcnearbyserviceadvertiser *nearbyadvertiser; nsstring *servicetype; } - (id) init { self = [super init]; if(self) { epbmyconfig *configinfo = [epbmyconfig instance]; nsstring *assetid = [configinfo getassetid]; nsstring *useagelocation = [configinfo getuseagelocation]; nsstring *peerdisplayname = [@"pctouchpad-" stringbyappendingstring:assetid]; if(![useagelocation isequ

adding listbox value with multi value select to sql database in php -

i trying add multiple values sql table (program_celebrity) form post, have in form post following, reads table this: <label for="programlisting"></label> <select name="programlisting" style="width: 800px;" size="10" multiple id="programlisting"> <?php $sql_program_listing = "select * program order programname asc"; foreach($conn->query($sql_program_listing) $row_program_listing){ ?> <option value="<?=$row_program_listing["programcode"];?>" <?php if ($row_programlisting["id_program"] == $registrant['id_program']) echo 'selected="selected"';?>><?=$row_program_listing["programname"];?> (<?=$row_program_listing["releasedate"] .")";?> </option> <?php } ?> </select> what works fine add information comes fol

javascript - jquery $.each incorrect binding? -

<div id='a'>a</div> <div id='b'>b</div> <div id='c'>c</div> <div id='d'>d</div> this javascript: var first = [$('#a'), $('#b')]; var second = [$('#c'), $('#d')] var = [first, second]; (var i=0; i<everything.length; ++i) { var current = []; (var j=0; j<everything[i].length; ++j) { current.push(everything[i][j]); } $.each(current, function(i,d) { d.hover(function() { $(current).each(function() { this.css('background-color', '#00ff00') }); }, function() { // hover out $(current).each(function() { this.css('background-color', 'white') }); }); }); } this code little strange because took original code nerf down presentable here. why c,d highlighted when hover on a,b? fiddle: http://jsfiddle.net/c4rsj/4/ edit desired behavior: a,b highlight when hover

javascript - How do I get multiple returns from a for...in loop inside of a method? -

i'm learning javascript , decided try out working methods, constructors , this keyword. made method finding cars based on words match words inside of property values. if turns out word matches value, returns object. problem is, when multiple objects have same property values, first of them returned. how of objects same value return? can solved or solution advanced? tried ton of variations this keyword nothing worked. //the constructor function car(make, model, year, condition){ this.make = make; this.model = model; this.year = year; this.condition = condition; } //an object holds properties more objects var cars = { car1: new car("toyota", "corolla", 2013, "new"), car2: new car("hyundai", "sonata", 2012, "used"), car3: new car("honda", "civic", 2011, "used") }; //the method findcar = function(find){ for(var in cars){ if(cars[i].make.tolowercase() === find){

semantic web - Need indexing algorithm for ontology models -

i building semantic web crawler stores url , ontology models (triples) need indexing algorithm store same like page www.abc.com crawler extracts links www.abc1.com www.abc2.com www.abc3.com model www.abc.com#harry www.abc.com#friend www.abc.com#himanshu allegrograph indexing tool indexing rdf documents also sparql can used storing , retrieving rdf files dbms normal files

java - JSF+Facebook Integration One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL -

Image
i have created facebook application , details given screen shot ! but when clicking on jsf button login facebook getting below exception given url not allowed application configuration.: 1 or more of given urls not allowed app's settings. must match website url or canvas url, or domain must subdomain of 1 of app's domains. here code using redirect private void redirect(string url, httpservletresponse response) throws ioexception { string urlsessionid = response.encoderedirecturl(url); response.sendredirect(urlsessionid); } i tried other solution provided in other question found in stackoverflow not worked me . if (requesturl.indexof("login.xhtml") > 0) { callback = requesturl.replaceall("login.xhtml", "fblogin.xhtml"); } else if (requesturl.indexof("userregistration.xhtml") > 0) { callback = requesturl.replaceall("userregistration.

objective c - How to take my view as a picture osx -

i want take nsview (with layers) image can in osx ? in ios following -(uiimage*) makeimage//snapshot view { uigraphicsbeginimagecontext(self.view.bounds.size); [self.view.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *viewimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return viewimage; } i tried solution 1 of answers [[nsimage alloc] initwithdata:[view datawithpdfinsiderect:[view bounds]]]; but didn't work because have layers in nsview . i started converting ui ns , have warnings on every line :) -(nsimage*) makeimage :(rmblurredview*)view { uigraphicsbeginimagecontext(view.bounds.size); [self.view.layer renderincontext:uigraphicsgetcurrentcontext()]; nsimage *viewimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return viewimage; } i not familiar osx can 1 me convert code osx ? drawing image tad different in ios: you create

symfony - Is there a tool to refactor a YAML file, order the lines, switch from dot format to indent? -

in symfony 2, using translation:update command generate translations yml files templates have defined teh translation strings. i .yml files mixed up. i searching tool, script refactor : menu.home: __en.menu.home menu.projects: __en.menu.projects information.address: __en.information.address information.agent.languages.english: __en.information.agent.languages.english information.agent.languages.russian: __en.information.agent.languages.russian information.agent.name: __en.information.agent.name to : information: address: __en.information.address agent: languages: english: __en.information.agent.languages.english russian: __en.information.agent.languages.russian name: __en.information.agent.name menu: home: __en.menu.home projects: __en.menu.projects here code snippet ask: use symfony\component\yaml\yaml; use symfony\component\yaml\dumper; // ... $dottedyaml = yaml::parse(file_get_contents('dotted-file.yml')); $nestedyaml =

android - How keep services alive when the device turned off? -

there way keep service running if device turned off !?? (like alarm clock still working device off or no battery or clock setting still). looking information on question , not find hint. if answer me me , grateful you can't. instead restart service @ boot time, registering boot_complete broadcast receiver in manifest.

c++ - Virtual base function with template return type: compiler fails at derived class with pointertype as template argument (MSVC 2013) -

if derive cbaseinterface (see code below) template argument t=int*, compiler fails wirh error c2555. happens pointer types used t. if use typedef instead, same code works fine. // if _falis defined, compiler fails, else succeeds // (ms visual studio 2013 update 2, 32 , 64 bit native c++, debug build). #define _falis #ifdef _falis #define pint int* #else typedef int* pint; #endif template <class t> class cbaseinterface { public: virtual ~cbaseinterface() {} virtual const t calculate() const = 0; }; class ccalculator : public cbaseinterface<pint> { public: ccalculator() {} virtual ~ccalculator() {} // error c2555: 'ccalculator::calculate': // overriding virtual function return type differs , not 'covariant' // 'cbaseinterface<int *>::calculate' virtual inline const pint calculate() const final { return (pint)&m_item; } protected: int m_item = 0; }; where problem point

1's complement using ~ in C/C++ -

i using visual studio 2013. tried ~ operator 1's complement: int = 10; cout << ~a << endl; output -11 but for unsigned int = 10; cout << ~a << endl; the output 4294967296 i don't why output -11 in case of signed int . please me confusion. when put number 10 32-bit signed or unsigned integer, get 0000 0000 0000 0000 0000 0000 0000 1010 when negate it, get 1111 1111 1111 1111 1111 1111 1111 0101 these 32 bits mean 4294967285 unsigned integer, or -11 signed integer (your computer represents negative integers two's complement ). can mean 32-bit floating point number or 4 8-bit characters. bits don't have "absolute" meaning. can represent anything, depending on how "look" @ them (which type have).

Android Emulator option is not coming in Titanium Studio -

Image
i have installed titanium studio , installed android sdk in windows. after have created 1 test application. when right click on project folder run application cannot find android emulator option. what can now. not able test hello world app. please. correctly spotted swanand !!! emulator in list,d' scolz need start emulator titanium studio .and try run app when emulator in running state!!!hope works ..

scala - What's the difference between these two ways to declare functions? -

follow 2 similar functions, a , b , declared differently: scala> val = { x:int => x+x } a: int => int = <function1> scala> def b(x:int) = x+x b: (x: int)int the difference can find between 2 def function can specify parameter's name pass (e.g. b(x=1) ). how these functions different in other regards? should used when? edit: i not able use @tailrec annotation val method. the principal difference in how scala translates definitions. in scala lambda (an anonymous function, function value, function literal) , method different things. first definition of yours sugar instance of function1 class, 1 of classes used lambdas, second method of surrounding object, compiles standard java method. the practical difference between 2 scala cannot let refer method value, renders second class citizen. results in redundant indirections when dealing higher order functions. e.g., following: 1.to(4).map(b) desugars wrapper lambda: 1.to(4).map((x: int)

sql - Reduce database restore time -

i have database backup file of 4.78 gb. when restore on machine, takes lot of time (15 - 20 mins precise) restored. mdf file of database of 5.64 gb , ldf of 100mb. there lots of tables , lots of data in database. there way can reduce time taken restore backup file? restoring speed depends on various factors like processor speed your harddisk reading , writing speed. upgrading these factors should increase database restore time

vb.net - Casting Anonymous Type LINQ Using TryCast Returns Nothing -

i want query return list (of service) want use new list further filter. when run query exectutes correctly dim duplicateservice = svggrpcontainer.groupby(function(x) x.servicegroup).where(function(x) x.count > 1).select(function(x) x) i attempting cast in oder use , create query dim duplicatepak = duplicateservicegroups.groupby(function(x) x.name).where(function(x) x.count > 1).select(function(x) x) when cast first query returns nothing dim duplicateservice list(of servicegroup) = trycast(svggrpcontainer.groupby(function(x) x.servicegroup).where(function(x) x.count > 1).select(function(x) x), list(of servicegroup)) tolist throws grouping exception tried that. how cast query can further filter data in subsequent queries? or use 1 query , group both group , name? here's .net fiddle working solution (forgive c#). c#: https://dotnetfiddle.net/puqnss vb.net: https://dotnetfiddle.net/aixeib you need use anonymous object group multiple field

long integer - 64-bit Float Literals PHP -

i'm trying convert 64-bit float 64-bit integer (and back) in php. need preserve bytes, i'm using pack , unpack functions. functionality i'm looking java's double.doubletolongbits() method. http://docs.oracle.com/javase/7/docs/api/java/lang/double.html#doubletolongbits(double) i managed far comments on php docs pack(): function encode($int) { $int = round($int); $left = 0xffffffff00000000; $right = 0x00000000ffffffff; $l = ($int & $left) >>32; $r = $int & $right; return unpack('d', pack('nn', $l, $r))[1]; } function decode($float) { $set = unpack('n2', pack('d', $float)); return $set[1] << 32 | $set[2]; } and works well, part... echo decode(encode(10000000000000)); 100000000 echo encode(10000000000000); 1.1710299640683e-305 but here's gets tricky... echo decode(1.1710299640683e-305); -6629571225977708544 i have n

angularjs - Dependency on $translateProvider in factory? -

trying far basic angularjs app work translations support. first create app, configure $translateprovider . create factory data in set initial stuff in $rootscope , want set language. var app = angular.module('app', ['ngroute', 'pascalprecht.translate']); app.config(['$translateprovider', function($translateprovider) { $translateprovider.preferredlanguage('sv'); $translateprovider.usestaticfilesloader({ prefix: '/assets/translations/', suffix: '.json' }); }]); app.factory('data', ['$http', '$rootscope', '$translateprovider', function ($http, $rootscope, $translateprovider) { $http.get('/api/get/state').success(function(data) { $translateprovider.preferredlanguage(data.language); // ... set other stuff here in $rootscope }); } ]); the problem when run code get: error: [$injector:unpr] http://errors.a

android - Support Contextual Action Bar never inflates -

in order add contextual action bar application using support action bar v7 library implemented : my actionbaractivity (support v7) : package com.supinfo.cubbyhole.mobileapp.activities; import com.supinfo.cubbyhole.mobileapp.r; import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.support.v7.view.actionmode; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview; public class homy extends actionbaractivity { private actionmode mactionmode; private listview list; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_home); // instantiate , fill list custom adapter ... fine list = (listview) findviewbyid(r.id.home_list); string[] array = {&qu

WebApp does not open on Tizen Emulator -

i'm doing test apps , trying use tizen emulator see them running. but, when try open app, doesn't. at first, getting black screen when trying open it, looking answers saw people suggesting turn off gpu on emulator, due issue intel or something. after that, app not open @ all, it's i've never clicked on it. apperently, builds , install properly, doesn't open. i've tested sdb -e dlog tool on windows 7 64 bits try understand happening , i've got this: https://docs.google.com/document/d/18qfacyeyytndu5n8ztcex4mbozildb0wicuhuixtnq8/edit have seen this? thank help. i figured out emulator needs machine necessary configuration, listed on: https://developer.tizen.org/downloads/sdk/installing-sdk/prerequisites-tizen-sdk otherwise, webapps won't execute, using web emulator. thank help.

iphone - removeObserver not working for UIApplicationWillEnterForegroundNotification IOS -

hi developing iphone application in registering uiapplicationwillenterforegroundnotification notification. when tried unregister observer not working. still called. code looks in viewdidload method registering [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(applicationbecomeactive) name:uiapplicationwillenterforegroundnotification object:nil]; and on logout method tried remove observer [[nsnotificationcenter defaultcenter] removeobserver:uiapplicationwillenterforegroundnotification]; but not working. doing thing wrong. need help. thank you. that's because you're not removing observer. notice add observer method: [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(applicationbecomeactive) name:uiapplicationwillenterforegroundnotification object:nil]; the important part addobserver:self so in order remove observer, do: [[nsnotificationcenter defaultcenter] removeobserver:self]; or if wan

javascript - .onmousedown executing on page load -

i'm trying have different graph shown when click on different polygon. function executes when page loads, though defined .onmousedown . function function iscrtaj(data, arg) { alert(arg); var barwidth = 13; var w = 700; var h = (barwidth + 10) * data.length; var xscale = d3.scale.linear() .domain([0, d3.max(data, function (d) { return d.bodovi; })]) .rangeround([0, 280]); var yscale = d3.scale.linear() .domain([-1, data.length]) .range([0, h]); var bargraph = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); svg.selectall("rect") .data(data) .enter() .append("rect") .attr("x", 870) .attr("y", function (d, i) { return yscale(i); }) .attr("height", barwidth) .attr("width", wi

c# - Two db contexts under TransactionScope fails -

Image
i stuck using 2 db connections entity framework contexts under single transaction. i trying use 2 db contexts under 1 transaction scope. "mstdc not available". read it's not ef problem it's tdc not allow 2 connections. is there answer problem? this happens because framework thinks trying have transaction span multiple databases. called distributed transaction . to use distributed transactions, need transaction coordinator. in case, coordinator microsoft distributed transaction coordinator, runs widows service on server. need make sure service running: starting service should solve immediate issue. two-phase commit from purely theoretical point of view, distributed transactions impossibility* - is, disparate systems cannot coordinate actions in such way can absolutely either commit or roll back. however, using transaction coordinator, pretty darn close (and 'close enough' conceivable purpose). when using distributed transaction, eac

ios - how to draw above cashapelayer path -

i having cashapelayer want draw above layer.. have taken uiimageview , added on cashapelayer , starting drawing user touch moves inside cashapelayer path. when user touch ends want merge drawn image view on cashape layer in such way if users taps again using hittest method can again path of cashape layer. // tempdrawingimage image view added above hit layer. uigraphicsbeginimagecontext(tempdrawingimage.frame.size); [hitlayer drawincontext:uigraphicsgetcurrentcontext()]; [tempdrawingimage.image drawinrect:tempdrawingimage.frame]; hitlayer.contents = (id) uigraphicsgetimagefromcurrentimagecontext().cgimage; uigraphicsendimagecontext(); you cannot convert image path cashapelayer. you need have drawingpath modified according touch events. second cashapelayer needed draw current drawingpath (since same results while drawing after merge not guaranteed using image approach). when merging need append drawingpath path of shapelayer.

.net - Retaining order of the xml elements between serialization and deserialization in C# -

i have generated c# class xml schema. class used in tool perform following: read xml deserializing make changes deserialized object. write processed deserialized object xml serializing. basically fill data in xml. i have problems in retaining order of elements between deserialization , serialization. i have sample code below. fpnodetypewindowfield , fpnodetypeclass1field can appear interchangeably in 2 xmls. order of these fields not fixed in xml. don't face problems while reading xml while deserializing. order of these fields follow order mentioned in code. is there possible solution retain order of these fields in xml? /// <remarks/> [system.codedom.compiler.generatedcodeattribute("xsd", "4.0.30319.1")] [system.serializableattribute()] [system.diagnostics.debuggerstepthroughattribute()] [system.componentmodel.designercategoryattribute("code")] [system.xml.serialization.xmltypeattribute(anonymoustype = true)] [system.xml.seri

android - open ANY SQLiteDatabase as su/root -

i know, can start process root user, how can create sqlitedatabase given path (any path, i.e. another's app database)? root user in root process... i tried reading file directly, not work (it asks every time root access again) , prints empty result (because sqlite3 not found) string path = "/data/data/<app_package>/databases/<database_name>"; process p = runtime.getruntime().exec("su sqlite3 -csv " + path + " \"select * test\";"); stringbuilder res = new stringbuilder(); string line; while ((line = bufferedreader.readline()) != null) res.append(line + "\n"); actually, want read content of app's database, how can properly? content 1 of 2 following solutions: get content of query csv or similar getting sqlitedatabase object root, given database path (preferred, more flexible) partially solution found: see answer... but: still 1 problem, asks su permissions every time, how can avoid this?

javascript - jQuery: avoid code duplication because of fadeOut() -

here's problem i've faced many times: i have element may or may not visible i need stuff element if element visible, fadeout() element once stuff done: fadein() element the problem here: code looks this: function showonlyelement(myel) { $('body') .children('div:not(.'+myel+')') .fadeout() .promise().done(function() { var el=b.children('div.'+myel); if (el.is(':visible')) { /* have hide before modifying */ el.fadeout(function() { /* long code (a) modifying innerhtml of el */ el.fadein(); }); } else { /* again same long code (a) modifying innerhtml of el */ el.fadein(); } }); } i want make clean there's not repetition of same long code (a) how do (generic way of doing this)? simple generic solution : $(&

php - how to htaccess pwd-protect a WP login? -

i have tried instructions in guide http://titanfusion.net/how-to-protect-wp-login-php-using-htaccess-and-htpasswd/ i got "error, webserver misconfigured" setup. i tried following on wp-admin directory (but if below coda had worked, wouldn't protect actual login page, wp-admin sites behind login form, think. in .htaccess: authtype basic authname "password required" authuserfile /www/passwords/password.file and used web generator actual password-file should ok. anyone know of working guide how set up? if .htaccess file in folder password.file can try this: authuserfile password.file

svg - How to change 2d coordinates from side view to top view -

now using svg tool create 2d objects , able see side view . dont know how write coordinates top view . coding side view follows . how can change coordinates top view . tried lot , search in google unable find answer me it "bat": "m143.40468,206.20782c-0.49527,-8.51843 -1.60919,-23.17813 -13.91826,-16.10698c-5.69614,2.11977 -22.79842,7.51244 -14.5293,-3.62979c-4.53243,-11.10219 -22.97476,5.42294 -24.24419,-2.29205c9.91943,-10.64906 -4.7813,-22.35199 -15.17139,-14.80321c-6.39341,1.76166 -19.4276,12.91188 -21.9789,9.37552c5.93793,-7.52516 19.31312,-22.93167 3.18112,-27.55084c-17.5302,-3.97589 -32.93319,8.09392 -48.1771,14.68205c-4.57452,3.57106 -10.39707,2.94862 -4.70683,-2.99597c19.7419,-30.64111 50.72646,-53.70857 85.10566,-65.43076c8.33369,-2.70812 21.16511,-8.70424 21.41656,4.97536c5.15313,12.59007 8.81947,28.33097 22.08977,34.80917c15.28362,8.49702 4.32793,-24.52711 20.16156,-12.05241c6.66379,4.32207 20.92268,-3.91697 22.87737,0.71265c-3.88257,5.55579 -5.70456,15

Crystal Report prompts for the same parameter twice -

i using cr 2011. in report, used command datasource. in command used parameters restrict amount of record read. simplified version of command that: select .. ... mydate between {?start} , {?stop}. the report worked correctly, 1 annoying thing report asked dates entered twice. dates prompted when command run , prompted again along other parameters. do have work around issue? thanks,

python - Why does this script close immediately even though I ask for input? -

i can't output in python code. import random die1=random.randrange(5) die2=random.randrange(5) total=die1+die2 input=("\npress enter key exit.") the black window closes when opened you not calling input() ; assigning string name input instead. remove = : input("\npress enter key exit.")

php - using regex to separate string in groups -

i want parse string this: [np amanda brumfield],[np estranged daughter][pp of][np actor billy bob thornton],[vp found][adjp guilty][pp of][vp aggravated][np manslaughter][pp of][np child] and in case recognise these groups: [np amanda brumfield][np estranged daughter][pp of][np actor billy bob thornton] , [adjp guilty][pp of] , [np manslaughter][pp of][np child] in other words, should use string [vp \w+] split string. how write regex that? @casimir et hippolyte mentions using preg_split() , correct. following split given input way requesting: $parts = preg_split('/\[vp\s+(?:[^\]])+\]/', $input); that pattern should allow pretty after initial vp , 1 or more spaces prior closing ] . php should fine non-capturing parens well.

New Deck of cards display in a textbox -

private void getnewdeck_click(object sender, eventargs e) { string[] suit = { "c", "d", "h", "s" }; string[] num = { "2", "3", "4", "5", "6", "7", "8", "9", "t", "j", "q", "k", "a" }; (int j = 0; j < 4; j++) { (int = 0; < 13; i++) { newdecktextbox.text + = (suit[j] , num[i]"\n"); } } } i trying display new deck of cards in multiline textbox(newdecktextbox) when click button getnewdeck_click button.iam having error newdecktextbox.text line.. the output should c2 c3 c4 c5 c6 c7 c8 c9 c10 cj cq ck ca d2 d3 d4 d5 d6 d7 d8 d9 d10 dj dq dk da h2 h3 h4 h5 h6 h7 h8 h9 h10 hj hq hk ha s2 s3 s4 s5 s6 s7 s8 s9 s10 sj sq sk sa thanks this bit better stringbuilder sb = new stringbuilder();

typeconverting - TinyOS: converting uint16_t and uint8_t into uint32_t -

i'm having following problem: i have uint8_t h_msb , uint16_t h_lsb , iwant combine them uint32_t so here code: void parseheader(mypackage header,uint32_t* timestamp ){ (*timestamp) = (header->h_msb <<16)| header->h_lsb; } but not seem work; i tried h_msb = 10 , h_lsb= 10 i 10 timestamp. the problem seems if shift beyon 7 bit information h_msb ist lost, how can since timestamp uint32_t ? the problem h_msb uint8_t , shift operation performed within uint8_t type (or possibly within uint16_t , doesn't matter), 0 . cast uint32_t before shifting: (*timestamp) = (((uint32_t)header->h_msb) << 16) | header->h_lsb;

c# - Edit iso file with discutils -

i'm trying modify existing iso file adding files using discutils. far i've tried cdbuilder allows creating iso file. cdreader can open file , can enumerate contents can't find way of adding files. can point me in right direction? edit: there's cdreader class can used open existing .iso file. once open, can enumerate contents should wish extract files, there no clear method adding file. e.g. using (filestream fs = file.open(imagefilepath, filemode.open)) { cdreader cd = new cdreader(fs, true, true); foreach (var dir in cd.root.getdirectories()) { console.writeline(dir.name); } } there cdbuilder class used build .iso files scratch, cannot used open existing .iso file. yes create temporary copy of .iso image cdbuilder object consume lot of memory when adding large number of files. can discutils library used purpose? thanks .net discutils supports reading or creating iso files. modifying not supported yet. ,

java - Play Framework templates -

i've started playing play framework , wondering: there way write templates using not scala java? e.g. link http://www.playframework.com/documentation/2.1.0/javaguide3 provieds great tutorial start with, scala code makes hard me understand anything... i mean, learn amazing if it's possible write in java sure, can use freemarker template language. https://github.com/guillaumebort/play2-freemarker-demo