Posts

Showing posts from June, 2011

oop - Models getting out of hand -

we use laravel in our company , follow 2 simple conventions: controllers should thin. models represents database entities (user, roles, cars) now we're facing dilemma: have screen complicated data graphs represented require long , heavy logic produce. should put of logic? controllers should thin - not in controllers. models represent data entities, can't model since screen displays data of other models don't have actual table/database entity. services doesn't sound normal place. i wondering how did approach similar situations i put logic service. in service can run other services (in case logic in other service or if service complicated) , use repositories (or models in case don't use repositories). of course there no point put big code or logic controllers because run services return desired output.

c# - if statement whit DataBinder.Eval -

the code : <asp:repeater id="repeater2" runat="server"> <headertemplate> <table cellspacing="0" cellpadding="0" border="0" width="100%"> </headertemplate> <itemtemplate> <tr> <td colspan="3" style="height: 1px; width: 100%; " align="center"> <div style="height: 1px; width: 90%; background-color: #cccccc;"></div> </td> </tr> <% if (databinder.eval(container.dataitem, "productid").tostring() == "32668" || databinder.eval(container.dataitem, "productid").tostring() == "33829" || databinder.eval(container.dataitem, "productid").tostring() == "33831") { %> <tr> <td style="height: 132px; width: 25%; padding-left:20px;"><a href='product_detail_<%# databinder.eval(contain

c++11 - Convert chrono duration to time_point -

how can convert chrono duration time_point, later clock's epoch given duration? tried find epoch time in chrono clock without success. from synopsis in 20.12.6 [time.point]: template <class clock, class duration = typename clock::duration> class time_point { public: constexpr explicit time_point(const duration& d); // same time_point() + d this can used (for example) like: using namespace std::chrono; system_clock::time_point tp{30min}; // needs c++14 literal though system_clock::time_point not specified in standard, in practice creates time_point referring 1970-01-01 00:30:00 utc.

c++ - Qt QAudioInput how to send a fixed number of samples -

i'm tryng send audio stream qt application other device udp protocol. problem target device wants fixed number of samples(in case 320) every packet receives. think must use setbuffersize function of qaudioinput object use catch sound, documentation odd , poor whole qaudioinput object. how can control number of samples send? thank you. this how send stream: qaudioformat format; format.setsamplerate(48000); format.setchannelcount(1); format.setsamplesize(16); format.setcodec("audio/pcm"); format.setbyteorder(qaudioformat::littleendian); format.setsampletype(qaudioformat::unsignedint); //if format isn't supported find nearest supported qaudiodeviceinfo info(qaudiodeviceinfo::defaultinputdevice()); if (!info.isformatsupported(format)) format = info.nearestformat(format); input = new qaudioinput(format); socket = new qudpsocket(); socket->connecttohost(ip, port); input->start(socket); this way qbytearray: qaudioformat format; format.setsamplerate(

python - Pivot each group in Pandas -

using pandas i've invoked groupby on dataframe , obtained following: >>>grouped = df.groupby(['cid']) key, gr in grouped: print(key) print(gr) out: cid price 121 12 121 10 121 9 i want have each group pivoted like: cid price1 price2 price3 121 12 10 9 what correct way pandas? assuming have frame looking like >>> df = pd.dataframe({"cid": np.arange(64)//8, "price": np.arange(64)}) >>> df.head() cid price 0 0 0 1 0 1 2 0 2 3 0 3 4 0 4 then think can want combining groupby , pivot : df = pd.dataframe({"cid": np.arange(64)//8, "price": np.arange(64)}) df["num"] = df.groupby("cid")["price"].cumcount() + 1 pivoted = df.pivot(index="cid", columns="num", values="price") pivoted.columns = "price" + pivoted.columns.astype(str) piv

python - Reset Tkinter Widget to its default value -

in need make generic function on event return focused-out widget default value. there way accomplish this? example: entry1 = tkinter.entry() entry1.grid(..) entry1.insert(0,"hello") entry1.bind("<focusin>", entryfocusedin) entry1.bind("<focusout>", entryfocusedout) entry2 = tkinter.entry() entry2.grid(..) entry2.insert(0,"again") entry2.bind("<focusin>", entryfocusedin) entry2.bind("<focusout>", entryfocusedout) def entryfocusedin(params): params.widget.delete(0, tkinter.end) def entryfocusedout(params): # return widget default value # in case of entry1 "hello" # , in case of entry2 "again" you subclass entry widget add attribute store default value, , reference attribute in event handler. however, there's nothing stopping adding own attribute each entry widget directly, e.g. entry1.default_value = 'hello' , entry1.default_valu

maven - no main manifest attribute, in jar -

i trying run jar created maven shade plugin. configuring main class following way: <project> ... <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.manifestresourcetransformer"> <manifestentries> <main-class>org.comany.mainclass</main-class> <build-number>123</build-number> </manifestentries> </transformer> </transformers> </configuration> </ex

node.js - Error: Cannot GET / -

Image
i working in c9.io ide environment, have written below code in server.js file var http = require('http'); var path = require('path'); var async = require('async'); var socketio = require('socket.io'); var express = require('express'); var express = require('express'); var app = express(); var router = express(); var server = http.createserver(router); server.listen(process.env.port || 3000, process.env.ip || "0.0.0.0", function(){ var addr = server.address(); console.log("server listening at", addr.address + ":" + addr.port); }); app.use(express.static(__dirname + '/client')); // respond "hello world" when request made homepage app.get('/', function(req, res) { res.render('index.html'); }); app.get('/about', function (req, res) { res.send('about'); }); after running node server.js in terminal message given your code running @ https://n

C# Application won't close -

i'm writing program uses char value determine string write. have (with both cplant , ssql declared earlier) if (cplant == 'b') { ssql = "somestring1"; } else if (cplant == 'd') { ssql = "somestring2"; } else { messagebox.show("error!"); application.exit(); messagebox.show("shouldn't see this!"); } shouldn't application.exit(); kill program? application.exit(); all post message message pump requesting application closes (much user clicking close icon). all normal exit code (eg. form's implementing onclosing ) run after caller returns message pump can process outstanding messages. of course in code runs cancel closure…

sql - How to pass a parameter into a date function -

i trying create simple function , cannot seem pass in parameter date function. here function: create or replace function test(source int,days text) returns integer $totals$ declare totals integer; begin select count(id) totals ad createdate::date = date(current_date - interval '$2' day) , source = $1; return totals; end; $totals$ language plpgsql; @imsop shed light upon syntax error. however, can simpler, faster , cleaner in multiple ways. create or replace function test(_source int, _days int) returns integer $func$ select count(*)::int ad a.source = $1 , a.createdate::date = current_date - $2 $func$ language sql stable; first of all, subtract days date , can can subtract integer number. accordingly use integer parameter here. how determine last day of previous month using postgresql? you don't need plpgsql simple function this. use sql function instead - can "inlined" in conte

ios - TyphoonStoryboard problems -

i'm trying instantiateinitial viewcontrollers manually , stuck next thing. this working: -(typhoonstoryboard *)storyboard { return [typhoondefinition withclass:[typhoonstoryboard class] configuration:^(typhoondefinition* definition) { [definition useinitializer:@selector(storyboardwithname:factory:bundle:) parameters:^(typhoonmethod *initializer) { [initializer injectparameterwith:@"diary"]; [initializer injectparameterwith:self]; [initializer injectparameterwith:[nsbundle mainbundle]]; }]; definition.scope = typhoonscopesingleton; }]; } -(ladiarymainviewcontroller *)mainviewcontroller { return [typhoondefinition withfactory:[self storyboard] selector:@selector(instantiateinitialviewcontroller)]; } and 1 not working: -(typhoonstoryboard *)storyboardwithname:(nsstring *)name { return [typhoondefinition withclass:[typhoonstoryboard class] configuration:^(typhoondefinition* definition) {

c# - Excel how to fit text in cell, based on cell witdh -

i want set witdh of cell in excelsheet. set witdh: worksheet.columns["k"].columnwidth = 114.80; when text larger columnwith text not visible. i want split text new row in same cell based on columnwith. i tried add \r\n string in excel no result. edit after answers this works perfectly: worksheet.columns["k"].columnwidth = 114; excel.range rangek = worksheet.get_range("k1"); rangek.entirecolumn.wraptext = true; what looking this: worksheet.range("k1:k100").wraptext = true; that code, example, set cells k1 k100 wrap contents inside cells.

r - Find location of the first nonzero number multiple times in a vector -

i iteratively loop wanted see if has idea on how outside of loop. below vector of numbers has 0's , 1's. trying grab location of first 1 in ever cluster appears (the 1s appear in bunch). every time there 1s, want 1 0 comes before it. test_vector <- c(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0

ios - NSCounted set ignoring a property -

this question has answer here: confusion distinct , indistinct object 1 answer i'm trying nscountedset need ignore property, tried overriding isequal method of object, , doing manual compare of properties except 1 want ignore doesn't work any idea on how achieve it? update my class @interface gsordermenumenucontent : gsbasemodel @property (copy, nonatomic) nsnumber *order_content_id; @property (copy, nonatomic) nsnumber *item_id; @property (copy, nonatomic) nsnumber *price; @property (copy, nonatomic) nsnumber *pricewithmodifiers; @property (copy, nonatomic) nsstring *course; @property (copy, nonatomic) nsstring *itemname; @property (nonatomic) gsmenuitem* item; @property (nonatomic) nsmutablearray *modifiers; @property (copy, nonatomic) nsnumber *isalreadyprinted; @property (co

Excel Pivot Table Exclude one Row in Calculated Field -

Image
in microsoft excel want have pivot table uses calculated field row. calculated row exlude current year. want 2 summary rows 1 current year , 1 without. attachment in orange shows desired result. i know can manually make cell formula each month, automatic. thoughts? if row variable called "year", column variable called "month", e1 1 of cells in pivot table , values variable called "score", like =getpivotdata("score",e1,"month","jan")-getpivotdata("score",e1,"month","jan","year",year(now())) and repeat each month. however need leave room under table expand avoid over-writing orange cells. the other way can think of obvious 1 of copying whole pivot table , filtering on row labels, excluding 2015. you can copy pivot table selecting whole table (can use ctrl shift * ), right-clicking, selecting copy , pasting somewhere else. this mini-example showing 2 metho

arrays - filter away duplicates in two lists not containing a dot php -

say have 2 arrays array a n1099 n1100 n1100.1 n1100.2 n1100.3 n1100.4 n1100.5 n1101 n1101.1 array b n1100.1 n1100.2 n1100.3 n1100.4 n1100.5 n1100.6 n1101.1 now can see array contains n1100 , n1101 , has "children" in list b. want remove parent in array becomes: resulting array after comparing 2 arrays n1099 n1100.1 n1100.2 n1100.3 n1100.4 n1100.5 n1101.1 how can done in php? i found questions merge 2 arrays , filter duplicates , thats not case here. want filter away duplicates not containing dot "." in it. php - how compare 2 arrays , remove duplicate values php - merging 2 array 1 array (also remove duplicates) you need in following manner:- <?php $lista = array('n1099','n1100','n1100.1','n1100.2','n1100.3','n1100.4','n1100.5','n1101','n1101.1'); $listb = array('n1100.1','n1100.2','n1100.3','n1100.4','n1100.5','

iis - Same origin policy exception -

uncaught securityerror: blocked frame origin " https://localhost:44300 " accessing frame origin " https://othersite ". protocols, domains, , ports must match. as can see, both sites https. i trying access properties of iframe within website. 1 push me in right direction? if can't make sure both sites run on exactly same protocol, domain , port, might think using proxy solution webserver. depending on browsers , versions need support, can choose cors solve problem.

javascript - Select from two strings where they differ -

my page receives 2 strings: var string1 = "_some_specification_abc_defgh_end_code"; var string2 = "_some_specification_34_kj_w7_end_code"; and want take differ display later title function selectrelevantinfo (string1, string2) { // don't know if regex here }; it should give abc_defgh string1 , 34_kj_w7 string2 . how can achieve it? in advance. here's attempt, few tests make sure when prefix/postfix non-existent, or if both strings, etc. it's similar in spirit pablo's code, in searches front , of strings, rather using indexof @ each iteration ( accidentally quadratic ), scalar character comparisons. function return object containing prefix , postfix both input strings stripped of these. function findprepostfix(a, b) { var minlength = math.min(a.length, b.length); // important initialization , prefix search var prelen = minlength; (var = 0; < minlength; i++) { if (a[i] !== b[i]) { prel

php - WooCommerce - Changes to a template are being ignored -

Image
i have file called content-product-inner.php . file being loaded product-loop, works fine. the variable $layout equals "inner", checked both var_dump , echo . if rename file else, content-product-in.php name doesn't match loaded product-loop products not load on category page, expected. means file placed , being loaded sure. but changes file result in nothing. if add meaningless stuff, such <b>hey</b> . changes aren't displayed if file wasn't changed. this has problem woocommerce settings, please provide me possible explanations unusual behavior?

Whats the best way to accurately scroll to a DIV element with javascript/jquery -

so have page filled divs , on page load need have browser automatically scroll pre-designated div. i'm semi-successfully doing this $('html,body').animate({scrolltop:jquery('#mydiv').position().top}, 'slow'); the problem if page contains images above #mydiv, scroll not accurate. because images load, browser pushes content (including #mydiv) down (this safari). solutions don't work me: 1) give images set width , height way browser knows ahead of time dimensions are , won't push content down load. doesn't work me because images all on internet , not hosted on own server don't know dimensions ahead of time (these user submitted photos) 2) run page scroll after page has loaded. non starter me because takes few seconds images load (many many images) , in time user start scroll browser window , jump #mydiv. becomes confusing , frustrating user. what i'm hoping ideas/pointers/code other solutions? or .... out of luck i&#

java - Eclipse Auto-build eternal loop -

ok have bug causes 1 of project build forever. i have custom ant builder script, runs maven .pom file (i did saves me time on doing things manually) , done after each save in eclipse. however 1 particular project building forever in loop, finishes , of go again. <?xml version="1.0" encoding="utf-8"?> <!-- configuration of ant build task generate jar file each time project updated --> <project name="orderlystatsse" default="execute-pom"> <target name="execute-pom" description="execute orderlystatsse.pom file"> <!-- <exec dir="." executable="cmd"> <arg line="/c mvn -t 4c install -dmaven.test.skip=true" /> </exec> --> <exec dir="." executable="sh"> <arg line="-c 'mvn -t 4c clean compile install -dmaven.test.skip=true'" />

php - CSV upload showing umlauts but it doesn't upload – and „ or “ -

im having issues csv upload script need upload german text mysql database translation purposes. everything utf8 when runs script , inserts database. characters there, umluats show fine – (&mdash) , „ or “ go in blank. the snippet of text im trying upload actual text in csv = "testing – seit über „es ist“ das unternehmen." database after upload = "testing seit über es ist das unternehmen." it uploads umlauts puts space dash , quotes should be. the csv encoded in utf-8 if take utf8_encode() off insert breaks @ first special character. here script header('content-type: text/html; charset=utf-8'); require_once("../cfg/database.php"); mysql_query("set names 'utf8'"); extract($_post); $file = $_files['csv']['tmp_name']; $handle = fopen($file,"r"); $data = array(); $count = 0; if (!empty($_files['csv']['size'])) { while (($data = fgetcsv($handle,1000,",&

java - Declare Two-Dimensional Array - Clarification -

i taking java lessons, , course explaining two-dimensional arrays. first method declaring type of variable create constant arguments how many rows , columns in two-dimensional array. then, used nested for-loop give random numbers particular rows, , columns. the second method declare , initialize two-dimensional array "int[][] nums" line below. know has 3 rows. it's similar putting list in bigger list, how many columns in "nums" array? there may simple answer, little confused right now. thank assistance. import java.util.random; //importing class package public class chap15part4 { public static void main(string[] args) { final int rows = 5; //constant final int cols = 5; //constant int[][] numbers = new int[rows][cols]; //declaring 2-d array constants arguments random rand = new random(system.currenttimemillis()); //seeding random number generator for(int r = 0; r < rows; ++r) //nested for-loop ass

r - Rcpp swap function with NumericVector -

as exploring rcpp came realization following swap function // swap.cpp #include <rcpp.h> using namespace rcpp; // [[rcpp::export]] void swap(numericvector x) { double tmp = x[0]; x[0] = x[1]; x[1] = tmp; } does not perform swap when passed integer vector. example, x <- 1:2 str(x) # int [1:2] 1 2 swap(x) x # [1] 1 2 however, y <- c(1,2) str(y) # num [1:2] 1 2 swap(y) y # [1] 2 1 works fine. suspicion when swap passed integer vector x forced make copy of x converted numericvector. performed on copy of x not effect original variable passed. reasoning correct? if so, why conversion have result in copy? there way write more robust swap function in wouldn't have worry accidentally passing integer vector when should passing numeric vector? i apologize if question has been asked before, not find suitable answer. edit: the code below indeed show copy of object made when integer vector passed swap instead of numeric vector. // [[rcpp::export]]

I cant insert in mysql from php -

whats solution problem number of elements in type definition string doesn't match number of bind variables session_start(); $regvalue1 = $_get['un']; $regvalue2 = $_get['pass']; $regvalue3 = $_get['fn'] ; $regvalue4 = $_get['ln']; $regvalue5 = $_get['age'] ; $regvalue6 = $_get['sex']; $regvalue7 = $_get['em'] ; echo "hello: ".$regvalue3."."; $servername = "localhost"; username = "root"; $password = "b4sonic"; $dbname = "blog"; $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("insert register(un,pass,fn,ln,age,sex,email) values (?,?,?,?,?,?,?)"); bind_param("sss",$regvalue1, $regvalue2,$regvalue3,$regvalue4,$regvalue5,$regvalue6,$regvalue7); $stmt->execut

c - Use scanf in if statement -

why output '4' ? , while input 'a' int main() { int = 5; if(scanf("%d",&a)) printf("%d",a+1); else printf("%d",a-1); } when type sepcifier %d used function expects valid signed decimal integer number entered. evident symbol 'a' not number input failed. now question arises: function return in case? according description of function scanf (the c standard, 7.21.6.4 scanf function): 3 scanf function returns value of macro eof if input failure occurs before first conversion (if any) has completed. otherwise, scanf function returns number of input items assigned, can fewer provided for, or zero, in event of matching failure . so condition in if statement if(scanf("%d",&a)) evaluated 0 (false) , else statement executed. else printf("%d",a-1); that outputed 4. take account in general may enter symbol 'a' integers. in case corresponding in

vbScript that Checks NetworkAdapter Config and updates URL if it detects change -

ok... here seems way more educated stuff i. i've been @ 2 days straight , i've gone @ kinds directions. goal: have script check ip address of local pc. @ time (thinking 5 minutes) recheck ip address again. compare 2 , if there change execute command silently. i realize can not ip address i'll entire state using winmgmts , i'm ok that. it's keep eye on whether or not state changes in general. line of code access url update freedns incase ip changes. whatever reason, none of programs offered have been working. 1 crashes .net framework. knowing i'm utter noob (and thank reading far!) here's crazy broken , utterly bizarre code looks like. assistance divine , apologize dim firstset, secondset set objwmiservice = getobject("winmgmts:") set firstip = objwmiservice.execquery("select * " & "win32_networkadapterconfiguration ipenabled = true") set firstset = firstip wscript.sleep 3 set objwmiservice = getobject(&qu

winusb - WinUSB_AbortPipe Hangs -

if call winusb_abortpipe() winusb_readpipe() starts, deadlock state. ran debug trace log provided here . below last 5 lines in log problem occurs. think readpipe must have missed signal, , abortpipe waiting readpipe complete. [0]4e34.4b58::06/09/2015-15:42:12.528 - ioctl_winusb_read_pipe [0]4e34.4b58::06/09/2015-15:42:12.528 - pipe129: (00000019) read has been added raw io queue [0]4e34.4b58::06/09/2015-15:42:12.528 - pipe129: (00000019) read being handled [2]4e34.4ecc::06/09/2015-15:42:12.529 - ioctl_winusb_abort_pipe [2]4e34.4b58::06/09/2015-15:42:12.529 - pipe129: (00000019) reading 64 bytes device in design, have in endpoints read asynchronously buffers. found best set timeout of read operation infinite because driver hates when cause stalls occur (ran other issues that). need have disconnect sequence cause threads wake realize need close. there way safely that? my workaround instead call winusb_resetpipe(). causes winusb_readpipe() unblock, , doesn't seem lock

google chrome - Is new line a separator in Javascript -

while debugging web spa issue, stumbled on not find concrete references online: missing comma separator between function expressions in javascript. here's details: this works - explicit comma separator there (note - intentionally on 1 line): var f1 = function() { console.log(1); }, f2 = function() { console.log(2);} this doesn't seem work, trying in chrome console (again - one-liner on purpose): var f5 = function() { console.log(5); } f6 = function() { console.log(6);} vm37860:2 uncaught syntaxerror: unexpected identifier @ object.injectedscript._evaluateon (<anonymous>:895:140) @ object.injectedscript._evaluateandwrap (<anonymous>:828:34) @ object.injectedscript.evaluate (<anonymous>:694:21) then 1 seems work - notice missing comma: > var f3 = function() { console.log(3); } f4 = function() { console.log(4); } < function f4() > f4() 4 < undefined > f3() 3 < undefined i looking explanation or

c++ - Linking error with LAPACK under cygwin -

similar problem described in this question , want compile c++ program using lapack under windows 8.1, using cygwin (and written in netbeans). got necessary packages in cygwin (lapack, liblapack-devel, liblapack0), , have written function prototype: extern "c" void dgeev_(char* jobvl, char* jobvr, int* n, double* a, int* lda, double* wr, double* wi, double* vl, int* ldvl, double* vr, int* ldvr, double* work, int* lwork, int* info); but trying compile still throws error linker: $ g++ -llapack -lblas main.cpp /tmp/cc3opfn5.o:main.cpp:(.text+0x349): undefined reference `dgeev_' /tmp/cc3opfn5.o:main.cpp:(.text+0x403): undefined reference `dgeev_' collect2: error: ld returned 1 exit status the code looks (adapted this example ): /* locals */ int n = n, lda = lda, ldvl = ldvl, ldvr = ldvr, info, lwork; double wkopt; double* work; double h = k_max / n; /* local arrays */ double wr[n], wi[n], vl[ldvl * n], vr[ldvr * n]; double a[lda * n]; /* initialize m

angularjs - Angular UI-Router: Can't access state name from service -

Image
i want detect name of current state service. problem: $state.current.name returns null. app.factory('rootuserservice', ['$http', '$state', '$stateparams', '$rootscope', '$q', 'socketfactory', function($http, $state, $stateparams, $rootscope, $q, socketfactory) { return { guestornot: function(res) { if ( res._id === 'someid' ) { $rootscope.isguest = true; } else { $rootscope.isguest = false; // if current state = app.landing, something. console.log($state) // current.name field 'app.landing' console.log($state.current) // name field empty console.log($state.includes('app.landing')) // returns false no matter what. }; } }]); console.log($state) returns below: console.log($state.current) returns below

java - Spray Client (i.e. AKKA) within Tomcat, cause Threading issue -

i using spray client i.e. akka within tomcat webapp. while destroy actor system on tomcat shutdown via spring, i'm nevertheless still facing threading issue. i found issue reported few years ago tomcat complaints when re-deploying servlet akka inside , not find solution it i'm using default spray-client configuration. here error when stop tomcat. (sorry amount of information try give clue possible) 10-jun-2015 12:54:22.516 warning [localhost-startstop-1] org.apache.catalina.loader.webappclassloaderbase.clearreferencesthreads web application [root] appears have started thread named [poolpartyconnector-actorsystem-scheduler-1] has failed stop it. create memory leak. stack trace of thread: java.lang.thread.sleep(native method) akka.actor.lightarrayrevolverscheduler.waitnanos(scheduler.scala:226) akka.actor.lightarrayrevolverscheduler$$anon$8.nexttick(scheduler.scala:405) akka.actor.lightarrayrevolverscheduler$$anon$8.run(scheduler.scala:37

java - Spring validation annotation using message with parameters -

i'm trying use annotations custom message in spring/hibernate validation. want support internationalization while being able pass in parameter. for instance, here field in java class: @notempty (message = "{error.required}") public string name; validationmessages.properties has this: error.required = {0} required field so i'm looking way pass in field name message using message annotation in java class. possible? edit: similar question: jsr 303 bean validation in spring

python - Get values of multiple select with Selenium? -

i have multiple select element: <select multiple="multiple" id="myselect"> <option value="al">alabama</option> <option value="ak">alaska</option> ... </select> how can values of element selenium? this have: elem = self.browser.find_element_by_css_selector('#myselect') self.assertequal('ny', denom_val.get_attribute("value")[0]) self.assertequal('co', denom_val.get_attribute("value")[1]) but in fact, get_attribute returning string, not array of values. guess because selenium doesn't spot it's multiple element. is there way around this? this java way asking. hope help. cheers. // values array list<webelement> selelement = driver.findelements(by.cssselector("select#myselect > option")); string[] seltext = new string[selelement.size()]; // text of corresponding elements array

matplotlib - Is there a python equivalent for "Screen Reader" in Origin Software? -

Image
i plotting 2 graphs on same curve. code goes : x = np.array([86,14,19,24,30,55,41,46]) y1 = np.array([96,86,82,78,80,101,161,32]) y2 = np.array([54,54,48,54,57,76,81,12]) y4 = np.concatenate([y2.reshape(8,1),y1.reshape(8,1)],1) plot(x,y4) i need values @ points other in x array. example: values 30,50 , 78. there option read data graph in origin using "screen reader" (i.e. when point in graph, value.). is there equivalent in python? .plot matplotlib.plot here's simple method, i'm going highlight limitations. it's great since requires no complex analysis, if data sparse, or deviates linear behavior, it's poor approximation. >>> import matplotlib.pyplot plt >>> plt.figure() <matplotlib.figure.figure object @ 0x7f643a794610> >>> import numpy np >>> bins = np.array(range(10)) >>> quad = bins**2 >>> lin = 7*bins-12 >>> plt.plot(bins, quad, color="blue") [<mat

android - Meteor: how to detect a new user to display an app intro screen? -

how know user first time user? needs work anonymous users (before they've logged in) , must remember if user has dismissed intro screen after updates of app. this web , mobile app (android , ios) thanks! when use dismisses intro screen, store persistent session variable. check package https://github.com/okgrow/meteor-persistent-session more information. before displaying intro message, check session variable set.

java - Dropwizard 0.7 service hangs while writing output -

i have dropwizard 0.7.0 service. jetty 9.0.7 jersey 1.18.1 occasionally (1 in 5000 requests) service spend 60 seconds writing response. appdynamics showing 60 seconds being spent inside com.sun.jersey.spi.container.servlet.webcomponent$writer:write:300. after 60 seconds following exception: org.eclipse.jetty.io.eofexception.closed @ org.eclipse.jetty.server.httpoutput.write(httpoutput.java:171) @ org.eclipse.jetty.servlets.gzip.abstractcompressedstream.write(abstractcompressedstream.java:226) @ com.sun.jersey.spi.container.servlet.webcomponent$writer.write(webcomponent.java:300) @ com.sun.jersey.spi.container.containerresponse$committingoutputstream.write(containerresponse.java:135) @ com.fasterxml.jackson.core.json.utf8jsongenerator._flushbuffer(utf8jsongenerator.java:1862) @ com.fasterxml.jackson.core.json.utf8jsongenerator.close(utf8jsongenerator.java:1087) @ com.fasterxml.jackson.jaxrs.base.providerbase.writeto(providerbase.java:649) @ com.sun.jersey.sp

parse.com - Multiple Parse.Cloud.httpRequest in Parse.Cloud.job -

i need implement following in parse.cloud.job: get objects parse.com class make parse.cloud.httprequest using values of each 1 of objects parse.com class process parse.cloud.httprequest response , save parse.com class currently can retrieve objects class (step 1) when trying make httprequest (step 2) cloud job finished. parse.cloud.job("mycloudjob", function(request, status){ var countobjects; var objectsarray = []; var query = new parse.query("myclass"); query.limit(200); query.find().then(function(results){ countobjects = results.length; objectsarray = results; }).then(function(){ for(i = 0; < countobjects; i++){ var valueone = objectsarray[i].attributes.valueone; parse.cloud.httprequest({ url: 'https://www.myapi.com/', params: {value: valueone} }).then(function(httpresponse) { console.log(httpre

git - Zip with ignore within Bash script -

found wonderful little bash script i've adapted use zip compressing managed directories, ignoring files bower_components , .git , node_modules : #!/bin/bash # script zips directory, excluding specified files, types , subdirectories. # while zipping directory excludes hidden directories , file types [[ "`/usr/bin/tty`" == "not tty" ]] && . ~/.bash_profile directory=$(cd `dirname $0` && pwd) if [[ -z $1 ]]; echo "usage: managed_directory_compressor /your-directory/ zip-file-name" else directory_to_compress=$1 zipped_file="$2.zip" compress_ignore_dir=("\.git" "node_modules" "bower_components") ignore_list=("*/\.*" "\.* "\/\.*"") if [[ -n $compress_ignore_dir ]]; ignore_dir in "${compress_ignore_dir[@]}"; ignore_list+=("$directory_to_compress/$ignore_dir/***") ## "$directory_to_compress/$ignore_dir/*&quo

.htaccess - A description for this result is not available because of this site's robots.txt – learn more For mobile version -

i created website www.example.com. created mobile version of website subdomain www.m.example.com. used htaccess file redirectiong mobile version in smartphones. put mobile website's files in folder named "mobile". put robot.txt file in main root folder prevent indexing mobile urls in search engines result. robot.txt file this. user-agent: * disallow: /mobile/ i put robot.txt file in folder named mobile. user-agent: * disallow: / my problem that. in desktop version result , snippets correct. when searching in mobil, result in snippet shows this. a description result not available because of site's robots.txt – learn more how solve this? by using robots.txt on www.m.example.com user-agent: * disallow: / you forbidding bots crawl resource on www.m.example.com . if bots not allowed crawl, can’t access meta - description . so working intended. if want pages crawled (and indexed), have allow in robots.txt (or remove altogether). by usi

java - package org.powermock.api.easymock does not exist using gradle -

using gradle android. i trying powermock compile dependency. i have dumbed down attempts working , still not working. below build.gradle , activity. doing way demonstrate error , trying working. //error error: package org.powermock.api.easymock not exist import org.powermock.api.easymock.powermock; //build.gradle apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "22.0.0" defaultconfig { applicationid "android.testing.powermock" minsdkversion 19 targetsdkversion 21 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0'

node.js - getting info about facebook user using passport -

this first steps in node.js in general , passport in particular , came across annoying issue. trying events user attended hes facebook profile no matter tried didn't work. thought "ok, lets , other data" except basic display name , profile pic other attempt (birthday,events,friends list etc..) ends no data. tried using facebook's api alot in last few days (for first time) , couldnt figure out...this last attempt: passport.use(new facebookstrategy({ clientid: config.fb.appid, clientsecret: config.fb.appsecret, callbackurl: config.fb.callbackurl, profilefields: ['id', 'displayname', 'photos', 'birthday', 'events', 'profileurl', 'emails', 'likes'] }, function(accesstoken, refershtoken, profile, done){ //check if user exists in our mongo db database //if not, create 1 , return profile //if exists, return profile usermodel.findone({'profileid':profile.id}, function

inheritance - Java 8 - Call interface's default method with double colon syntax -

i'm delving java 8 innovations, , i'm trying call default method implement in high-level interface, when subclass overrides it. have no problem going implementing comparator in businesslogic class, wondering if there's magic lets me use nifty new :: . code: public interface identity extends comparable<identity> { int getid(); @override default int compareto(identity other) { return getid() - other.getid(); } } public class game implements identity { @override public int compareto(identity o) { if (o instanceof game) { game other = (game) o; int something; // logic return something; } return super.compareto(o); } } public class businesslogic { private void sortlist(list<? extends identity> list) { // game, game::compareto gets called want, in call only, default method collections.sort(list, identity::compareto); } }

Hubot change IRC channel topic -

i'd our hubot manage topic of irc channels. when have hubot send "/topic #channel new topic" text ends in channel. i know can add listener irc topic changes (like irc-topic.coffee ) with: robot.adapter.bot.addlistener 'topic', (channel, topic) -> but there interface setting topic or way coerce hubot-irc adapter send raw irc command? https://github.com/nandub/hubot-irc/blob/master/src/irc.coffee#l40 it looks setup listener , topic = "thing topic should be"

Delphi passing Types in parameters -

an example, need solve problem in framework developing : //unit2 : procedure a(aform : tform; aclasstype: tformclass); begin showmessage (aclasstype(aform).edtuser.text); end; ... //unit1 : uses unit2; begin form1 := tform1.create; try a(form1, tform1); form1.free; end; end; the compiler not accept line: aclasstype (aform).edtuser.text one solution use: uses unitoftform1; procedure (aform: tform; aclasstype: tform1); begin showmessage (aclasstype (aform).edtuser.text); end; but can not because giving circular reference , need decoupling in framework is there way make typecast passing parameter type of form or there way ? what asking can done either: deriving various form classes common base class exposes field want access: procedure a(aform : tbaseform); begin showmessage(aform.edtuser.text); end; type tbaseform = class(tform) edtuser: ted