Posts

Showing posts from September, 2014

recursion - Combinatorics in Scala: How to iterate/enumerate all possibilities to merge multiple sequences/lists (riffle shuffle permutations) -

recursion - Combinatorics in Scala: How to iterate/enumerate all possibilities to merge multiple sequences/lists (riffle shuffle permutations) - updated question: in original question did not know how refer next problem. clarify question, added following illustration wikipedia: it turns out problem named after analogy: riffle shuffle permutations. based on terminology question becomes: how can iterate/enumerate riffle shuffle permutations in general case of multiple decks? original question: let's assume given multiple sequences , want merge these sequences 1 single sequence. resulting sequence should preserve order of original sequences. think of merging multiple stacks of cards (say seq[seq[t]] ) 1 single stack ( seq[t] ) randomly drawing card (random) stack. input stacks should merged resulting stack. how can iterate or enumerate possible compositions of such resulting sequence? to clarify: if have 3 stacks a, b, c (of 5 elements each) not want 6 possible arrange

r - Reshape three column data frame to matrix -

r - Reshape three column data frame to matrix - i have data.frame looks this. x 1 x b 2 x c 3 y 3 y b 3 y c 2 i want in matrix form can feed heatmap create plot. result should like: b c x 1 2 3 y 3 3 2 i have tried cast reshape bundle , have tried writing manual function not seem able right. there many ways this. reply starts favorite ways, collects various ways answers similar questions scattered around site. tmp <- data.frame(x=gl(2,3, labels=letters[24:25]), y=gl(3,1,6, labels=letters[1:3]), z=c(1,2,3,3,3,2)) using reshape2: library(reshape2) acast(tmp, x~y, value.var="z") using matrix indexing: with(tmp, { out <- matrix(nrow=nlevels(x), ncol=nlevels(y), dimnames=list(levels(x), levels(y))) out[cbind(x, y)] <- z out }) using xtabs : xtabs(z~x+y, data=tmp) you can utilize reshape , suggested here: convert table matrix co

Is there a way to pull a list of all user that have ever authenticated to a Twitter Application? -

Is there a way to pull a list of all user that have ever authenticated to a Twitter Application? - i unable find in documentation know facebook has similar where, app can pull list of users have authenticated ( or granted permissions ) said app. the twitter rest api not expose methods allow developers see has authorized application. twitter

c# - Strangely slow: what happened when TakeWhile met AsParallel? -

c# - Strangely slow: what happened when TakeWhile met AsParallel? - i know wrong usage of linq may cause lower performance time it's strange. when phone call "asparallel.takewhile.asparallel.forall", it's much slower "asparallel.takewhile.forall". can explain why? using system; using system.diagnostics; using system.linq; namespace consoleapplication1 { class programme { static void main(string[] args) { action<int> donothing = => { }; var stopwatch = stopwatch.startnew(); enumerable.range(1, 100).asparallel().takewhile(m => m < 10) .forall(donothing); var ticks1 = stopwatch.elapsedticks; stopwatch.restart(); enumerable.range(1, 100).asparallel().takewhile(m => m < 10) .asparallel() // spend much more time asparallel .forall(donothing); var ticks2 = stopwatch.elapsedti

azureservicebus - Azure notification hubs shared access key expiry -

azureservicebus - Azure notification hubs shared access key expiry - from azure portal, on configure tab notification hub able generate primary key , secondary key. understand these required gain programmatic access azure api - allowing client app create registrations , send messages. could please explain: why there 2 keys (primary , secondary)? keys generated ui expire , if how long live before expiry? they don't expire. reason there 2 because it's recommended regenerate keys periodically security reasons. example, suppose application using primary key today. if regenerated primary key, application broken until update , resulting in downtime. instead, can alter application utilize secondary key little or no downtime. then, after application has been updated, can regenerate primary key. next month (or whatever schedule like), can repeat process, switching primary key , regenerating secondary key. this not unique notification hubs. see primary , seco

asp.net - What is the typical method for securely exposing some data on a public website that is taken from internal databases? -

