Posts

Showing posts from February, 2010

sql - Two questions for formatting timestamp and number using postgressql -

i selecting date column in format "yyyy-mm-dd". i want cast timestamp such "yyyy-mm-dd hh:mm:ss:ms" i attempted: select cast(mycolumn timestamp) mytable; but resulted in format yyyy-mm-dd hh:mm:ss i tried select to_timestamp(mycolumn,yyyy-mm-dd hh:mm:ss:ms) mytable; but did not work either. cannot seem figure out correct way format this. note want first digit of milliseconds. //////////////second question i trying select numeric data such there not trailing zeros. for example, if have values in table such 1, 2.00, 3.34, 4.50. i want able select values 1, 2, 3.34, 4.5. i tried using ::float, strange output. tried rounding function, how use without knowing how many decimal points need before hand? thanks help! it seems functions to_timestamp() , to_char() unfortunately not perfect. if cannot find better, use these workarounds: with example_data(d) ( values ('2016-02-02') ) select d, d::timestamp || '.0...

Rails ActiveModel: inheritance namespace -

i have parent class class project::subscription < activerecord::base and 2 inherited classes class project::loan::subscription < project::subscription class project::investment::subscription < project::subscription when call project::loan::subscription.first , shows: project::loan::subscription load (0.4ms) select "project_subscriptions".* "project_subscriptions" "project_subscriptions"."type" in ('project::loan::subscription') order "project_subscriptions"."id" asc limit which correct. but when call project::investment::subscription.first , shows: project::subscription load (0.3ms) select "project_subscriptions".* "project_subscriptions" order "project_subscriptions"."id" asc limit 1 in last call, project::investment::subscription acting project::subscription what's wrong code?

raspberry pi - Python GPIO function input button toggle on falling edge -

i trying script work button monitored , if operated once turn on something. if operated again turn off. toggle button. have working following code not waits button edge trigger. other code in while loop not carried out. how can check in function if button has been operated , if not carry on rest of code. import time import rpi.gpio gpio gpio.setmode(gpio.bcm) # using broadcomm pin numbers gpio.setup(21, gpio.in, pull_up_down=gpio.pud_up) prevwater = 0 def buttoncontrol (): global prevwater # take reading gpio.wait_for_edge(21, gpio.falling) prevwater = not prevwater return prevwater while 1: waterbutton = buttoncontrol () if (waterbutton == true): print ("turn water on") if (waterbutton == false): print ("turn water off") # check returned function print (waterbutton) # need other stuff here gpio.cleanup() any appreciated i have tried callback shown below import time import rpi.gpio gpio ...

c - How to use fgets() in 2d-arrays (multiple dimension arrays)? -

#include <stdio.h> #include <stdlib.h> void *salloc(int x){ char **pointer; int i; pointer = malloc(sizeof(char)*x); if(pointer == null){ exit(-1); } for(i=0; i<x; i++){ pointer[i] = malloc(sizeof(char) * 20); if(pointer[i] == null){ exit(-1); } } return pointer; } void input(int value, char **array){ for(i = 0; < value; i++){ printf("%d ----\n", i); fgets(array[i], 20, stdin); printf("%d ----\n", i); } } int main(int argc, char *argv[]){ char **array; int value = 2; array = salloc(value); input(value, array); return 0; } the general idea, can miss syntax. want read in string spaces. if run value 2, print: 0 ---- 0 ---- 1 ---- "some string" and crashes after press enter. if value 1: crashes. if replace fgets() with: scanf("%s", array[i]); it works (except spaces). so how fgets() ...

recursion - Processing graph layer by layer -

Image
i have task. let's imagine have tree . have trunk , branches . every branch has own branches. etc. simplify task suppose every branch has 2 branches on it. see picture. we want address every branch, have layer layer . mean @ first should address branches 1 , 2, after 3,4,5,6, , forth. tried make algorythm it, anytime ends recursively going deeply: 1-3-7-8-4-9-10... there algorithms process tree unknown size without boilerplate code? you can breadth-first search , goes through graph layer layer because uses queue store newly discovered nodes.

python - ClientForm.AmbiguityError: more than one control matching name -

