Posts

Showing posts from August, 2014

What is the purpose of the symlinks within the include and local directories in a python virtualenv? -

what purpose of symlinks automatically created within include , local in virtualenv? when run: virtualenv myvirtualenv it creates following directory structure , symlinks: myvirtualenv/ ├── bin ├── include │   └── python2.7 -> /usr/include/python2.7 ├── lib └── local ├── bin -> ../bin ├── include -> ../include └── lib -> ../lib why important virtual environment track /usr/include/python2.7 or have additional references own directories? ever different set here?

Jquery filter on php generated Divs -

i can't seem figure out why jquery isn't filtering. jquery function not correct or php using generate divs wrong. each generated div so each generated div looks so <div class="content" style="background-color: firebrick"> content </div> this code on page jquery function <html> <head> <link rel="stylesheet" href="css/logged_in.css"> <?php include("login_php_scripts.php"); ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $('#filter').keyup(function () { var filter = $("#filter").val(); $('#warnings').each(function() { $(this).find("div:not(:contains('" + filter + "'))").hide(); $(this).find("div:contains('" + filter + "')").show(); }); }); </

r - Get the SHA of the version used when run -

is possible sha of version of code being run in r? i have following code, outputs sha master head: readme<-file("info.txt") writelines(paste(c("document produced using version", paste(readchar("./.git/refs/heads/master", 10)), "of code")), readme) close(readme) but if makes mistake , accidentally runs code different branch? possible r active branch that? possibly this, activebranch figured out other bit of r code? readme<-file("code version info.txt") writelines(paste(c("document produced using version", paste(readchar(paste("./.git/refs/heads/", activebranch, collapse = ""), 10)), "of git instructions")), readme) close(readme)

php - Add prefix to link url in wordpress -

i want add image link on wordpress site redirect user page of same url different prefix. example page url mydomain.com/post1234 when user click image on page redirect user url mydomain.com/md/post1234 the following code print current page url on every post page on site want add "md" prefix in url <a href="<?php $path=$_server['request_uri']; $uri='http://www.example.com'.$path; ?>"><img src="<?php bloginfo('template_url'); ?>/images/sgxx.png">click here</a> pls suggest correct code this. try this: <?php $domain = get_site_url(); //you can use or either "http://".$_server[http_host]; $path = $_server[request_uri]; $prefix = "/md"; ?> <a href="<?= $domain.$prefix.$path ?>">link</a> for more info $_server , check link below: http://php.net/manual/en/reserved.variables.server.php

c++ - Substring Replace Vector -

this minimal code sample i'm trying create array of substrings find can replace them single word. in case i'm changing common greetings simple 'hi'. the problem when run code i'm getting error. error: no matching function call 'std::vector >::push_back(const char [4], const char [4], const char [3])' if me understand why error occurring , suggest solution perfect. #include <iostream> #include <string> #include <algorithm> #include <cctype> #include <ctime> #include <vector> vector<string> hiword; hiword.push_back("hey", "sup", "yo"); (const auto& word : hiword){ while (true) { index = r.find(word); if (index == string::npos) break; r.replace(index, word.size(), "hi"); } } you might want start creating vector of strings want search , replace: vector<string> searchwords = {"hey", "hello

java - Sorting int field of the wrapper class spring -