asp.net - What is the typical method for securely exposing some data on a public website that is taken from internal databases? - i have few internal databases , intranet site on server that's totally inaccessible outside world. , have external website on off-network server. there handful of info on internal databases want available on public website, internal databases contain sensitive info want away public site. how typically handled? not exclusively sure search for. right now, manually dump needed info xml file used website, sense there improve way go this. you have few options can think of, , more i'm list... not much of network guy. set firewall rule allows port requests external server's ip address internal database server. set external facing service exposes info wish share. can have authentication/authorization set on service allow users wish access info have access. additionally, set service allow calls external web site'

Unix Socket C: Connecting from another network -

Unix Socket C: Connecting from another network - i'm starting larn how configure unix server/client basilar application in c tcp socket, thing is, connect client server using port i've take in server, , (local?) address 192.168.1.x. don't know it, presume 192 local interface address , connection can achieved in same network, i've tried 2 pcs still in same network. connection network? it's complicated thing? suppose passing network's provider ip client won't job usually in such case open router configuration web page in browser , in section "port forwarding/triggering" come in entry redirecting connections outside lan port on given machine on lan, e.g: # service name start port end port server ip address 1 myserveronport9875 9875 9875 192.168.1.7 given external ip 89.75.140.30 can connect anywhere telnet 89.75.140.30 9875 to reach port 9875 on local machine 192.168.1.7 assuming server

c++ - Assign a string from an iterator -

c++ - Assign a string from an iterator - here problem have , have vector of filenames , want check if end .jpg or .png made code iterators , stl, creating std::map names keys , value texture, here code, segmentation fault error @ line 11: #include "texturemanager.h" std::map<std::string,sf::texture> createtexturearray(){ std::map<std::string,sf::texture> texturearray; std::vector<std::string>::iterator strit; std::string fname; for(strit = texturefilelist().begin(); strit != texturefilelist().end(); strit++){ sf::texture texture; fname = *strit; if(fname[fname.size()] == 'g' && fname[fname.size()-1] == 'p' && fname[fname.size()-2] == 'j' && fname[fname.size()-3] == '.'){ texture.loadfromfile(fname); texturearray[fname] = texture; } else if(fname[fname.size()] == 'g' && fname[fname.size()-1] == 'n' && fname[fname.size()-2] ==

jquery - Two datepickers are not displaying in a single htmlpage -

jquery - Two datepickers are not displaying in a single htmlpage - i want maintain 2 datepickers in single html page while running displaying 1 date pickers . the coding have done is </head> <body> issue date(dd-mm-yyyy)<span class="star" style="color:red;">*</span> <!-- <input type="text" id="datepicker" />--> <script type="text/javascript"src="http://www.snaphost.com/jquery/calendar.aspx"></script> &nbsp;&nbsp;&nbsp;&nbsp; expiry date(dd-mm-yyyy)<span class="star" style="color:red;">*</span> <script type="text/javascript"src="http://www.snaphost.com/jquery/calendar.aspx"></script> </body> </html> i have checked http://jqueryui.com/datepicker/ can give suggestion how

php - shifting arrays to 1st element -

php - shifting arrays to 1st element - $important_dates = array( array('start_date' => '2013-01-01', 'end_date' => '2013-12-01' ), array( 'start_date' => '2014-01-01', 'end_date' => '2014-05-03' ) ); i want output: $important_dates = array( array( 'start_date' => '2014-01-01', 'end_date' => '2014-05-03' ) ); i tried: $important_dates = array_shift($important_dates); failed. possible show me code? help lot. thanks try instead: array_shift($important_dates); var_dump($important_dates); array_shift removes first element of array , returns element - not array. php arrays multidimensional-array

selenium webdriver - Check whether SelectBox has items, Robot-Framework, Selenium2Library -