i new programming in python , trying login private website mechanize;i read similar questions like: how bypass mechanize "ambiguityerror" in python , python mechanize handle 2 parameters same name , non of these , there no feedback on solution second link. far i've read, using br.select_form(nr=0) should enough select first form still stuck; i've tried changing br.select_form(name of form) , br.form.find_control() attributeerror: 'nonetype' object has no attribute 'find_control'; options without success. below code , list of forms can found. support appreciated. thanks this code used: br = mechanize.browser() br.set_handle_robots(false) cj = cookielib.lwpcookiejar() br.set_cookiejar(cj) br.select_form(nr=0) br.form["username"]= 'myusername' br.form["password"]= 'mypassword' br.submit() these forms: <hiddencontrol(smauthreason=0) (readonly)> <hiddencontrol(clientfp=) (readonly)> <hiddencontr...

ios - Closures In Swift? -

i new ios coding , stuck in closures feature of swift. have referred many tutorials , found closures self written codes can used in many ways eg. arguments in function call,parameters in function definition,variables. giving below example below associated thoughts code & questions. please me if wrong in understanding. know wrong @ many points,so please rectify me. 1.1st part func test(text1:string,text2:string,flag: (s1:string,s2:string)->bool)//in line,i think,i using flag closure passed parameter in function. , if why doesn't follow standard closure syntax? { if flag(s1: text1, s2: text2) == true//i want check return type flag closure gets when compares both string during function call. why can't write if flag == true flag name of closure , refers return type of closure? { print("they equal") } else { // } } 2nd part this part troublesome part confuses me when callin...

logging - How do I hide hazelcast INFO logs? -

i use hazelcast in application, , console flooded hazelcast logs. how "hide" info logs don't find useful moment ? in application logging made slf4j log4j implementation. create logger warn level <logger name="com.hazelcast" level="warn" additivity="false"> <appender-ref ref="your_hz_file_appender" /> </logger>

php - Jquery event won't fire when element is displayed via mysql -