i have navigation class dynamically creating navigation having 2 tables folder(it directory contains files) , content(it files or pages render content on public site). have created navigation class in having wrapper class merging fields of content folder. have tried using @orderby , @ordercolumn came know work collections. list<folder> folder = folderrepository.findallbynavdepthlessthanorderbynavdepthasc(3); here sorting navdepth(this column belongs folder entity) want sort navorder(this column belongs content entity) @service public class navigationservice { @qualifier("jdbcmysql") private jdbctemplate jdbctemplate; private folderrepository folderrepository; private folderservice folderservice; @autowired public navigationservice(jdbctemplate jdbctemplate, folderrepository folderrepository, folderservice folderservice) { this.jdbctemplate = jdbctemplate; this.folderrepository = folderrepositor

java - Obtaining list views in Jenkins from nested view plugin -

i have developed plugin has extension point listviewcolumn have run problems when combining plugin, nested view plugin . my plugin enables 1 select jobs in current view , make modifications 1 button press. when view resides inside nested view, can't find view (from java code , jelly scripts) , no modification can made. in columnheader.jelly execute ${it.getheadertext(view.name)} where getheadertext() defines as public string getheadertext(string viewname) { hudson.getinstance().getview(viewname); // access jobs return object of .getview(viewname) return viewname; } this works fine regular list views whenever enter nested view's list view, getview(viewname) returns null. upon further investigation i've noticed nested views show when calling hudson.getinstance().getviews(); which returns views in toplevel of whole jenkins instance (no views inside nested views). here have nested view shows , instance of hudson.plugins.nested_view.nestedview.

How to create a dynamic textarea showing value of input slider using jQuery/Javascript? -

suppose there input[type=range] . use jquery (or javascript) dynamically create textbox show value of input when being changed. textbox floating below input slider knob/arrow/dot. also, after value change completed, textbox should automatically hidden/removed. how go it? this pretty simple var ismousedown = false; $('#slider').mousedown(function(e){ ismousedown = true; $('#val').show().css({left:e.clientx,top:$(this).offset().top + $(this).height()}).val(this.value); }) .mousemove(function(e){ if(ismousedown){ $('#val').show().css({left:e.clientx,top:$(this).offset().top + $(this).height()}).val(this.value); } }) .mouseup(function(){ ismousedown = false; $('#val').hide(); }); #val{ position:absolute; display:none; width:20px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input id="slider&quo

git - Squash commits directly on feature without rebase or merge -

i've been reading little --squash ing commits, seem go hand in hand --rebase . i have feature branch set of commits this: (feature) --> b --> c --> d --> e --> f --> g / (master) m1 --> m2 --> m3 suppose want merge master branch, want clean commits on feature first. is possible to: pick commit b, e , f , squash them 1 commit? or can squash commits come in order, squash: (a, b , c), or squash (d, e , f) etc? either way, can squash directly on feature, without immidiately initializing merge or rebase it? if so, how can git? yes , no. yes, can avoid changing parent of commit 'a' believe can't avoid git rebase . can interactive rebase on same root: git rebase -i m2 feature then can whatever want , @ end branch feature still start commit m2.

dataframe - how to add specific row and columns from pandas -

i have data set below when tried sum column sum year. want sum jan dec. the code tried is data.sum(axis=0) out[64]: year jan feb mar apr may jun jul aug sep oct nov dec 0 1981 32 26 62 22 23 98 80 163 13 122 144 109 1 1982 42 30 54 50 192 37 52 77 48 46 74 52 2 1983 78 10 107 46 36 105 80 25 188 58 36 78 3 1984 72 29 34 11 29 97 67 51 145 114 51 51 4 1985 83 37 42 69 23 25 104 50 76 53 74 63 5 1986 50 12 69 51 77 39 121 234 56 45 54 89 6 1987 23 28 22 4 55 77 92 122 65 34 54 24 7 1988 72 64 40 37 41 51 106 173 36 69 38 66 8 1989 9 28 51 55 38 42 11 68 23 74 55 59 9 1990 74 79 56 46 30 25 128 42 153 79 60 42 10 1991 59 29 41 24 78 142 54 124 71 27 47 37 filter columns first , sum : in [2

Dechunking a string in python -

i have array of bytes in python, looks this: chunk_size = 8 = b'12341234a12341234b12341234c12341234...' i have remove each nth byte (a, b, c in example). array length can many thousands. typical chunk size can 128 or few thounds. this current solution: chunk_size = 8 output = b"".join([ i[:-1] in [ a[j:j+9] j in range(0, len(a), chunk_size + 1) ]]) i looking other solutions, more elegant. python 3.x solutions fine. i'd pull 'chunk , skip' logic out generator, like: >>> = b'12341234a12341234b12341234c12341234' >>> def chunkify(buf, length): ... while len(buf) > length: ... # next chunk buffer ... retval = buf[:length] ... # ...and move along next interesting point in buffer. ... buf = buf[length+1:] ... yield retval ... >>> chunk in chunkify(a, 8): ... print chunk ... 12341234 12341234 12341234 >>> ''.join(chunk chunk in chunkify(a, 8)) '

php - Security For URL'S Laravel 5.1 -

i developing application in laravel 5.1, have multiple users have different permits , when log in can edit example account , route app/user/1/edit if user change id app/user/2/edit can edit information of other user, there way protect url? :d one of solutions putting middleware on route , comparing logged users id 1 in url (for routes actually, viewing, editing etc) 1 using user/edit instead , getting id directly session data, , recommend of course still have make sure nobody can post id, middleware or getting user id session instead of post save

WSO2 API manager claims cache -

i've switched using wso2 api manager version 1.9 1.8, looks good, except i'm getting exception when trying populate claims in jwt token. java.lang.illegalstateexception: cache status not started @ org.wso2.carbon.caching.impl.cacheimpl.checkstatusstarted(cacheimpl.java:287) @ org.wso2.carbon.caching.impl.cacheimpl.get(cacheimpl.java:171) @ org.wso2.carbon.apimgt.impl.token.defaultclaimsretriever.getclaims(defaultclaimsretriever.java:82) @ org.wso2.carbon.apimgt.impl.token.jwtgenerator.populatecustomclaims(jwtgenerator.java:92) @ org.wso2.carbon.apimgt.impl.token.abstractjwtgenerator.buildbody(abstractjwtgenerator.java:185) @ org.wso2.carbon.apimgt.impl.token.abstractjwtgenerator.generatetoken(abstractjwtgenerator.java:141) @ org.wso2.carbon.apimgt.keymgt.handlers.abstractkeyvalidationhandler.generateconsumertoken(abstractkeyvalidationhandler.java:146) @ org.wso2.carbon.apimgt.keymgt.service.apikeyvalidationservice.validatekey(apikeyvalidati

How to kill a running bash file with php -

i have 2 buttons "start acquisition" , "stop acquisition", the start button executes bash file , works fine: <form action="control.php" method="post"> <input value="continous acquisition " name="continuous" type="submit"> </form> <?php if (isset($_post['continous'])) { shell_exec('sh /desktop/run_test.sh'); } ?> i have no idea how stop execution when stop button pressed <form action="control.php" method="post"> <input value="stop acquisition " name="stop" type="submit"> </form> any appreciated. thank you. to run program in background, command should take form: nohup sh /desktop/run_test.sh & to stop program, first find process id (pid), assuming here there 1 instance, otherwise you'll need differentiate instances: $exec_output = array(); $actual_pid = 0; exec("pgrep

openssl - ASN1 parsing with swift -

i think basic idea behind asn.1 parsing. walk bytes, interpret them , useful them. alas stuck on implementation. apple has no sample code (that find), security reasons. openssl not documented, can guess @ functions do. sample code in swift did find doesn't handle case 17 (the in-app purchases), 1 thing interested in. i tried figuring out in data stream pointer located, same nonsensical result of 49. let receiptcontents = nsdata(contentsofurl: receiptlocation)! let receiptbio = bio_new(bio_s_mem()) bio_write(receiptbio, receiptcontents.bytes, int32(receiptcontents.length)) contents = d2i_pkcs7_bio(receiptbio, nil) //parsing var currentindex = unsafepointer<uint8>() var endindex = unsafepointer<uint8>() let octets = pkcs7_d_data(pkcs7_d_sign(self.contents).memory.contents) var ptr = unsafepointer<uint8>(octets.memory.data) let end = ptr.advancedby(int(octets.memory.length)) println(ptr.memory)

jhipster generator to create JPA Entity representing nested documents in MongoDb collection -

i using jhipster mongodb. how can define jpa entity representing nested document in mongodb collection using "yo jhipster:entity" eg: { _id: "joe", name: "joe bookreader", addresses: [ { street: "123 fake street", city: "faketon", state: "ma", zip: "12345" }, { street: "1 other street", city: "boston", state: "ma", zip: "12345" } ] }

powershell - Web Config changes for deployment slots in Azure -

i have created 3 deployment slots on azure website. devtest qa staging for each slot need customize web.config file. changes through out web.config file , not in appsettings , connectionstring sections, such web service endpoints, smtp details, logging details, debugging details, etc... it seems though azure supports changes in connectionstring , appsettings. how configure these different slots update rest of web.config? the end result would continuously integrate devtest, swap qa, staging , production. have tried release management seems support azure vm deployments. noob @ powershell believe may answer. any appreciated. ====== resolution ====== so, thought i'd feedback on else looking way this. created webconfig.cs class follows: [assembly: webactivatorex.preapplicationstartmethod(typeof(webconfig), "populatefromappsettings")] namespace application.presentation.web { using system; using system.configuration; using system.xml;

formatting - Insert newline character after every line using Python -

i'm trying insert newline character text file after every line. so if data: dose atra_minus_tet tet 0.001 5.100033162 0 0.001967886 9.651369961 0 0.003926449 16.72520921 0 i want: dose atra_minus_tet tet 0.001 5.100033162 0 0.001967886 9.651369961 0 0.003926449 16.72520921 0 my code: def prepare_steady_state_data(self,data_file): open(data_file) f: lines= [line+'\n' line in f.readlines()] open(data_file[:-4]+'_for_ss_fit.txt','w') f: f.write(str(lines)) the problem writes string literally, so: ['dose,cyp26(atra_plus_tet),tet\n\n', '0.001,26.67599946,1\n\n', '0.001006932,26.89620879,1\n\n', '0.001013911,27.117882,1\n\n', '0.001020939,27.34102614,1\n\n'] how change code desired format in output text file? with thanks, ciaran with open(data_file) source: open(data_file[:-4]+'_for_ss_fit.txt','w') output: line in source:

c++ - Defining interface of abstract class in shared library -

say have abstract base class defined so: interface.hpp #ifndef interface_hpp #define interface_hpp 1 class interface{ public: virtual void func() = 0; }; #endif // interface_hpp then compile translation unit test.cpp shared object test.so : test.cpp #include "interface.hpp" #include <iostream> class test_interface: public interface{ public: void func(){std::cout << "test_interface::func() called\n";} }; extern "c" interface &get_interface(){ static test_interface test; return test; } if open shared object in executable , try call get_interface this: #include <dlfcn.h> #include "interface.hpp" int main(){ void *handle = dlopen("test.so", rtld_lazy); void *func = dlsym(handle, "get_interface"); interface &i = reinterpret_cast<interface &(*)()>(func)(); i.func(); // print "test_interface::func() called" dlc

javascript - Failed to instantiate module formlyBootstrap -

i've installed angular-formly-templates-bootstrap via bower on project i've been working on. when try inject in angular, receive following error: uncaught error: [$injector:modulerr] failed instantiate module bandar due to: error: [$injector:modulerr] failed instantiate module formlybootstrap due to: error: [$injector:nomod] module 'formlybootstrap' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument. http://errors.angularjs.org/1.4.1/$injector/nomod?p0=formlybootstrap @ http://localhost:3000/bower_components/angular/angular.js:68:12 @ http://localhost:3000/bower_components/angular/angular.js:1949:17 @ ensure (http://localhost:3000/bower_components/angular/angular.js:1873:38) @ module (http://localhost:3000/bower_components/angular/angular.js:1947:14) @ http://localhost:3000/bower_components/angular/angular.js:4355:22 @ foreach (http://localhost:3000/bower_compon

BsonElement attribute and custom deserialization logic with MongoDB C# driver -

consider following example: public class foo { private string _text; [bsonelement("text"), bsonrequired] public string text { { return _text; } set { _text = value; bar(_text); } } private void bar(string text) { //only relevant when text set user of class, //not during deserialization } } the setter of text property and, subsequently, method bar called both when user of class assigns new value property , during object deserialization mongodb c# driver. need ensure bar called when text property set user , not during deserialization. i see 2 solutions don't suit me: the first move bsonelement attribute backing field. however, far know, bsonelement attribute used in query building mongodb c# driver, lose ability use text property in queries. the second solution make text se

Flex Data binding on an mx component's property -

getting warning compiler data binding won't see assignments "cmrepeater" <mx:repeater id="cmrepeater"> <support:cancelmembershiprowselector lineitem="{cmrepeater.currentitem}" selectedticketsobj="{selectedticketscancel}" /> </mx:repeater> also getting can't see assignments "tickets" here derep repeater , currentitem xml object. dataprovider="{derep.currentitem.tickets.ticket}" itemclick="viewcharacs(event);"> thanks help! i don't think work if try bind xml object or property directly might work if convert data arraycollection, like <fx:declarations> <fx:model id="myxml" source="../assets/myxml.xml"/> <s:arraycollection id="myarraycollection" source="{myxml.mynode}"/> </fx:declarations> <mx:repeater id="cmrepeater" dataprovider={myarraycollection}> <support:cance

How to detect soft menu key available in android device? -

i check menu key presence in device in android application. achieve used following code detect weather device having hardware menu or not , working fine !viewconfiguration.get(scscommander.getinstance().getapplicationcontext()).haspermanentmenukey() but did not find logic find weather device having soft menu present or not. please suggest me there way detect soft menu available or not in device. there no reliable/clean way check if soft menu (aka navigation bar) present or not! you may try using below code (not tested on devices , not reliable solution anyways): boolean hasnavbar(context context) { resources resources = context.getresources(); int id = resources.getidentifier("config_shownavigationbar", "bool", "android"); if (id > 0) { return resources.getboolean(id); } else { // check keys boolean hasmenukey = viewconfiguration.get(context).haspermanentmenukey(); boolean hasbackkey =

python - How to get currently logged user id in form model in Django 1.7? -

let's have webpage displays songs. , let's there public , private songs. public songs available see, while private songs songs user has created , available him see. user should see songs owner_id == null , owner_id == currently_logged_in_user_id (his own id) model: import .... class song(models.model): name = models.charfield(max_length=100) duration = models.integerfield(max_length=15) owner = models.foreignkey(settings.auth_user_model, null=true, blank=true) def __unicode__(self): return self.name view: from django.shortcuts import render, redirect, get_object_or_404 django.contrib.auth.decorators import login_required songapp.models import song songapp.forms import songinfoform @login_required def song_info(request): song = get_object_or_404(box) song_status = song.get_status() form = songinfoform(initial={'song_list': song.song_list}) return render(request, 'songapp/song_info.htm

asp.net mvc - Displaying the full name with Enums and resource file in c# MVC -

giving 1 more try i have enums.cs file have following code public enum authorizinglevels { [display(name = "authorizinglevels_syssupport", resourcetype = typeof(resources.enums))] syssupport } and when try calling display name, doesn't work viewbag.authgroupfullname = enums.authorizinglevels.syssupport.tostring(); it displays syssupport instead of full name systems support i went link provided in previous question ( how display name attribute of enum member via mvc razor code? ) , added code peter kerr /// <summary> /// generic extension method aids in reflecting /// , retrieving attribute applied `enum`. /// </summary> public static string getdisplayname(this enum enumvalue) { var displayattrib = enumvalue.gettype() .getmember(enumvalue.tostring()) .first() .getcustomattribute<displayattribute>();

wpa - Make Android hotspot use WPA2 PSK -

my app configures , activates access point: // expose required method wifimanager wifimanager = (wifimanager)context.getsystemservice(context.wifi_service); method setwifiapenabled = wifimanager.getclass().getmethod("setwifiapenabled", wificonfiguration.class, boolean.class); // set configuration wificonfiguration myconfig = new wificonfiguration(); myconfig.ssid = "markhotspot"; myconfig.allowedprotocols = wificonfiguration.protocol.rsn; myconfig.presharedkey = "markpass"; // configure , enable access point setwifiapenabled.invoke(wifimanager, myconfig, true); the hotspot comes correctly, no security - no wpa2, wpa, wep etc. how can make use wpa2 please? you can define key management sample code: private boolean setwifiapenabled() { boolean result = false; // initialise wifimanager first wifimanager.setwifienabled(false); method enablewifi; try { enablewifi = wifimanage

xml - C# How to traverse a subtree with recursion? -

i guess, have set first starting point want explore subtree, build recursive call. example: <realroot> <node> <desiredroot> <rootchild/> <nestedchild/> <rootchild/> </desiredroot> </node> </realroot> my goal iterate only: <desiredroot> <rootchild/> <nestedchild/> <rootchild/> </desiredroot> what's best solution in c# so? if understand correctly: simple example display names , types of elements: var xmlstr = @"<realroot> <node> <desiredroot> <rootchild/> <nestedchild/> <rootchild/> </desiredroot> </node> </realroot>"; var xd = xdocument.parse(xmlstr); var el = xd.root.element("node").descendants(); foreach (var x in el) console.writeline("{0} [{1}]"

java - AsyncTask keeps on giving output and updating my list -

this asynctask code , using populate custom listview . think wrong code .this piece of code keeps on running , don't know how many times. @ end giving me right results after many updates on textview (designation). not degrading performance of application showing multiple updates on textview before reaching result. i getting data in desig[0] variable , have on code . data coming azure don't worry if not azure guy . me on java part. one more thing whole code inside getview() method . final string[] desig = new string[1]; try { mclient = new mobileserviceclient( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", getcontext()); muser = mclient.gettable(user.class); new asynctask<void, void, boolean>() { @override

./configure Can I to use /some/path/configure - Unix, Linux -

why needed (inside container directory): # cd /container/directory/ # ./configure instead of: # pwd /external/path # /container/directory/configure maybe because calling ./configure /container/directory/ created files inside of /container/directory/ is there option create files (makefiles,etc ) inside of /container/directory/ calling /external/path ? something like: # /container/directory/configure --createoutputfiles=/container/directory/ the autotools explicitly designed work way seeing (with output files in current directory opposed directory of configure script) because designed support out-of-tree builds. idea build can happen somewhere other in source directory. this lets have per-arch builds in clean fashion, lets blow away built files , not source files, etc. i don't know if there reliable , portable way automatically determine location of executing script (see bash faq 028 discussion this). if there isn't makes doing want automatic

ibm mobilefirst - Cannot add custom device in Mobile Browser Simulator (MFP 7.0) -

i tried adding custom device mbs using studio component (as specified here ) device not appear in add device list. tried restart mf dev server or eclipse + clear workspace... no luck. any ideas? i cannot work well. looks defect. to have fixed need open ibm pmr (support ticket), see no local workaround work.

semantic web - Is owl:complementOf same as owl:disjointWith in RDF? -

i puzzled real meaning. if hae class meat, can define not meat class "notmeat". can use owl:complementof here. man , women? can use owl:complementof "woman" not "man"? if not, there way describe disjointness of man , woman class without using owl:disjointwith? can use property "disjoint" in both class , use property predicate in triples subjects , objects "man" , "woman" class describe disjointness? the difference complement of class class b such union b equivalent top (thing, resource, or whatever represents individuals in interpretation), while disjoint means , b not share individuals. for example, if our individuals mammals, can male complement of female. however, if individuals mammals , trees, male , female no longer complement of each other, because there trees, neither. 2 classes still disjoint.

node.js - Bluebird promises freeze when using Sinon's fake timer -

the following test freezes when used sinon's fake timers , bluebird. var sinon = require('sinon'); var promise = require('bluebird'); describe('failing test', function() { beforeeach(function() { this.clock = sinon.usefaketimers(); }); aftereach(function() { this.clock.restore(); }); it('test', function(done) { promise.delay(1000).then(function(){ done(); //this never gets called }); }); }); i using mocha (v2.2.5) bluebird (v2.9.33) , sinon (v1.15.3). i tried suggestions offered in discussions in bluebird , sinon couldn't make work. seems issue way sinon stubs setimmediate other have no clue how resolve this. you need step fake timer manually so: describe('failing test', function() { it('test', function(done) { promise.delay(1000).then(function(){ done(); //this never gets called }); // // advance clock: // this.clock.tick(1000);

jquery - Changing the name od a dropdown using javascript onchange -

hi need change name of dropdown box depending on selected list. <form name="dofilter" method="post" action="<%=site_url%>/product"> <select name="ff" onchange="form.submit();"> <option value="">--</option> <option value="brut">brut</option> <option value="moet"> moet</option> </select> </form> if option brut selected need select name fk , if option moet selected need select name ff help please this how did it: $("form > select").change(function () { $(this).parent().attr("name", $(this).find("option:selected").attr("id")); }); here jsfiddle demo. you can check inspecting element see name change instantly.

ios - Weird Issue with Parse -

my app working fine. last hour crashing giving me log: channel name must start letter: 2 (code: 112, version: 1.7.2) i using parse push notification service , following code subscribe channel: nsstring *str =[[nsuserdefaults standarduserdefaults]objectforkey:@"useremail"]; //asd@lop.com str = [str stringbyreplacingoccurrencesofstring:@"@" withstring:@"-"]; str = [str stringbyreplacingoccurrencesofstring:@"." withstring:@"-"]; pfinstallation *currentinstallation = [pfinstallation currentinstallation]; [currentinstallation adduniqueobject:str forkey:@"channels"]; currentinstallation[@"user"] = [pfuser currentuser]; //app crashes here [currentinstallation saveinbackground]; i haven't changed anything. checked earlier versions of code , crashing @ same point. issue unable figure out. your code seems fine , acco

ios - Setting supported interface orientation as 'All' only MPMoviePlayerController is active in swift -

i trying set interface orientation mpmovieplayercontroller active. meanwhile, movie started play. in target of project, have checked portrait , landscape left , landscape right . also, in appdelegate file, have implemented supportedinterfaceorientationsforwindow method , tried check presentedviewcontroller mpmovieplayercontroller . however, not implement correctly. how can solve problem correct way ? best solution changing supported interface orientation when mpmovieplayercontroller active ? thank answers king regards you need uiinterfaceorientationmaskall only mpmovieplayercontroller so, while creating controller use bool variable identify interface needed or not . mpmovieplayerviewcontroller *playercontroller = [[mpmovieplayerviewcontroller alloc] initwithcontenturl:[nsurl fileurlwithpath:moviepath]]; override initwithcontenturl method , set appdelegate bool variable yes and @ viewwilldisappear set bool no . in appdelegate.m #pragma mark --- orie

pandas - Python: Automatically choose parameters for ARMA model -

i trying fit arma model time series data. haven't find functions can automatically choose parameter. below code wrote beginner python hence believe code can optimised. can give me ideas on how to: do vectorization on double loop quicker way parameter choosing much appreciate. parameter_bound = 3 # creating 2-d array, storing residuals of 2 different parameters of arma model residuals = [[0 x in range(parameter_bound)] x in range(parameter_bound)] model = [[0 x in range(parameter_bound)] x in range(parameter_bound)] # calculate residuals each parameter combinations in range(parameter_bound): j in range(parameter_bound): model[i][j] = sm.tsa.arma(input_data, (i,j)).fit() residuals[i][j] = sum(abs(model[i][j].resid)) # find parameters lowest residuals parameters = np.argmin(residuals) parameter1 = parameters/parameter_bound parameter2 = parameters - parameters/parameter_bound*parameter_boun

how can we merge two java objects in one xml file? -

this program. correct way merge 2 objects? public class objecttoxml { public static void main(string[] args) throws exception{ jaxbcontext contextobj = jaxbcontext.newinstance(employee.class); marshaller marshallerobj = contextobj.createmarshaller(); marshallerobj.setproperty(marshaller.jaxb_formatted_output, true); try{ employee employees = new employee(); employees.setemployee(new arraylist<employee>()); employee emp1=new employee(1,"vimal jaiswal",50000); employee emp2=new employee(2,"kamal",40000); employees.getemployee().add(emp1); employees.getemployee().add(emp2); marshallerobj.marshal(employees, new fileoutputstream("e:\\employee.xml")); } catch(jaxbexception e){ system.out.println(e); }}} its giving output doulbe times: 1,"vimal jaiswal",50000 2,"kamal",40000 1,"vimal jaiswal",50000 2,"kamal",40000 please find below code solve problem,

php - Somehow a row is inserted twice even only one flush() exists; -

i made simple search form search query log. in indexaction public function indexaction(){ $searchlog = new searchlog; $form = $this->createformbuilder($searchlog) ->add('query','text') ->add('save', 'submit', array('label' => 'search')) ->setaction($this->generateurl('acme_top_searchresult')) ->getform(); 'acme_top_searchresult' invokes searchresultaction(); receive query in searchresultaction public function searchresultaction(request $request){ //var_dump($request); $searchlog = new searchlog; $form = $this->createformbuilder($searchlog) ->add('query') ->getform(); $form->handlerequest($request); $querydata = $form->getdata(); $this->em->persist($searchlog); $this->em->flush(); $sq = $querydata->getquery(); // use $sq searching however inserted 2 rows in database. why happens??

Create Bootstrap Popover content based on a javascript value -

i'm using justgage , bootstrap , want display variable content in popover based on value in javascript justgage. for example, if value in gauge between 0 - 50, "try harder", if it's between 50 - 200, "well done", surfaced in popover content. - (you can see clicking on gauge 1). $(window).load(function() { var gagevalue1 = getrandomint(0, 200) var gagevalue2 = getrandomint(0, 200) var gagevalue3 = getrandomint(0, 200) var colorgradientryg = ["#991d1d", "#9d1f1f", "#a22222", "#a62424", "#ab2727", "#b02929", "#b42c2c", "#b92e2e", "#be3131", "#c23333", "#c73636", "#cc3939", "#ce4236", "#d14b33", "#d35530", "#d65e2d", "#d8672a", "#db7127", "#dd7a24", "#e08321", "#e28d1e", "#e5961b", "#e8a019"