Posts

Showing posts from June, 2014

r - invalid factor level, NA generated when I try to add row to dataframe with var1 and Freq -

i have data frame, head of is: head(loss_freq_table) var1 freq 1 1101 19 2 1102 18 3 1103 12 4 1104 19 5 1105 16 6 1106 12 however, when type loss_by_team<-rbind(loss_by_team, data.frame(var1=1455, freq=0)) , error warning message: in `[<-.factor`(`*tmp*`, ri, value = 1455) : invalid factor level, na generated and when type loss_by_team[which(loss_by_team$var1=="1455"), ] , get [1] var1 freq <0 rows> (or 0-length row.names) anyone know why is?

c - Accessing and storing elements in an array -

i have modified version of quicksort in program instructed sort pairs of numbers sum of squares ( example: -4,1 > 2,2 ). program works fine positive integers , when use many negative integers program crashes (any more 1 or 2 negative numbers cause crash). think i'm trying access or sort undefined parts of array storing integers . array storage forgetting? or problem elsewhere? void swap(int *a,int *b); int square(int num); int abs_value(int num); void quicksort(int arr[],int first,int last); int main() { int num_of_pts; int num1; int num2; printf("enter number of points: ");//points coordinates on xy axis scanf("%d", &num_of_pts); //that's why there double int unsorted_pts_arr[2*num_of_pts];//the amount of storage in array for(int i=0; i<num_of_pts; i++){ printf("enter point: "); scanf(" %d",&num1); scanf(" %d",&num2); unsorted_pts_arr[2*i]=num

I am trying to do union of three lists of type T in C# , but when any of them is null it throws null reference exception -