i have content fed in mysql that, when clicked should fire alert()... however, not working... here code code fed in php/get_answers.php <?php session_start(); ?> <?php require_once("../includes/include_all.php"); ?> <?php $answers = $question->get_answers_for_question($_get['id']); ?> <?php while($row = $answers->fetch_array()){ ?> <!-- answers here --> <div class = 'answer-row'> <div class = 'answer-side'> <div class = 'arrow-contain-answer' type = 'answer' id = 'arrow-up' answer-id = '<?php echo $row["id"]; ?>'></div> <div class = 'answer-votes-contain'> <?php echo $row['popularity']; ?> </div> <div class = 'arrow-contain-answer' id = 'arrow-down'answer-id = '<?php echo $row["id"]; ?>'></div> ...

angularjs - Move http functionaity into its own Service with Angular2 and TypeScript -

i'm trying teach myself angular2 , typescript after happily working angular 1.* last 4 years! anyway, have top level component creates property derived type have created in class. component when ngoninit() called make http call phoney rest service wrote end. when writing apps using angularjs put $http tasks service , inject them controllers... same component. here's component without service code activated... notice comments import {component, oninit} 'angular2/core'; import {routeconfig, router_directives} 'angular2/router'; import {home} './components/home/home'; import {userstatus} './types/types.ts'; // why userstatus type kept import {userdata} './services/user-data/userdata.ts'; // here wish write sevice perform http tasks... import {http, headers} 'angular2/http'; @component({ selector: 'app', // <app></app> providers: [...form_providers], directives: [...router_directives], pip...

css3 - media query only for iphone 6s plus -

is there media query target iphone 6s plus. code working fine on iphone 6plus there issue in iphone 6s plus. there way write specific media query iphone 6s plus. any appreciated. for landscape @media screen , (min-device-width : 414px) , (max-device-width : 736px) , (width : 736px) , (orientation : landscape) , (color : 8) , (device-aspect-ratio : 414/736) , (aspect-ratio : 736/414) , (device-pixel-ratio : 3) , (-webkit-min-device-pixel-ratio : 3) { } portrait @media screen , (min-device-width : 414px) , (max-device-width : 736px) , (width : 414px) , (height : 736px) , (orientation : portrait) , (device-aspect-ratio : 414/736) , (aspect-ratio : 414/736) , (device-pixel-ratio : 3) , (-webkit-min-device-pixel-ratio : 3) { }

canjs - DoneJS - Chat Example failing on add Component -

i following in donejs chat example on following url: http://donejs.com/guide.html however, when step: generate custom elements, following error: c:_source\donejs\donejs-chat>donejs add component home.component chat-home x no 'folder' or 'appname' specified. neither in .yo-rc.json nor in package.json file i have installed: nodejs 5.5.0 npm 3.3.12 donejs 0.6.0 bootstrap 3.3.6 any ideas on wrong and/or how resolve issue? hello yes know whats going on there bugs solved plz retry current versions.

jquery - Javascript date offset -

i working on filter's page report. on page, have radio inputs user can select quick report options auto populate filters. there 1 field has stumped me. able to offset date field year, , month, when try offset day, follow: seeing today 2/5/16, , try offset 7 days, calculate 2/29/16. counts correct number of days, fails go january , present 1/29/16. here javascript: function datedayoffset(theday) { var = new date(); var m=now.getmonth()+1; now.setdate(now.getdate() + theday ); var d=now.getdate(); var y=now.getfullyear(); var dayoffset = m + "/" + d + "/" + y; return((zeropaddate(dayoffset))); }; and here using jquery in filters page: $("#todate").val(datedayoffset(-7)); honestly, when comes dates, you're better off using moment.js handle stuff this. other issues such 28/29/30/31 day months affect if manually. you can use moment().subtract(7, 'days') accomplish want. but regarding code, ...

Oracle 9i ignores query alias sent from vb.net -

the following code released version of application using framework version 1 , oracle 9i. strsql = "select course_code code course_revisions doc_ref_code = '" & doc_ref_prevcode & "'" objdataset = stkdataassistant.gettable(strsql) course_code = objdataset.tables(0).rows(0)("course_code").tostring response.redirect("../courses/courserevisionnew.aspx?flag=add&course_code=" & course_code) it throwing error on following line: course_code = objdataset.tables(0).rows(0)("course_code").tostring it known there error in sql string alias code. issue being ignored in clients environment , working until month ago throwing error in stated line above. is error showing because of sort of framework change? or oracle? the client states there has been updates server database resides application still working expected. error started showing 3 months later , there has no changes done either database or...

Javascript - Error: require is not defined -

i installed unirest. in documentation provided following piece of code test unirest: var unirest = require('unirest'); unirest.post('http://mockbin.com/request') .header('accept', 'application/json') .send({ 'parameter': 23, 'foo': 'bar' }) .end(function (response) { console.log(response.body); }); when add bit of code, following error in console: error: require not defined the entire ui of site stops working well. i've used require in past before , it's never given me error. there i'm forgetting include? edit: forgot mention. yes, running in node.js environment.

html - Include style one CSS class to another -

is possible include styles of 1 css class another? mean sass @extends pretty similar thing, styles extended class, not required. see example: <style> .myclass1{ background:red; } .myclass2{ color:blue; @extend .myclass1; } </style> <div> <p class="myclass2">hello class 2, text blue , background red</p> </div> <div> <p class="myclass1">hello class 1, text should not blue , background red</p> </div> posted example inspired article of css-tricks web , here confusing not working should. myclass2 should give myclass1 according article. however, giving strange output. heading in right direction? or article wrong? update: question actual concept behind @extend of saas, , including other css class another, , difference? css without pre-processors (sass, less etc.): .myclass1{ background:red; } .myclass2{ color:blue; } <div> ...

Linking to another html page in google apps script does not seem to work -

i have tried answer provided linking html page in google apps script , not go page my1, blank screen. in fact, tried expand adding third page, my3 , having 2 buttons on each page... example: my1.html has buttons "my2" & "my3" my2.html has buttons "my1" & "my3" my3.html has buttons "my1" & "my2" from my1, can go either my2 or my3, either my2 or my3, pressing button, blank screen , when refreshed, end @ my1... thank you. code.gs /** * url google apps script running webapp. */ function getscripturl() { var url = scriptapp.getservice().geturl(); return url; } /** * "home page", or requested page. * expects 'page' parameter in querystring. * * @param {event} e event passed doget, querystring * @returns {string/html} html served */ function doget(e) { logger.log( utilities.jsonstringify(e) ); if (!e.parameter.page) { // when no specific page request...

oracle - sql HR schema making a line appear once -

i struggling time thought best use hr schema show example: the following sql: select department, sum(salary) "money", case when job_id = 'sa_man' 'y' end "indicator" (select first_name || ' ' || last_name "name", salary, job_id, department_id depatment employees) group depatment, case when job_id = 'sa_man' 'y' end order 1 ; from sql, have department 80 appearing twice has sa_man 'y' , null. my question how have appearing once looking @ whether sa_man there without appearing twice. with minor modification: don't group case . make max on in select clause. select department, sum(salary) "money", max(case when job_id = 'sa_man' 'y' end) "indicator" (select first_name || ' ' || last_name "name", salary, ...

angularjs - POST from angular.js doesn't work but directly from form works. Why? -

i'm working on basic authentication project in node.js using passport.js , it's localstrategy method. it's without password validation yet. accounts stored in mongodb instance. i stuck whole day when in course i'm going through instructor recommended binding form data angular , sending $http.post() there, so: $scope.signin = function (username, password) { $http.post('/login', {username: username, password: password}) .then(function (res) { if(res.data.success) { console.log('logged in'); } else { console.log('error logging in'); } }) }; and here's route it: app.post('/login', function (req, res, next) { var auth = passport.authenticate('local', function (err, user) { if(err) { return next(err); } if(!user) { res.send({success: false, user: user}); } req.login(user, function (err) { if(...

c - Linked Files instead of linked list -

i have linked list time start , time end tuples. in each list, tuples not overlapping. now, instead of put tuples in list, want them stored in file. ever list should file. on order sort files , go through every file, have know file next file. in oder words, how can make pointer next file, such in linked list. typedef struct list { struct list *next; } list; but don't want this, create linked list first, , put each list in file, because want evade memory usage. here static void create_files(list* first){ list* tmp = first; int partition_num = 1; while(tmp != null){ char filename[29]; sprintf(filename, "partitions%d/partition%d.txt",partition_folder, partition_num); file* partition; partition= fopen(filename, "w"); while(tmp->head != nil){ fprintf(partition,"[%d, %d) \n",ts,te); tmp->head= tmp->head->next; } list_num++; tmp=tmp->next; } more this file* firstfile; ...

Eclipse windows will not dock on Ubuntu -

i'm running eclipse mars on ubuntu 12.04 lts , seems impossible dock windows in ide. normally, when drag tab border of editor pane, dock within pane. makes easy work on several files @ once. start drag tab, creates detached window. window has no menu or toolbar , can find no way re-attach main editor. can suggest way make eclipse windows behave normally? seems kind of transient display problem. closing eclipse , rebooting fixed it. guess should have tried first :s

ios - Xcode, Linking framework doesn't work when use custom build configuration -

Image
i have workspace contain 2 projects: main project called "mainproject" , second cocoatouch framework called "privateframework". privateframework linked mainproject , works well. i have podfile file in project looks below. can see use xcglogger pod in privateframework , mainproject. source 'https://github.com/cocoapods/specs.git' platform :ios, '8.0' use_frameworks! workspace 'mainproject' def shared_pods pod 'xcglogger' end target 'privateframework' xcodeproj 'privateframework/privateframework.xcodeproj' shared_pods end target 'mainproject' xcodeproj 'mainproject.xcodeproj', 'development' => :debug, 'production' => :release shared_pods pod 'alamofire' pod 'unbox' pod 'locksmith' end after installing pods ok privateframework , mainproject compiling , running well. problem when tried add in mainproject new b...

Does Datapower appliance XI52 support ActiveMQ? -

the answer can find seems datapower appliance support websphere mq, , doesn't understand activemq brokers. and, documentation front side handler mentioned queue managers, activemq not have. is there way in datapower fetch/poll messages activemq? wdp not support possible brokers few of them (tibco, ibm etc). if configure amq provide rest interface can consume messages using plain http instead of messaging. rest/http access activemq won't traditional openwire/amqp connections. lack support transactions , other things, can @ least read messages. i not suggest using activemq messaging backbone datapower - go ibm websphere mq instead nicely integrated. if need pull message or 2 activemq broker - go above setup.

.net - Mapping a drive and accessing it from another process programmatically (as another user) -

i need launch 2 processes, first map drive (homedrive in case) , second launch application access drive (notepad, example). machine kiosk machine logged in kiosk user has minimal permissions, therefore these processes need run different user (when user accesses machine winforms form takes credentials). way first approached start 2 processes process.start, first running "net" , passing "use h: \homedrive /persistent:no" in order map drive, , second running "notepad" both of these have credentials supplied , useshellexecute set false. problem each process seems separated , drive unable accessed notepad process. my solution launch both processes 1 process.start call, solution launches "cmd" , passes "/c net use h: \homedrive /persistent:no & notepad". works hoped , homedrive accessible notepad, perfect. except fact command prompt stays open in background, have attempted altering window style hidden or minimized after googling see...

java - How to force TeeChart gallery repaint?(swing) -

Image
when switch to/from 3d mode in graphics gallery, old version still visible, it's removed if resize gallery(it's child of jdialog class) here demo: tried lots of methods - these repaint, revalidate, refresh... etc, don't work :( so how can force redraw when it's resized? (i rewriting code of teechart in local version ) another customer reported same time ago here . can see, i've fixed next maintenance release included that.

ruby - what's a clean way of finding which common elements exist in a set of n arrays? -

i'm going through table in database has lot of optional columns. i'm wanting find columns have data in every record in database. a simplified example of i'm trying follows: [1,2,3,4,5] & [1,2,3,4] & [1,2,3] & [1,2] #=> [1,2] however, i'm trying run type of operation thousands of records. what's clean way accomplish this? have feeling ruby might have bespoke methods sort of thing. here's before decided write question: sets_of_columns_with_data = tablename.all.map(&:attributes).map |attrs| attrs.select {|k,v| v} end.map(&:keys) so @ point, if following above code, columns_with_data equivalent of this: sets_of_columns_with_data = [ [1,2,3,4,5], [1,2,3,4], [1,2,3] [1,2] ] a messy way guess this: always_used = sets_of_columns_with_data.first sets_of_columns_with_data.each |columns_with_data| always_used = always_used & columns_with_data end what's clean, ruby-way this? thanks note: i'm ...

sql - Column names based on a mapping table on mysql -

i new mysql. have 2 tables. table 1:product_details manufacturerid| sku | image1 | image2 | image3 -------------------------------------------------------------------------------------------------- 123 | 1 | image1-sku1-filename.jpg | image2-sku1-filename.jpg | image3-sku1-filename.jpg 123 | 2 | image1-sku2-filename.jpg | image2-sku2-filename.jpg | image3-sku2-filename.jpg 123 | 3 | image1-sku3-filename.jpg | image2-sku3-filename.jpg | image3-sku3-filename.jpg 456 | 10 | image1-sku10-filename.jpg| image2-sku10-filename.jpg| image3-sku10-filename.jpg 456 | 20 | image1-sku20-filename.jpg| image2-sku20-filename.jpg| image3-sku20-filename.jpg table 2:image_mapping manufacturerid | image_column | image_type ------------------------------------------- 123 | image3 | master 123 | image1 | 123 | image2 | 456 | image3 ...

Interacting with C++ classes from Swift -

i have significant library of classes written in c++. i'm trying make use of them through type of bridge within swift rather rewrite them swift code. primary motivation c++ code represents core library used on multiple platforms. effectively, i'm creating swift based ui allow core functionality work under os x. there other questions asking, "how call c++ function swift." not question. bridge c++ function, following works fine: define bridging header through "c" #ifndef imagereader_hpp #define imagereader_hpp #ifdef __cplusplus extern "c" { #endif const char *hexdump(char *filename); const char *imagetype(char *filename); #ifdef __cplusplus } #endif #endif /* imagereader_hpp */ swift code can call functions directly let type = string.fromcstring(imagetype(filename)) let dump = string.fromcstring(hexdump(filename)) my question more specific. how can instantiate , manipulate c++ class within swift? can't seem f...

Overlaying text on video with required angle using FFMPEG -

Image
i trying overlay text on video using ffmpeg. able overlay text bellow command. ffmpeg -i input1.mp4 -filter_complex "[0:v]transpose=2[anticlockwiserotated];[anticlockwiserotated]drawtext=fontfile=../../public/fonts/roboto-regular-webfont.ttf: text='test text':x=100: y=50: fontsize=36: fontcolor=white:[textapplied];[textapplied]transpose=1" output_video.mp4 it allowing me overlay horizontally or vertically only. but want append angle 45 degrees. for if modify command as ffmpeg -i input1.mp4 -filter_complex "[0:v]rotate=45*pi/180[anticlockwiserotated];[anticlockwiserotated]drawtext=fontfile=../../public/fonts/roboto-regular-webfont.ttf: text='test text':x=100: y=50: fontsize=36: fontcolor=white:[textapplied];[textapplied]rotate=315*pi/180" output_video.mp4 by getting overlay video as: because in first rotating video 45 degrees, appending text , bringing original position. loosing borders. please suggest me best way overlay text re...

Any idea why i'm always getting "Sat 17th" date (Calendar) - java? -

public static void main(string[] args) { jsonweathertime time = new jsonweathertime(); string date = time.formatdate(long.valueof(1454691600)); //todays date system.out.println(date); } private string formatdate(long milliseconds){ stringbuffer datebuffer = new stringbuffer(); calendar calendar = calendar.getinstance(); calendar.settimeinmillis(milliseconds); switch(calendar.get(calendar.day_of_week)){ case calendar.monday: datebuffer.append("mon, "); break; case calendar.tuesday:datebuffer.append("tue, "); break; case calendar.wednesday:datebuffer.append("wed," ); break; case calendar.thursday:datebuffer.append("thur, "); break; case calendar.friday:datebuffer.append("fri, "); break; case calendar.saturday:datebuffer.append("sat, "); break; case calendar.sunday:datebuffer.append("sun, "); break; default:datebuffer.ap...

angularjs - Can ngResource pass nested object into GET query? -

i using ngresource communicate web api. want send search request webapi controller object not flat: var searchrequest = { query: "hotel", page: 1, price: { min: 1000, max: 2500 } } and controller takes searchrequest parameter same structure sent object request should like http://localhost/api/search?query=hotel&page=1&price.min=1000&price.max=2500 however, ngresource $resource.query(searchrequest) sending this: http://localhost/api/search?query=hotel&page=1price=%7b%22min%22:1000,%22max%22:2500%7d if me change use odata attributed endpoint returns iqueryable. use breeze.js on frontend generate queries. have @ these: https://ovaismehboob.wordpress.com/2014/01/18/adding-queryable-support-to-asp-net-web-api-controller-action-methods/ http://breeze.github.io/doc-js/server-odata.html i wrong don't think work nested queries. solution might flatten query , use linq projection or automapper projection q...

php - Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.authenticationservice.orm_default -

zend\servicemanager\servicemanager::get unable fetch or create instance doctrine.authenticationservice.orm_default installed zend 2 framework authdoctrine module. can see getting above error when try visit http://localhost/test/public/auth-doctrine/index/login i getting error in module.php file. if using doctrineormmodule : return $servicemanager->get('doctrine.authenticationservice.odm_default'); can me how resolve this?

web services - Ending a nintex workflow through JavaScript -

hopefully has answer out there , unable find it. question is: is there way end nintex workflow (on list item) through use of javascript? points i've come across while researching today: nintex uses old sharepoint 2010 workflow engine there no supported web service ending workflow, see; http://sharepointportal.local/site/subsite/_vti_bin/workflow.asmx there little/no documentation on javascript usage of getworkflowinteropservice method. note using sharepoint server 2013 (part of issue believe). any appreciated there web service action terminate workflow: terminateworkflow you need build soap request in javascript. documentation has example: <soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nin="http://nintex.com"> <soap:header/> <soap:body> <nin:terminateworkflow> <nin:listid>00000000-0000-0000-0000-000000000000</nin:listid> <nin:item...

Android studio app keeps crashing: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' -

so practicing using list view , having @ several questions online, , trying make there 2 activities, 1 list view , user able add list, tried making: activity 1 package com.example.nooli.listview; import android.app.listactivity; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.arrayadapter; import android.widget.button; import android.widget.edittext; import java.util.arraylist; public class mainactivity extends listactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final arraylist<string> things2 = new arraylist<string>(); final arrayadapter<string> adapter = new arrayadapter<string>(getlistview().getcontext(),android.r.layout.simple_list_item_1,things2); getlistview().setadapter(adapter); bu...

How to run app on moto 360 from android studio -

i'm using sample watchface app , have followed steps (developer.android + several variations site) run on watch no joy. wondering if can advise please. phone (moto 4g) connected pc usb. usb debugging on in settings , debugging on bluetooth on in android wear app. paired watch (moto 360 2gen) has adb debugging enabled , debugging on bluetooth enabled. android studio lists phone if run phone module part of app; offers no compatible devices if run wearable module. adb devices command lists phone. on phone in android wear app under debugging on bluetooth says host: disconnected target: connected. when on phone in settings, apps watchface app has appeared there's nothing on watch (tried change watch face, nothing new; no new app). i tried adb forward tcp:4444 localabstract:/adb-hub adb connect localhost 4444 but second command gives 'unable connect localhost:4444 ... no connection made because target machine actively refused (10061).' tried adb connect ...

node.js - POSTing RAW body with restify client -

i'm trying post raw body restify. have receive side correct, when using postman can send raw zip file, , file correctly created on server's file system. however, i'm struggling write test in mocha. here code have, appreciated. i've tried approach. const should = require('should'); const restify = require('restify'); const fs = require('fs'); const port = 8080; const url = 'http://localhost:' + port; const client = restify.createjsonclient({ url: url, version: '~1.0' }); const testpath = 'test/assets/test.zip'; fs.existssync(testpath).should.equal(true); const readstream = fs.createreadstream(testpath); client.post('/v1/deploy', readstream, function(err, req, res, data) { if (err) { throw new error(err); } should(res).not.null(); should(res.statuscode).not.null(); should(res.statuscode).not.undefined(); res.statuscode.should.equa...

javascript - Accessing nested route parameter from parent route/template -

i have nested route behaves less-nested version of itself: /code/class/myfile.java /code/coverage/:coverageid/class/myfile.java somewhat self-explanatory, coverage route decorates page additional highlighting/details not present in "normal" version. however, code template defines sidebar includes navigation tree access other code files. when viewing /coverage/ page, sidebar display links differently, ensuring nested route maintained when clicking around. my problem: i can't seem find way access :coverageid in code route or template modify way links displayed. code route: export default ember.route.extend({ model(params) { console.log('coverage id: ' + params.coverageid); ... prints undefined . seems make sense since it's child parameter, "out of scope"? my incorrect solution: i tried in class route: export default ember.route.extend({ model(params) { var parentmodel = this.modelfor('code'); ...

ios - Swift ViewController without prepareForSegue -

on project have master controller (which accessed segue has 3 nibs. these nibs not on main storyboard show on master view , can swipe across view them. how 1 of nibs viewcontroller sent them? for clarity viewcontroller1 segue viewcontroller2 display slide nibs (viewcontroller3). i want viewcontroller3 viewcontroller1 not on storyboard cant click , drag , make segue. i hope makes sense. edit: ibaction let storyboard = uistoryboard(name: "main", bundle: nil) let secondvc = storyboard.instantiateviewcontrollerwithidentifier("viewcontroller1storyboardid") as! viewcontroller1 presentviewcontroller(secondvc, animated: true, completion: nil) viewcontroller2 has this: let vc3 = viewcontroller3(nibname: "viewcontroller3", bundle: nil) var frame3 = self.vc3.view.frame frame3.origin.x = self.view.frame.size.width * 2 self.vc3.view.frame = frame3 self.addchildviewcontroller(self.vc3) self.scrollview.addsubview(self.vc3.view) self.vc3.d...

jquery - Display results on keyup event and values inside form how to? -

how display output on keyup event rather on submit , values inside input fields? i tried readonly <input id="result" name="totalamount" value="" readonly/> but not working. can helo? here thew complete codes <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script> $('#myform').submit(function (event) { event.preventdefault(); var actualprice = number($("#actualprice").val().trim()); var discount = number($("#discount").val().trim()); var shipping = number($("#shipping").val().trim()); var discountrate = (100 - discount) / 100; var result = (actualprice * discountrate) + shipping; $("#result").html("result :" + result.tofixed(2)); }); </script> <form id="myform"> <input id="actualprice" type="number"...

sql - Low Impact End-to-End Database Connection & Query Test -

the database oracle. goal perform status check in code is: robust end-to-end (healthy connection not mean healthy objects, i.e. views offline tables) creates minimal overhead calling application to suffice these various requirements, i've come following query: select null view_name null not null so let's break down: select null attempt "leverage" sql result caching explicitly specifying value. from view_name fail if view_name not present in database (i.e. end-to-end). where null not null attempt avert table scans, return 0 records, etc. any thoughts, improvements, suggestions, etc. appreciated. know if there conceivable issues query or approach. you better off checking valid objects under user connecting as. select count(*) user_objects status != 'valid'; or if looking valid objects in db, then: select count(*) obj$ status != 'valid'; just make sure query not run - 50 times minute. an better approach opt...

visual studio - c++ and the type size_type -

the following code fragment fails compile: #include <vector> #include <string.h> #include <cstddef.h> #include <stddef.h> using namespace std; vector<int> list1{1,3,5,7,11}; size_type s1 = list1.size(); i using microsoft visual stdio not expect compiler dependent. believe problem failing include correct header. header should including? bob size_type dependent name of container using. need std::vector<int>::size_type you use std::size_t size_type boils down std::vector<int>::size_type guaranteed correct. if using c++11 or higher can forgot detail , use auto s1 = list1.size(); the compiler deduce correct type , if ever change container type line need changed.

if statement - Segmentation Fault (Core Dumped) - C Arguments -

every time run program below in following way: ./a.out -a -b runs properly. if choose run ./a.out -a , result in segmentation fault (core dumped). there way can fix this? int main(int argc, char *argv[]) { if (argc > 1) { if (strcmp(argv[1],"-a") == 0) {... if (strcmp(argv[2],"-b") == 0) {...} } } } when run ./a.out -a , 1 argument, should not check strcmp(argv[2],"-b") , because there no third argument, , reading argv[2] result in undefined behavior. you can fix adding check before doing strcmp(argv[2],"-b") . int main(int argc, char *argv[]) { if (argc > 1) { if (strcmp(argv[1],"-a") == 0) {... if (argc > 2 && strcmp(argv[2],"-b") == 0) {...} } } } this looks pretty ugly work.

python - questions on pandas group by functionality? -

i have following data set: productid att 12 block10 12 block20 12 clean 12 screw 12 nail 13 hard 13 cover 14 round 14 narrow 14 black 15 block4 i wanted group dataframe according product id , following result: productid att 12 block10 block20 clean screw nail 13 hard cover 14 round narrow black 15 block4 i can use pandas.groupby('productid') group data not sure how write data specific productid single row separated space. groupby on 'productid' , apply join: in [6]: df.groupby('productid')['att'].apply(' '.join) out[6]: productid 12 block10 block20 clean screw nail 13 hard cover 14 round narrow black 15 block4 name: att, dtype: object

javascript - How is this setTimeout working? what is 49221 and how is console.log.bind working? -

this question has answer here: browser console output has mysterious number in loop settimeout? 2 answers how settimeout working? 49221 , how console.log.bind working? for(var = 0; < 10; i++) { settimeout(console.log.bind(console, i), 0); } output 49221 0 1 2 3 4 5 6 7 8 9 the fact you're seeing number before 0 tells me you're pasting browser console. you're seeing number because it's handle of last timer created in loop. for loop (this may surprise many reading this, did me when first learned of it) result in return value of last statement executed in last execution of body block. in case, that's return value of settimeout , number: handle you'd use if wanted cancel timer. (the spec's bit hard follow, it's in §13.7.4.7 .) the reason goes on show 0 through 9 schedules 10 timed callbacks conso...

Writing an IF statement in Excel -

i have inserted check box (form control) title "wall". next have cell stating "false" if unticked , "true" if ticked. next 2 cells dimensions of wall "length", "height". - lastly cell containing "area of wall". i want write if statement in "area of wall" cell when check box ticked, area of wall printed, , if not ticked prints n/a if have written: =if((c2="true"), (d2*e2), ("n/a")) all happens cell reads n/a, no matter whether box ticked or not. please on how correct this? example true should not in quotes, it's treating string when it's boolean. removing quotes should work or writing true() the final formula should this: =if((c2=true), (d2*e2), ("n/a"))

winforms - C# dataGridView shows no data -

there many posts this, no 1 helped me. maybe have logical problem or this. i'am c# newbie. so following problem. have datagridview in form1. when click button1 form6 appears, give in table name , filldatagrid-mehtod runs in form1. but. shows no data datagradview keeps empty nothing in it. now curios thing, if place code filldatagrid-method in button1 method every thing works fine. database (sqlite) connection works fine (not shown in code example). form1: private void button1_click(object sender, eventargs e) { form6 f6 = new form6(); f6.show(); } private void button3_click(object sender, eventargs e) { form3 createtable = new form3(); createtable.show(); } public void filldatagrid(string eingabe) { string tabelle = eingabe; string selectcommand = "select id, von, bis, dauer, kommentar " + tabelle + ";"; sqlitedataadapter dataadapter = new sqlitedataadapter(selectcommand, sqlite_conn); data...

javascript - How to display .toggle or .Animate to all connected browser sessions using Meteor -

but how show interaction of clicking on element toggles or animates? meteor checkers example: http://checkers.meteor.com/ in example below, every browser that's connected meteor server able see when 1 of other browsers makes shape change. https://jsfiddle.net/qh2jyl3b/ html: <div class="square"></div> <script src="//code.jquery.com/jquery-1.10.2.js"></script> css: .square { width: 100px; height: 100px; background: white; border: 10px solid black; cursor: pointer; } javascript: $(".square").click(function() { $( ).toggleclass("circle"); }); you can store click state in meteor.collection. changes in collections propagate reactively connected clients. create separate document each square , save state here. can create helper displays correct class name depending on db items. for example can this way: for each chess-table can create separate document on server side: chesst...