selenium webdriver - Check whether SelectBox has items, Robot-Framework, Selenium2Library - how can check whether <select> box has more 1 <option> ? the <option> s loaded using ajax , placed 2 <optgroup> s. <option value="">default</option> <optgroup ...> <option value=..>... <option ..>... ... </optgroup> <optgroup ...> <option ..>... <option ..>... ... you can utilize get list items homecoming list of items , utilize get length number of elements in list: select options test open browser your_url chrome @{items} list items id=select_list_id ${list_length} length ${items} should true ${list_length} > 1 selenium-webdriver robotframework

php - Joomla! K2 - How to fetch Author Item Count for user page? -

php - Joomla! K2 - How to fetch Author Item Count for user page? - i have several authors on website , each of them has page of own image, description , list of items. add together "item counter" pages, page this: author name, number of posts -> author description -> author items. the thing miss here number of posts author. thank much answers! you need modify k2 view (we did 1 of our clients). need create query resembles next in view: select count(*) #__k2_items authorid='id'; now should pass result of query template (using assignref function on $this object. that's it! note: not sure field name authorid, i'm sure it's else can't remember on top of head. php joomla joomla-k2

angularjs - Make a directive with minimal length "required" -

angularjs - Make a directive with minimal length "required" - i have directive adds % every input. want able create "required". if % exists invalid. additional requirement, input field can enabled/ disabled user (with ngdisabled). when disabled don't need create "required". i have tried set ngminlength=1, doesnt show % want, when input empty, because invalid. how can it? http://jsfiddle.net/jivangilad/uzvn3/ <input valid-num type="text" ng-model="deal.cupon"> var portaldirectives = angular.module("portaldirectives", []); portaldirectives.directive("validnum", function($filter) { homecoming { restrict: 'a', require: '?ngmodel', priority: 1, link: function(scope, element, attr, ngmodelctrl) { ngmodelctrl.$parsers.unshift(function(val) { if (val === undefined) val = "";

c++ - argument of type 'void* (...)(void*)' does not match 'void* (*)(void*) -