here code snippet: var joinedlist = list1.list.where(x => x != null) .union(list2.list.where(x=> x!= null).union(list3.list.where(x => x!= null))).tolist(); var joinedlist = new list<t>(); if (list1.list != null) joinedlist = joinedlist.union(list1.list.where(x=>x!=null); if (list2.list != null) joinedlist = joinedlist.union(list2.list.where(x=>x!=null); if (list3.list != null) joinedlist = joinedlist.union(list3.list.where(x=>x!=null);

powershell - Nested arrays and ConvertTo-Json -

to use rest api, must pass json object looks this: { "series" : [{ "metric": "custom.powershell.gauge", "points":[[1434684739, 1000]] } ] } note nested array here. cannot reproduce this. here code: [int][double]$unixtime=get-date ( (get-date).touniversaltime() ) -uformat %s $obj=@{} $series=@{} $array=@() $points=@() $value=get-random -minimum 0 -maximum 100 $series.add("metric","custom.powershell.gauge") $points=@(@($unixtime, $value)) $series.add("points",$points) $obj.add("series",@($series)) $json=$obj | convertto-json -depth 30 -compress $json and here output: {"series":[{"points":[1434685292,95],"metric":"custom.powershell.gauge"}]} i've tried many things, cannot 2 arrays nested, end looking single array. on same note, came explain please: > $a=(1,2) > $a 1 2 > $a | convertto-json [ 1, 2 ] > $

html - Increase the space between the image and the text -

how increase space between image , div? have display text in div object. image in 1 tag, , text in div tag beside image. <div> <div id="top"> <img src="" id="toppopupimage" hspace="50" style="width:85px;height:90px;float:left;background-color:white;"> <div id="text" class="externaltext"></div> </div> </div> one way add margin , float #text div: #text { margin-left: 15px; float: left; } <div> <div id="top" > <img src="" id="toppopupimage" hspace="50" style="width:85px;height:90px;float:left;background-color:white;"> <div id="text" class="externaltext">text</div> </div> </div> another way remove float image , set display: inline-block; on elements: img { width:

HTTPS connection is not working [Spring Boot] -

i setting https server using spring boot. followed configure ssl on spring boot docs . my application.properties file follows. # ssl server.port = 8443 server.ssl.key-store = classpath:keystore.jks server.ssl.key-store-password = rootroot but when access https://localhost:8443 . server returns no response , server temporarily down. can guide me going wrong? finally, found answer. using keystore.jks generated machine instead of generating in server machine. now solved problem using keystore generated keytool on server machine , went well. anyway, thank answers.

scroll - Horizontal scrolling top menu iOS like instagram -

how implement menu? want best way =) image of saying... https://dl.dropboxusercontent.com/u/43484361/arquivo%2018-06-15%2023%2015%2056.jpeg

sql - Joining two tables and getting rows as columns -

i have 2 tables. 1 transaction table of user id following details. user_id product_id timestamp transaction_id 123 a_1 id1 123 a_2 id1 124 a_1 id2 125 a_2 now there product_id mapping division product belongs mapping: product_id division a_1 grocery a_2 electronics , on i need final table have 1 record each user id , corresponding items bought in each division separate columns. user_id grocery electronics 123 1 1 124 1 0 i did this: select user_id, case (when division ="grocery" count(product_id) else 0) end grocery when division="electronics" count(product_id) else 0) end electronics ( select user_id, a.product_id, b.division transact left join mapping b on a.product_id=b.product_id ) group user_id sound good? when use conditional aggregation, case argument aggregation function: select user_id, sum(ca

c# - Fluent Validation - Stop validating all other validations when a specific validation fails -

i'm using fluent validation server side validation. i've created set of rules validated. these rules individual functions in validator. public samplevalidator() { validate_authorisation(); validatetitle_notempty(); validategender_notempty(); validatefirstname_regex(); validatefirstname_notempty(); validatesurname_notempty(); validatesurname_regex(); validatemobilephone_regex(); } private void validate_authorisation() { rulefor(model=> model) .must(model=> isuserauthorised(username)) .withname("authorisation check"); } private void validatetitle_notempty() { rulefor(model=> model) .must(title=> !string.isnullorempty(title)) .withname("title"); } private void validategender_notempty() { rulefor(model=&

java - Updating Jframe based on JLabel Click -

i making "super tic-tac-toe" application in java. here description of aiming for. http://mathwithbaddrawings.com/ultimate-tic-tac-toe-original-post . having problems updating jframe on click. application made of individual cells (jlabels) make tic-tac-toe boards (jpanels) reside in jframe. my problem using getsource on mouseclick me seep jpanel, , cannot access cell of tic-tac-toe grid pressed. there way check 1 pressed current method of organizing project? here code viewing tictactoe board contains listener: public class tictactoeview extends jpanel { public cellview[][] cv; public tictactoe ttt; public tictactoeview(tictactoe t) { int rows = 3; int columns = 3; cv = new cellview[3][3]; ttt = t; setsize(3 * 64, 3 * 64); setbackground(color.white); setlayout(new gridlayout(rows, columns)); setvisible(true); setfocusable(true); (int = 0; < 3; i++) { (int j

ruby command line gem not working in windows -

i wrote command line gem based on tutorial here: http://robdodson.me/how-to-write-a-command-line-ruby-gem/ it works fine in linux, reason can't run in windows. in windows following error: c:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- my_gem_name (loaderror) c:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' c:/ruby193/lib/ruby/gems/1.9.1/gems/my_gem_name-0.0.1/bin/importer:3:in `<top (required)>' c:/ruby193/bin/importer:23:in `load' c:/ruby193/bin/importer:23:in `<main>' any insight appreciated

Collections of Traits with types generics in Scala 2.10 -

i'm trying build collections of objects, defined @ run time , using type generics, referring superclass (well, trait), i'm having tough time transforming them child objects. example code , results: trait mytrait[t] { def f(x: t): int } class foo extends mytrait[double] { def f(x: double) = 1 } class bar extends mytrait[string] { def f(x: string) = 2 } val fooinstance: foo = new foo val barinstance: bar = new bar val mytraitlist: list[mytrait[_]] = list(fooinstance, barinstance) println(fooinstance.getclass) // prints "class myexample$foo" println(barinstance.getclass) // prints "class myexample$bar" println(mytraitlist(0).getclass) // prints "class myexample$foo", list preserving object classes , not "mytrait[_]" println(mytraitlist(1).getclass) // prints "class myexample$bar", again, preserving object class println(fooinstance.f(1.0)) // prints "1" println(barinstance.f("blah")) // prints

java - Why isn't the scanner input working? -

so new java programmer , trying figure out why piece of code isn't working. issue having line: "string interests = input.nextline();", skips user's input , jumps next system.out, displays "your profile..." in console before allowing user input data. sorry if it's dumb question, i'm new! system.out.println("hello, " + name + "! gender?"); string gender = input.nextline(); system.out.println("okay, " + name + ", " + gender + ". now, tell me, age?"); int age = input.nextint(); system.out.println("great! we're done. 3 interests have?"); string interests = input.nextline(); system.out.println("...your profile..."); system.out.println("name: " + name); system.out.println("gender: " + gender); put this: int age = input.nextint(); input.nextline(); system.out.println("great! we're done. 3 interests have?"); string interests = input.ne

sql server - Cant execute this instruction in the database GRANT EXEC sp_configure to user -

i have database called sa-db , in database have user called sa-clientap , need grant him permissions execute sp_configure , when try this, error: permissions on server scoped catalog views or stored procedures or extended stored procedures can granted when current database master this tried: grant exec [sys].[sp_configure] [sa-clientapp] i tried code , uid same error pops up. how can make work? how this.... use master go grant exec [sys].[sp_configure] [sa-clientapp]; go

c++ - Double template<> in template specialization -

why code below compile? not specializing template member function of template class, 1 template<> should used. however, g++ compiles no warnings whatsoever, clang++ gives warning warning: extraneous template parameter list in template specialization template<typename t> struct s{}; template<> template<> // why can this? struct s<int>{}; int main() { } because grammar allows it, , there doesn't seem under template specialization section prohibits it: from [gram.temp] explicit-specialization : template < > declaration from [gram.dcl] declaration : [...] explicit-specialization the fact grammar lax has been in active issues list (#293) since 2001.

command line - How do I run a perl script on multiple files and produce the same number of saved output files? -

i have simple perl script want run on folder full of .txt files. i read answers how run perl script on multiple input files same extension? , did not understand how implement answers. i have have googled etc. , not understand answers on perlmonks. on mac os terminal using perl myscript.pl input.txt > output.txt but don't know how run on folder full of .txt files. i'd content either producing new set of modified .txt files (one output per input) or editing files , overwriting input output if easier. this more of command line/bash question perl question, understand want run following against multiple files perl myscript.pl input.txt > output.txt the easiest way execute following command terminal find . -name "*.txt" -exec sh -c 'perl myscript.pl {} > {}.out' \; this files match *.txt , , execute command between --exec sh -c' , '\; , replacing {} name of file.

c# - Enum defined as IsOptional cannot be queried for null values -

i have defined enum property on entity via fluent api isoptional. database reflects isoptional shows nullable type. when attempt query entity property null values following error: the 'usertype' property on 'group' not set 'null' value. must set property non-null value of type 'usertype'. the query follows: var groups = (from g in db.groups let reqs = r in db.requests r.id == requestid gg in r.groups select gg.id g.contentarea.id == db.requests.firstordefault(o => o.id == requestid).contentarea.id !reqs.contains(g.id) (g.usertype == db.requests.firstordefault(r => r.id == requestid).user.usertype || g.usertype == (usertype?)null) select g).tolist(); and part breaks after or statement g.usertype == (usertype?)null i've tried compare g.usertype null, set instance of usertype? nulltype = null , compared nothing se

Error loading OpenCV in Java for Image Processing -

i facing problem in loading opencv in java(eclipse, mac osx). new java , main target image processing.i have checked several examples online but....i have few queries actually: 0) can instruct me how use opencv library java in eclipse in mac os x? have downloaded jar , done import.... 1) below sample of code mat = highgui.imread("/users/.../dropbox/imagejspace/image_0001.jpg", 1); mat b = null; imgproc.cvtcolor(a, b, imgproc.color_bgr2gray); highgui.imwrite("/users/.../dropbox/imagejspace/image_0001gray.jpg", b); in section, trying read image, covert matrix, graysale , save image again. in examples checked online, have mentioned cvtcolor overtime try write doesn't work. have write highgui.cvtcolor , each keyword new library. 2) following error: exception in thread "main" java.lang.unsatisfiedlinkerror: no opencv_java in java.library.path @ java.lang.classloader.loadlibrary(classloader.java:1764) @ java.lang.runtime.loadlib

c++ - Use of "template<>" for static members -

i came across code has confused me. have distilled confusion down simple case template<typename t> struct s { t member; static const size_t size; }; struct u { int i; }; typedef s<u> us_t; template<> const size_t us_t::size = sizeof(u); q1: why need " template<> " on last line, since us_t described? the code came across - compiles - has equivalent of this: template<>template<> const size_t us_t::size = sizeof(u); i'm pretty sure cut-and-paste error wasn't caught because compiled. q2: valid? if so, why? [i notice codepad.org compile code " template<>template<> ".] imagine typedef macro that's expanded @ compile time instead of pre-processor time. then without template<> you'd have const size_t s<u>::size = sizeof(u); and that's not valid syntax, because you're doing template specialization

performance - for...of - JavaScript keyword Internet Explorer work-around -

i using “for...of” in many places in javascript code new technology, part of javascript’s new specification (ecmascript 2015 (e56) standard). "for...of" supported in chrome, safari , firefox. though, ie doesn’t yet support new feature ( see link ). best approach support these 4 main browsers - revert "for in/for loop" or use browser-sniffing code or there better hack able both use hybrid "for...of" , "for...in"? not repeat of question here: link_here because aware ie not support "for...of". looking if there hack still use , still support 4 browsers listed? you can add traceur compiler: <script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script> <script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script> <script type="module"> for(var n of ['foo', 'bar']) alert(n); </script> it

ant - Load balance execution of UI tests (Selenium) on multiple identical app instances (URLs) -

i trying run ui tests on multiple identical instances of web application. example, let's identical version of application available @ 3 places: https://some1.app.com https://some2.app.com https://some3.app.com the intended system should check instance available , run test (that not run) on it. should able run 3 tests on 3 instances simultaneously in jenkins environment. i have explored jenkins matrix configuration, appears run tests on possible combinations in matrix. intention divide , load balance tests, not run on combinations. ideas on how can done? i using junit4 ant running tests on jenkins. one solution matrix project plugin . configure url parameter bit in here: building matrix project

html - Keep 'transform-scale' aspect ratio for iframe -

i'm having trouble keeping ' transform-scale ' attribute on aspect ratio when browser window being resized. instance, if window resized, iframe transform-scale attribute scale contents inside fit iframe width , height without resizing of sites contents. can't seem understand how achieve without using javascript or other libraries. came below: html: <div> <iframe id="resize" src="http://www.w3schools.com/" width="100%" height="100%"></iframe> </div> css: * { margin:0; padding:0; } div { height: 100vw; width: 56.25vw; /* 100/56.25 = 1.778 */ background: skyblue; max-height: 100vh; max-width: 177.78vh; /* 16/9 = 1.778 */ margin: auto; position: absolute; top:0; bottom:0; /* vertical center */ left:0; right:0; /* horizontal center */ } iframe { -webkit-transform:scale(0.8); -moz-transform-scale(0.8); -o-transform: scale

ruby on rails - Nginx Unicorn AngularJS html5 URLs configuration -

i want add pretty urls in angular ui-router. have nginx + unicorn on rails app angular js front-end. i want have pretty urls mysite/a/b/c, no '#' , no hashbang. when change location of nginx to: server { server_name yoursite.com; root /path/to/app; location / { try_files $uri $uri/ @unicorn; } } unicorn throw error: directory index of "/path/to/app" forbidden any idea on how setup nginx redirect? giving chmod app path isn't solution believe.. edit: issue try_files $uri/index @unicorn, works e.g. url.com/a/b. when refresh, automatically redirects me root url.com. ui-router suggests try_files $uri $uri/ /index.html, when access denied nginx. folder /path/to/app belongs user 'deploy', it's not chmod issue.. finally solved it! mistake, because running app angular forgot in rails routes.rb file line: get '*path' => '/' changed get '*path' => 'layouts#index'

ruby - Rails - Everytime I create a new project I get: Error during failsafe response: wrong number of arguments (2 for 1) -

whenever create new projects in rails using rails new project_name , start server @ localhost:3000, keep getting following error: rendered /users/banait/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (8.4ms) error during failsafe response: wrong number of arguments (2 1) /users/banait/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-4.2.1/lib/action_dispatch/http/request.rb:338:in `parse_query' /users/banait/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-1.6.3/lib/rack/request.rb:191:in `get' /users/banait/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-4.2.1/lib/action_dispatch/http/request.rb:300:in `get' /users/banait/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-4.2.1/lib/action_dispatch/http/parameters.rb:14:in `parameters' /users/banait/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-4.2.1/lib

amazon web services - Beanstalkd queue with AWS elastic beanstalk -

i wan't deploy web app running inside docker containers elastic beanstalk. when deploying app elastic beanstalk have 2 environment options can choose from: web server environment worker environment logically webapp uses first environment type, need make use of job queue used long running processes, run in second type environment. don't want use amazon sqs because of vendor lock in have when want switch different host. want running beanstalkd instead, can't think off solution how set up. i this answer given rohit banga. force me use sqs though right? i find important have on repository code. workers use same code web app. 1 repo think easier maintain. i think i'll setup , ec2 instance run beanstalkd server. if going run own queue , not require (or want) sqs, use webserver. web server , worker same thing. difference worker tier doesnt have load balancer. worker tier work of setting sqs queue deamon directs queue data "web listener"

javascript regex decimal -

var re = /^([0-9]*)(\.[0-9]{2})$/ re.test(.22) true re.test(.20) false re.test(10.02) true re.test(10.00) false i want pass 10.00, 10.02, 10.20. looks passing 10.02. what doing wrong? the trailing zeroes truncated when automatic string conversion done during call test() . use tofixed() string conversion manually instead. for example: var re = /^([0-9]*)(\.[0-9]{2})$/; re.test((.22).tofixed(2)); //true re.test((.20).tofixed(2)); //true re.test((10.02).tofixed(2)); //true re.test((10.20).tofixed(2)); //true re.test((10.00).tofixed(2)); //true

Proguard with Cordova Android 4? -

i had proguard running release builds when cordova built ant, gradle used project's release builds aren't being obfuscated (my "cordova build --release android" output shows step :cordovalib:mergereleaseproguardfiles, no other proguard/minification/obfuscation entries). with ant, project.properties file referred proguard-project.txt file using proguard.config parameter. how configure work cordova uses gradle? have @ updated proguard documentation , have change build.gradle file. change buildtype release section android { ... buildtypes { release { minifyenabled true proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } }

node.js - Unable to connect to mongolab, Getting MongoError: auth failed -

i have created account in mongolab.when trying connect database using below statement. var mongoose = require('mongoose'); mongoose.connect('mongodb://mk:12345@ds047742.mongolab.com:47742/mkdb'); i'm getting following error mongoerror: auth failed @ function.mongoerror.create (/users/a042292/desktop/start/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:31:11) @ /users/a042292/desktop/start/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:793:66 @ callbacks.emit (/users/a042292/desktop/start/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:94:3) @ null.messagehandler (/users/a042292/desktop/start/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:235:23) @ socket.<anonymous> (/users/a042292/desktop/start/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/

javascript - fixed sticky header expanding -

i have following issue. trying make fixed header on top. page responsive , when screen small header if clicked expands pushing down content... issue can't find solution make work.. either put position:fixed; , header stays on top, content not pushed down... if position relative content gets pushed down header not stick top. there solution this? possibly css if not javascript.. css: .header { width: 100%; height: inherit; margin-bottom: 5px; float: left; position: fixed; z-index: 999; top: 0; left: 0; background: #f3f3f3; -webkit-box-shadow: 0px 1px 1px #000; -moz-box-shadow: 0px 1px 1px #000; box-shadow: 0px 1px 1px #000; } javascript: function showmobilebar(){ $(menu).hide(0); $(showhidebutton).show(0).click(function(){ if($(menu).css("display") == "none") $(menu).slidedown(settings.showspeed); else $(m

linux - Using find command to search for files in one directory which are not in the other, then move them -

i able use gnu find command in bash find exact filenames in somedir_v1 not match filenames in somedir_v2, , move files somedir_v1 newdir_v1 the thing is, while copy somedir_v2 on somedir_v1, , have newer versions of files, both of these directories have 40gb files. don't know if access time (atime) update when move them, might not know files inside, files replaced , wasn't replaced. anyway, i'm not going way. if there's bash line can use, please let me know. thank you.

angularjs - angular link. What is # and what does it do? -

i working through ca angular course. had question code: <div class="main"> <div class="container"> <h2>recent photos</h2> <div class="row"> <div class="item col-md-4" ng-repeat="photo in photos"> <a href="#/photos/{{$index}}"> <img class="img-responsive" ng-src="{{ photo.url }}"> <p class="author">by {{ photo.author }}</p> </a> </div> </div> </div> </div> in so when click photo, angular knows it's index , index gets relayed photocontroller routeparams right , can access via $routeparams.id. #? # used in called hash navigation separate section of url's elements. hash navigation used angular interior hash routing rather full page routing.

java - Syntax error (missing operator) in query expression 'Nombreproductos ==' some product ' -

i have code: try{ class.forname("sun.jdbc.odbc.jdbcodbcdriver"); string db = "jdbc:odbc:driver=microsoft access driver (*.mdb);dbq=productosh.mdb"; connection con = drivermanager.getconnection(db, "", ""); statement s = con.createstatement(); resultset hola = s.executequery("select precioventau productos nombreproductos == '"+jcombobox1.getselecteditem()+"'"); while (hola.next()){ double preciou = hola.getdouble("precioventau"); system.out.println(preciou); jtextfield5.settext(string.valueof(preciou)); } } catch(classnotfoundexception | sqlexception e){ joptionpane.showmessagedialog(null, e); e.printstacktrace(); } supossed set in textfield result of query. raise exception can't figure how solve it. java.sql.sqlexception: [microsoft] [odbc microsoft access driver] syntax er

android - How to get a users current state(location) -

i'm trying create android app calculates sales tax(this dependent on state or province you're in) can't figure out how state/province android user in. this best approach: first of check providers enabled. may disabled on device, may disabled in application manifest. if provider available start location listeners , timeout timer. it's 20 seconds in example, may not enough gps can enlarge it. if update location listener use provided value. stop listeners , timer. if don't updates , timer elapses have use last known values. grab last known values available providers , choose recent of them. here's how use class: locationresult locationresult = new locationresult(){ @override public void gotlocation(location location){ //got location! } }; mylocation mylocation = new mylocation(); mylocation.getlocation(this, locationresult); import java.util.timer; import java.util.timertask; import android.content.context; import android.loca

Format Date VARIABLE to short date VBA -

i have user inputted via userform.textbox.value. general date want switch short date. (or try time drop reads 00:00). tried code sdate=format(date,(d)) but returns current date rather variable date without time. want drop time if there easier way accepting of idea. please, see: format function . usage: 'userform has textbox named txtdate dim mydate date, sdate string mydate = me.txtdate 'dateserial(2014,12,11) sdate = format(mydate, "short date") 'or sdate = format(mydate, "yyyy/mm/dd")

PostgreSQL - aggregating data by date from datetime field -

i have data on time particular users , timestamp of form 2013-11-23 16:00:00-05 - there's minute minute date each user , corresponding usage value. so table has values: user_id, localminute, usage. i trying aggregate usage @ day wise level, did far below s looking easier way without creating dummy column date_event: alter table tablename add column date_event date update table set date_event = date(localminute) select sum(use), date_event tablename group date_event my question how can extract date timestamp , aggregate in single query. help! just cast date: select sum(use), localminute::date tablename group localminute::date; or using standard sql: select sum(use), cast(localminute date) tablename group cast(localminute date);

python - How to get the real cube root of a negative number in Python3? -

python 3.4 seemingly randomly decides whether returns real or complex root of number using ** operator: >>> (863.719-2500) -1636.281 >>> -1636.281**(1/3) -11.783816270504108 >>> (863.719-2500)**(1/3) (5.891908135252055+10.205084243784958j) is there way ensure real root when cube rooting rather 1 of complex ones? in second case cube root getting evaluated first minus sign getting applied, hence real root. that -1636.281**(1/3) becomes -(1636.281**(1/3)) . , can use similar logic real cubic roots well. but actually, when doing cubic root of negative numbers complex numbers in python. >>> -1636.281**(1/3) -11.783816270504108 >>> (-1636.281)**(1/3) (5.891908135252055+10.205084243784958j) if want real numbers can add code - def cube(x): if x >= 0: return x**(1/3) elif x < 0: return -(abs(x)**(1/3))

angularjs - Weird Content of Facebook share/like button preview from angular app -

i have issue share/like button angular app. made working correctly links share/like preview if wrong. tried xfbml.parse(), switching html 5 mode, etc. there 2 complete enigmas: 1. got "given url not allowed application configuration..." despite adding possible variants fb app setting. when share preview appear - has "angular", never added anywhere. here link would grateful ideas... thx the facebook scraper looks @ html code server delivers, not execute javascript. so if want share different articles, need individual url each article, delivers relevant meta data when requested server. you can find more explanation , hints on how implement in article, http://www.michaelbromley.co.uk/blog/171/enable-rich-social-sharing-in-your-angularjs-app

intent open chrome in a url - not in lollipop -

public void onclickapp(view view){ intent intent = new intent("android.intent.action.main"); intent.setcomponent(componentname.unflattenfromstring("com.android.chrome/com.android.chrome.main")); intent.addcategory("android.intent.category.launcher"); intent.setdata(uri.parse("http://www.google.com")); startactivity(intent); } this code open google chrome , open web www.google.com. on android 5, open google chrome not load www.google.com. why? sorry bad english. thanks i think thats beacuse activity doesn't exist in android lollipop. try this: public void onclickapp(view view){ intent intent = new intent(intent.action_view); intent.setdata(uri.parse("http://www.google.com")); intent.setpackage("com.android.chrome"); startactivity(intent); }

ios - Swift - Adding image to tableview cell from asset library -

i trying add image tableview cell not having luck getting display. the image being loaded file system (i println() result) uiimage cannot seem cell. placing println() after closure shows me images loaded after cell has been returned. here code: func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell") as! uitableviewcell let note = notes[indexpath.row] let nsurl = nsurl(string: note.valueforkey("url") as! string)! var loaderror: nserror? var image: uiimage? assetslibrary!.assetforurl(nsurl, resultblock: { (asset) -> void in if let ast = asset { let iref = ast.defaultrepresentation().fullresolutionimage().takeunretainedvalue() image = uiimage(cgimage: iref) println("the loaded image: \(image)") } }, failureblock: {(error) -&g

css - jQuery UI dialog background -

Image
i'm trying fill background of dialog without success. as per picture getting transparency. the css have is: .ui-dialog { background-color: #e1e1e1; } .ui-dialog .ui-dialog-content { background-color: #e1e1e1; } but without success. i overriding alert() function can use alert() part of scripts: window.alert = function (message, callback) { $('<div />').text(message).dialog({ modal:true, title:'ddb', dialogclass: 'alert', show: { effect: "scale", duration: 200 }, hide: { effect: "explode", duration: 300 }, buttons: { 'ok':function(){ $(this).dialog('close'); callback(); } }, position: { my: 'center bottom', at: 'center bottom-30%', //of: $("#ma

Installing Azure powershell in an azure Virtual Machine -

i need write powershell workflow creates azure virtual machine , executes azure cmdlets in azure virtual machine. newly created vm has no azure powershell module installed in it. code new-azurequickvm -windows -servicename $servicename -name $vmname -imagename $vmimage -password $password -adminusername $username -instancesize "extrasmall" -waitforboot $winrmuri = get-azurewinrmuri -servicename $servicename -name $vmname $cred = new-object -typename system.management.automation.pscredential -argumentlist $username, $password invoke-command -connectionuri $winrmuri -credential $cred -scriptblock { add-azureaccount ...... ## these cmdlets need azure powershell module set-azuresubscription........ new-azurestorageaccount...... } i not supposed manually rdp of vm , open install azure powershell module dynamically create vm using powershell cmdlet , install azure module in vm using powershell itself. this can do

android - Always showing the emulator when running an application -

Image
i new android studio, , i'm building small android project. connected phone laptop see device real time debugs through logcat in android device monitor. however, when run project, never shows device list me choose phone, emulator. make sure have option selected shown in image attached. once you've done this, ensure phone has "usb debugging" enabled under developer options.

javascript - Highcharts Control Basic DrilDown Using Dom -

i have answer of previous question on how use dom drilldown , @ this post . found simple , easy understand version of highcharts.js @ here can see code more clear understand. now can please let me know how enable buttons drilldown , in this demo ? $(function () { var chart; function drawchart1() { chart = new highcharts.chart({ chart: { renderto: 'container', type: 'column' }, title: { text: 'basic drilldown' }, subtitle: { text: 'source: worldclimate.com' }, xaxis: { type: 'category' }, legend: { enabled: false }, credits: { enabled: false }, yaxis: { title: { text: 'total percent market share' }

amazon web services - Put file on S3 with AWS SDK 2 & Cognito for unauth users using iOS SDK 2 -

i want upload file 1 of s3 buckets. in app have: in app delegate let credentialprovider = awscognitocredentialsprovider(regiontype: .useast1, identitypoolid: "us-east-1:05da3124-9aab-abd9-081231a31") let configuration = awsserviceconfiguration(region: .useast1, credentialsprovider: credentialprovider) awsservicemanager.defaultservicemanager().defaultserviceconfiguration = configuration an upload function func uploadfile(fileurl: nsurl, type: mediatype) { var uploadrequest = awss3transfermanageruploadrequest() uploadrequest.body = fileurl uploadrequest.key = fileurl.lastpathcomponent uploadrequest.bucket = "xxx.xxx.dev" transfermanager.upload(uploadrequest).continuewithblock { (task) -> anyobject! in if let error = task.error { log.debug("upload failed error: \(error)") } else { log.debug("object \(uploadrequest.key) uploaded \(task.result)") x

ios - Share data between two UIWindows -

my objective have airplay option ios app shows same content ipad (like mirror) except modified 16x9 aspect ratio of tv. i have initial setup complete, point have second window , opportunity set root view controller. my current strategy create 2 separate view controllers, 1 ipad, 1 tv, create channel them communicate through. is efficient way solve problem? there better way, perhaps involves me using same view controller different uiview s?

android - Image search on FilePicker.io -

okay, using https://www.filepicker.com/ in order build app. web version , in ios version of file picker, has option make image search. android version of file picker, doesn’t. have walk around issue? any helps appreciated i have emailed , said "unfortunately there’s no workaround @ moment. need add our android client. planning so, right not i’m not able give specific date.". we have wait

javascript - Prototypical inheritance for cloned object - IE10 -

i’m trying clone object, using lodash’ _.clone . however, want keep prototypical inheritance intact cloned object. ie 10 not letting me access __proto__ or object.setprototypeof(toobj, object.getprototypeof(fromobj)); , don’t want access via call or apply on parent object there lot of setter , getter method on parent need called clone object. any suggestion? after try, found 1 of use: /** * shallow clone object , retains prototype chain * @param {object} fromobj object cloned * @returns {object} cloned object */ function cloneobj(fromobj) { var toobj, i; if (fromobj && typeof fromobj === 'object') { toobj = new fromobj.constructor(); (i in fromobj) { if (fromobj.hasownproperty(i)) { toobj[i] = fromobj[i]; } } } else { throw new error(fromobj + ' cannot cloned'); } return toobj; }

html - Css Transform - Trigger event each time the mouse is out and in of a div -

i have 2 questions. in project include code in post want: the transform should trigger when hover on blue square. the square should not return first position if mouse in red rectangle area or red square, when out of 2 divs. i hope understand. #square { position: absolute; width:100px; height:100px; background-color:blue; } #rectangle { width:200px; height:100px; background-color:red; } #square:hover { transform: translate(100px,0); -webkit-transform: translate(100px,0); /** chrome & safari **/ -o-transform: translate(100px,0); /** opera **/ -moz-transform: translate(100px,0); /** firefox **/ } .animation { position: absolute; transition: 2s ease-in-out; -webkit-transition: 2s ease-in-out; /** chrome & safari **/ -moz-transition: 2s ease-in-out; /** firefox **/ -o-transition: 2s ease-in-out; /** opera **/ } <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" &q

Cannot Resolve The Symbol 'R' - After importing eclipse project to Android Studio -

please gentle, moving projects eclipse android studio. first issue activities have problems resolving 'r'. have feeling produced because support library. using v.4 library in android studio following error: /users/vedtam/studioprojects/foto.studio/fotostudio/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-v11/values.xml error:(47, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. /users/vedtam/studioprojects/foto.studio/fotostudio/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-v14/values.xml error:(17, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. /users/vedtam/studioprojects/foto.studio/fotostudio/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-v21/values.xml error:(1) error retrieving parent item: no resource found matches given name 'android:textappearanc

ios - getting the current duration of recorded video using PBJVision -

how can length of video session in seconds? i understand may have sort of conversion of cmtime in didcapturevideosamplebuffer , can't seem find right property found answer: inside didcapturevideosamplebuffer put nslog(@"%f",[[pbjvision sharedinstance] capturedvideoseconds]);

php - preg_replace() replace only one pattern but match another pattern -

i trying replace string preg_replace() i want replace 1 pattern 'bbb' want match pattern , 2 more ('aaa' , 'ccc') example input : 'zzz aaa bbb ccc xxx' pattern match : 'aaa bbb ccc' output : 'aaa ccc' is possible make happen preg_replace() without invoking preg_match() you can use: echo preg_replace('/.*?(\baaa\b) +\bbbb\b +(\bccc\b).*/', '$1 $2', 'zzz aaa bbb ccc xxx'); //=> aaa ccc

html - how to get jquery selectable to select elements from other divs -

i working on requires me have li's in different parents. using jquery selectable function of selecting li's , ability drag mouse select multiple li's. this working great apart fact need someway of including of li's under both parents when selected rather acting 2 seperate containers. so in example, when drag on numbers select in first block not move onto second block starting @ number 13. i need include of numbers somehow without having move of li's same parent container. (sorry if i'm not explaining well, struggling explain mean. make more sense looking @ example: https://jsfiddle.net/susannalarsen/enq7bx22/1/ html: <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <body> <ol id="selectable"> <li class="ui-state-default">1</li> <li class="ui-state-default">2