c++ - argument of type 'void* (...)(void*)' does not match 'void* (*)(void*) - i'm developing bloc on gnu radio , want utilize thread. thread there acquired info udp socket can utilize in gnu radio bloc. "general work" function 1 signal , info processing. the master source file organized : namespace gr { namespace adsb { out::sptr out::make() { homecoming gnuradio::get_initial_sptr (new out_impl()); } /* * udp thread */ void *task_udprx (void *arg) { while(true) { printf("task udprx\n\r"); usleep(500*1000); } pthread_exit(null); } /* * private constructor */ out_impl::out_impl() : gr::block("out", gr::io_signature::make(1, 1, sizeof(int)), gr::io_signature::make(1, 1, sizeof(char))) { pthread_t thread_udprx; //thread init

jquery - Owl Carousel YouTube Video Not Playing on iOS (iPad and iPhone) -

jquery - Owl Carousel YouTube Video Not Playing on iOS (iPad and iPhone) - i'm using owl carousel , love it, works great can't seem embedded youtube videos play when tap on reddish play button. vimeo videos work fine. example url: http://dx1showroom.azurewebsites.net/details-images-v2.html html: <div class="thumbnail-frame"> <div id="sliderstatus" class="image-count"> <span class="glyphicon icon-camera"></span> <span class="currentitem"><span class="result"></span></span>/<span class="owlitems"><span class="result"></span></span> </div> <div id="slideshow-main" class="owl-carousel main-frame col-sm-8 col-md-8 col-lg-9"> <div class="item"><a><img src="http://placehold.it/750x422&amp;text=foobar4" alt="&q

sql - Extracting data from sub table -

sql - Extracting data from sub table - i have 2 tables choice(column: id, choice) , choices(column: choice_id, question_id + more). i need content of selection column plus rest of columns in selection table. tried , several other strings. got nil bot errors. doing wrong? select * selection id=(select selection choices question=" & request.form("id") & ") order rand() i can't tell language you're writing in tags specify sql. it doesn't you're providing entire snippet i'm looking @ have unclosed quotation marks... or something. additionally, why not bring together on 2 tables rather putting subquery in clause? from strictly sql perspective, if i'm understanding schema correctly, do: declare @id int set @id = 42 select c.* selection c inner bring together choices cs on c.id = cs.choice_id cs.question_id = @id sql

facebook - How can I add custom dimensions to a custom report in google analytics -

facebook - How can I add custom dimensions to a custom report in google analytics - i set custom dimensions in google analytics e.g. 1 dimension facebook login status twitter , on. want create custom study social login status of visitors. my tracking works. checked google analytics debugger. how can add together custom dimensions custom reports in google analytics? just select custom dimension you'd see list of dimensions. facebook google-analytics universal-analytics

c# - How to update Cached Page from an Asyn Task After Navigating to another Page? -

c# - How to update Cached Page from an Asyn Task After Navigating to another Page? - i navigating page page when background downloading work going on. in page 1, i'm updating progress bar based on progress received. i've cached page1 before navigating page 2. but when navigate page1, view not updated if have updated model , notified using mvvm method. w've verified progress completed , file downloaded. we using below code cache page. this.navigationcachemode = navigationcachemode.enabled; i wondering why view not updated, if have tried update it. if not navigating page, progress updated. sure work on normal case except on caching. please help on situation. clearing cache should help you override next in caller page protected override void onnavigatingfrom(navigatingcanceleventargs e) { if (e.uri.tostring().contains("/target")) { frame parentframe = (frame) parent; var cachesize = parentframe.cachesize;

javascript - Codeigniter: How to pass array from controller to view without refresh -

javascript - Codeigniter: How to pass array from controller to view without refresh - basically have form in view 1 input enabled, , multiple inputs disabled (only show info derivated unique input). now, need send input controller create query, , send view array fields info without refresh site (because cant loose progress have in page). maybe solution utilize javascript send controller input field, , in function homecoming array of values refresh form, how? edit: sorry bad english. var input = $('#input').val(); $.ajax({ type:"post", url: <?php echo base_url().'controllername/action'?> data: {input : input}, success: function(data){ // info should contain arra $('#where_to_insert_array').html(); } }); in controller action , in action function action() { $data = $this->input->post('input'); get info database on $data make array , echo it

payment gateway - how to use gocardless.com with django -

payment gateway - how to use gocardless.com with django - i have utilize gocardless payment gateway django, how can utilize project. are there django packages ,which back upwards latest gocardless payments, you can utilize python gocardless bundle in django installation: pip install gocardless implementation: import gocardless gocardless.set_details(app_id="dummy_app", app_secret="insert_app_secret_here", access_token="insert_merchant_access_token", merchant_id="insert_merchant_id") reference link here https://developer.gocardless.com/python/#initialization django payment-gateway gocardless

Cannot access Canvas Element inside Polymer custom-element with Javascript -

Cannot access Canvas Element inside Polymer custom-element with Javascript - i playing around polymer-project web-components library google. want build custom-tag canvas element included , access within custom-element via javascript. cant access document.queryselector or document.getelementbyid - hint or experience similar problem appreciated. here's source: <polymer-element name="sprite-canvas"> <template> <style> .leinwand { width:200px; height:200px; background-color: lightblue; } </style> <canvas class="leinwand" width="200" height="200"></canvas> </template> <script> polymer('sprite-canvas', { leinwand : null, ready: function() { console.log(document.getelementsbytagname('canvas')); console.log(document.queryselector('.leinwand')); }, domready: function() { console.log(document.getelementsbytagname('canvas')); console.log(document.querysele

java - log4j - no appenders could be found, custom config file -

java - log4j - no appenders could be found, custom config file - i'm using log4j in project first time, , i'm trying utilize custom configuration log output. want logger configuration in custom file, not log4j.xml or log4j.properties. have right now: constructor: public manager(int managerid, string loggerconfigfile) { this.manager_id = managerid; logger = logger.getlogger("testlogger" + manager_id); propertyconfigurator.configure(loggerconfigfile); } method calls logger first time: public void getpacketsfromstream(inputstream inputstream) { logger.info("manager " + manager_id + " started."); (there's more later, that's not important) contents of test1.config (that's value of loggerconfigfile in constructor) testlogger1=debug,a1 log4j.appender.a1=org.apache.log4j.consoleappender log4j.appender.a1.layout=org.apache.log4j.patternlayout log4j.appender.a1.layout.conversionpattern=%-4r %-5p [%t] %37c

debugging - Komodo php debugger stop at the beginning of script -

debugging - Komodo php debugger stop at the beginning of script - i'm using komodo ide debug php. stop @ origin of script although there no breakpoint. there anyway disable it? thanks. go menu edit/preferences/debugger/, alter 'initial break behaviour' 'run first breakpoint' php debugging komodo

java ee - map resource reference to resources in WAS6 -

java ee - map resource reference to resources in WAS6 - in ear containing web module , ejb module trying map ejb resources in was6 using ibm-ejb-jar-bnd.xmi. while installing ear inquire datasource mapping in map resource reference resources. question while installing ear if give different jndi name alter contents of ibm-ejb-jar-bnd.xmi ? while installing ear if settings or configuration changes can see them i.e path {was_install_root}/config or ? in advance. yes, seems bnd files changed when alter resource reference mappings. you can test exporting application console , opening zip tool. when install application: the original ear file deployment options located in: was_profile_home/config/cells/cellname/applications/appname after installation finished application archives (the ear & wars) extracted in next place , used server there: was_profile_home/installedapps/appname java-ee jndi ibm-was websphere-6

javascript - How to pass the img src into the Bootstrap modal? -

javascript - How to pass the img src into the Bootstrap modal? - now i'm getting src of images in loop. problem can't pass through modal show right image. matter of fact, can't show image. here's code. <script src="js/jquery-2.0.3.min.js" type="text/javascript"></script> <?php $sql = "select * portfolio"; $query = mysqli_query ($conn, $sql); ?> <div class="col-md-12"> <h1>portfolio</h1> <table class="table"> <?php while ($row = mysqli_fetch_assoc($query)) { ?> <tr> <td> <br> <a data-toggle="modal" data-target="#mymodal1"> <img src="<?php echo $row ['pic']; ?>" width="200" height="150" class="getsrc"> </a>

java - Why doesn't paintComponent(Graphics g) of JPanel run? -

java - Why doesn't paintComponent(Graphics g) of JPanel run? - during experience before, paintcomponent(graphics g) of panel run when initial , can create repaint calling repaint() method. demo below doesn't work experience. what's wrong it? import java.awt.borderlayout; import java.awt.dimension; import java.awt.graphics; import java.awt.image.bufferedimage; import java.io.file; import java.io.ioexception; import javax.imageio.imageio; import javax.swing.borderfactory; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.jscrollpane; public class backgroundtest { public static void main(string[] args) { backgroundtest backgroundtest = new backgroundtest(); seek { backgroundtest.createui(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } } public void createui() throws

javascript - NodeJs, pattern for sync developement -

javascript - NodeJs, pattern for sync developement - i new nodejs , express frameworks. have understood node works 1 thread on server side. so, have noticed causes me problems in order develop correctly application. in routes folder, have file index.js. file manage navigation asked user app.js. so decided create route function "test". in function, had code exports.test = function(req, res){ res.render('test', {}); }; so simple, easy. that's rend template test.jade in views folder. greats ! wanna complexify process. in test route function, want load content mysql database. for that, have created folder models in folders node_modules inside, have 2 file, first mysqlconnection.js exports variable db in order create queries. var mysql = require('mysql'); var db = mysql.createconnection( { host : 'localhost', user : 'root', password : '', database : 'test', } );

facebook - Handling a Share Button Click on Android Game -

facebook - Handling a Share Button Click on Android Game - hi want handle click on screen. class not extends activity class cannot utilize trivial method handle click. know how handle click on android app new game development have limited knowledge game. requirement : there share icon on game on screen. want handle icon click when user presses on icon shown bunch of sharing alternative facebook,twitter, skype , many more using createchooser. dont know how that. gameoverscreen code. public class gameoverscene extends cclayer { //fields private soundmanager _soundmananger; private ccsprite _background; private ccmenu _menu; private ccmenu _restart; private cclabel _yourscore; private cclabel _bestscore; //methods public static ccscene scene() { ccscene scene = ccscene.node(); gameoverscene layer = new gameoverscene(); scene.addchild(layer); homec

PHP Rest API Call with Authorization -

PHP Rest API Call with Authorization - simple question where set "authorization: bearer cajwune0fnr78ynj2kz6p8bad" $service_url = 'https://example.com/something/something.json'; $curl = curl_init($service_url); curl_setopt($curl, curlopt_httpauth, curlauth_basic); curl_setopt($curl, curlopt_userpwd, "username:password"); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_post, true); curl_setopt($curl, curlopt_postfields, $curl_post_data); curl_setopt($curl, curlopt_ssl_verifypeer, false); $curl_response = curl_exec($curl); $response = json_decode($curl_response); curl_close($curl); var_dump($response); thanks! you'd set into: ***old curl_setopt($curl, curlopt_httpheader, 'authorization: bearer cajwune0fnr78ynj2kz6p8bad'); ***new curl_setopt($curl, curlopt_httpheader, array('authorization: bearer cajwune0fnr78ynj2kz6p8bad')); php api rest authorization

javascript - AngularJS call method inside $routeProvider -

javascript - AngularJS call method inside $routeProvider - i'm newer in angularjs. have simple question, can't find answer. have code: angular.module('app', ['app.controllers', 'ngroute']). config(['$routeprovider', function ($routeprovider) { $routeprovider.when('/users', {templateurl: '../pages/list.html', controller: 'userlistctrl'}). when('/user-details/:login', {templateurl: '../pages/form.html', controller: 'userctrl' /* , here need phone call userdetails(login) userctrl */}). otherwise({redirectto: '/users'});; } ]); app.controller('userctrl', function ($scope, $http, $location) { $scope.userdetails = function (login) { $http.get(url + login).success(function (data) { $scope.user = data[0]; console.log('tst'); }).error(errorcallback); }; $scope.createuser = function (user) { $http.post(url, user).success(funct

Titanium studio disable enter key in android keybord -

Titanium studio disable enter key in android keybord - i seem stuck on problem can't seem find reply for. have textarea in titanium studio can come in name , if click button safes database want disable come in key in android keyboard or alter action similar space button wont mess when inserting database. does know way prepare this? below code : var textarea = ti.ui.createtextarea({ hinttext: 'enter name', left:10, width:200, height:40, borderstyle:titanium.ui.input_borderstyle_rounded, }); you need add keyboard properties textarea. var textarea = ti.ui.createtextarea({ hinttext: 'enter name', left:10, width:200, height:40, borderstyle:titanium.ui.input_borderstyle_rounded, keyboardtype: titanium.ui.keyboard_default, returnkeytype: ti.ui.returnkey_go }); you can set keyboardtype , returnkeytype values per needs. check these 2 properties : keyboardtype : keyboard type display when

c# - IsolatedStorageFile.DeleteFile doesn't work -

c# - IsolatedStorageFile.DeleteFile doesn't work - i seek that: using (isolatedstoragefile store = isolatedstoragefile.getuserstoreforapplication()) { if (store.fileexists(filename)) { store.deletefile(filename); } } but have system.io.isolatedstorage.isolatedstorageexception: unable delete file. what wrong? so resolve problem using filemode.truncate on opening file. using (isolatedstoragefile store = isolatedstoragefile.getuserstoreforapplication()) { using (var filestream = store.openfile(filename, filemode.truncate, fileaccess.readwrite, fileshare.readwrite)) { //do stuff } } c# windows-phone-8 windows-phone

ios - Fade in and out between images in NSmutableArrray -

ios - Fade in and out between images in NSmutableArrray - i know based on code, how can add together fade in fade out effect between each images in nsarray. using these images background. changing background without fade in , out looks horrible. here code. - (void)viewdidload { [super viewdidload]; nsarray *imagenames = @[@"1.jpg", @"2.png", @"3.png", @"4.png", @"5.png"]; nsmutablearray *images = [[nsmutablearray alloc] init]; (int = 0; < imagenames.count; i++) { [images addobject:[uiimage imagenamed:[imagenames objectatindex:i]]]; } // normal animation uiimageview *animationimageview = [[uiimageview alloc] initwithframe:self.view.bounds]; animationimageview.animationimages = images; animationimageview.animationduration = 9; [self.background addsubview:animationimageview]; [animationimageview startanimating];} ios iphone xcode animati

polling a file directory every tuesday moning at 8:00 using apache camel -

polling a file directory every tuesday moning at 8:00 using apache camel - i busy apache camel project automates process of uploading file sftp server every tuesday @ 8:00. i want set delay of apache camel route to: every tuesday @ 8:00. how go doing that? let's 'a' pickup location , 'b' destination location. use quartz component scheduler, pollenrich reading file, , ftp component sending content: from("quartz://myscheduler?cron=0+0+8+?+*+thu") .pollenrich("file:inbox?filename=data.txt") .to("ftp://foo@127.0.0.1:21/?password=pwd") more info cron look can found here. apache-camel

Unit testing C#/.NET classes which make use of static variables (unit test process segregation) -

Unit testing C#/.NET classes which make use of static variables (unit test process segregation) - i've got codebase makes utilize of static variables in number of cases makes sense, illustration flagging something's run 1 time since launch, etc etc. of course, can lead issues unit testing whereupon order matters , outcome of test on method of such class may depend on whether other code has been nail before, etc. understand of testtools.unittesting whenever run set of unit tests, within same project run within same process, static state maintained test test, whereas unit test project boundary implies process boundary , thus, if run 3 tests project 4th project b, state maintained 1>2>3 (in whatever order run) 4 virgin , static state default. so questions two: 1) assessment right unit test projects have 1:1 relationship processes when tests run in grouping (run or run selected), or there more nuance there i'm missing? 2) regardless, if have test needs fr

django - Accessing foreign keys -

django - Accessing foreign keys - i have next models: class article(models.model): title = models.charfield(max_length=200, unique=false, null=false) rating = models.integerfield(default=0, null=false, unique=false) class shared(models.model): sender = models.foreignkey(user) article = models.foreignkey(article) class sharedmap(models.model): item = models.foreignkey(shared) receiver = models.foreignkey(user) now execute next query: def get_shared_feed(self): homecoming article.objects.filter(shared__sharedmap__receiver=self) and list of articles expected. however: {{ article.shared_set.count }} gives me more 1 if articles shared before. want list of articles single sender(e.g. friend) each. instead, receive list of articles set of every user shared article. the solution easy. had specify fields want homecoming using values: blog_feed = article.objects.filter(shared__sharedmap__receiver=self).values('title', 

php - simplexml_load_string() just storing string of xml issue -

php - simplexml_load_string() just storing string of xml issue - i've been frustrated day issue, have say. website i'm working on utilises rest based api receive company data. using curl, have xml request , response coming me okay. however, 1 time seek utilize simplexml_load_string() alter xml array, stores xml string within 1 index of array. below, can see code along print screen of how array looks in google chrome's developer tools. code: $ch = curl_init($url); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, "requestxmlstr={$xml_data}"); curl_setopt($ch, curlopt_returntransfer, 1); $output = curl_exec($ch); curl_close($ch); $searchresults = simplexml_load_string($output); exit(print_r($searchresults)); the exit(print_r($searchresults)) displays next on page: simplexmlelement object ( [

Perl $1 giving uninitialized value error -

Perl $1 giving uninitialized value error - i trying extract part of string , set new variable. string looking @ is: maker-scaffold_26653|ref0016423-snap-gene-0.1 (inside $gene_name variable) and thing want match is: scaffold_26653|ref0016423 i'm using next piece of code: my $gene_name; $scaffold_name; if ($gene_name =~ m/scaffold_[0-9]+\|ref[0-9]+/) { $scaffold_name = $1; print "$scaffold_name\n"; } i'm getting next error when trying execute: use of uninitialized value $scaffold_name in concatenation (.) or string i know pattern right, because if utilize $' instead of $1 -snap-gene-0.1 i'm @ bit of loss: why $1 not work here? if want utilize value matching have create () arround character in regex perl

node.js - Is it possible to pipe to console.log? -

node.js - Is it possible to pipe to console.log? - i trying larn node.js. i trying understand streams , piping. is possible pipe response of http request console.log? i know how binding handler info event more interested in streaming console. http.get(url, function(response) { response.pipe(console.log); response.on('end', function() { console.log('finished'); }); }); thanks console.log function pipes process stream output. note next illustration code console.log = function(d) { process.stdout.write(d + '\n'); }; piping process.stdout same thing. http.get(url, function(response) { response.pipe(process.stdout); response.on('end', function() { console.log('finished'); }); }); note can do process.stdout.write(response); node.js stream

android - AlarmManager fires twice -

android - AlarmManager fires twice - i trying utilize androids alarmmanager. problem is, fires twice right after 1 another. public class schedulesomething { public static void schedule(pojo pojo) throws jsonprocessingexception { final objectmapper mapper = new objectmapper(); final string pojoasjson = mapper.writevalueasstring(pojo); final intent alarmintent = new intent(myapplication.getappcontext(), pojoalarmreceiver.class); alarmintent.putextra(pojo_as_json, pojoasjson); final pendingintent pi = pendingintent.getbroadcast(myapplication.getappcontext(), 0, alarmintent, pendingintent.flag_one_shot); am.set(alarmmanager.rtc_wakeup, system.currenttimemillis() + pojo.getscheduledtime() + 10l, pi); } } public class alarmreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { // stuff. onreceive() beingness called twice, ev

email - how can i tracking click in custom html template mailchimp? -

email - how can i tracking click in custom html template mailchimp? - i create html email template mailchimp. when want see click track in report, see: "sorry, couldn't stats looking for." i think when utilize custom html template, must utilize mailchimp tag sum data: |unsub| |forward| |archive| |update_profile| |email| |list:address| |list:company| |current_year| |date| but dont know how can utilize |url:your_merge| ? i found ! dont need add together tag ! type total address in template: <a href="http://yourlink.com" target="_blank"> yourlink! </a> your link must start "http://", mailchimp alter link html email templates mailchimp

How do I use Python Mox to check if a method is called with the equivalent of a string? -

How do I use Python Mox to check if a method is called with the equivalent of a string? - i want check if function beingness called string - seems makes difference if string created using '%s' insert substring. test failing error: unexpectedmethodcallerror: unexpected method call. unexpected:- expected:+ - foo('hello %s', 'world') -> none ? ------ + foo('hello world') -> none how check if method beingness called on 'hello world', regardless of how string created? there no type or class "formatted string" in python. string. think have error in code. mean, fault. bet trying phone call this: foo('hello %s', 'world') but should, instead, do foo('hello %s' % 'world') which give expected result. python mox

objective c - Revolve a SCNode object in the 3D Space using SceneKit -

objective c - Revolve a SCNode object in the 3D Space using SceneKit - i trying larn way around scenekit , example, thought i'd seek build solar scheme using sdk. able add together scnode objects , configure material properties pattern , lighting. also, able rotate planets, can't seem understand how "revolve" them along particular path. my code far looks like: // create new scene scnscene *scene = [scnscene scene]; // create , add together photographic camera scene scnnode *cameranode = [scnnode node]; cameranode.camera = [scncamera camera]; [scene.rootnode addchildnode:cameranode]; // place photographic camera cameranode.position = scnvector3make(0, 0, 2); // create , add together 3d sphere - sun scene scnnode *spherenode = [scnnode node]; spherenode.geometry = [scnsphere spherewithradius:0.3]; [scene.rootnode addchildnode:spherenode]; // create , configure material scnmaterial *material = [scnmaterial material]; material.diffuse.contents = [ns