Posts

Showing posts from March, 2013

ios9 - Xcode 7.0.1 iOS 9.0 simulator won't go past launch screen -

this question has answer here: after updating xcode ios 9, app stucks on splashscreen , initial viewcontroller not loaded 1 answer thanks help! reason simulator or iphone 6 won't go past launch screen. have single view application. in main storyboard have 1 view controller labels , text fields. launch screen story board gave view controller colored ground. no code yet. when run see colored background. am missing simple? the problem caused text area string less 10 characters @bas van stein providing answer in question @ after updating xcode ios 9, app stucks on splashscreen , initial viewcontroller not loaded

encoding - Pack two floats within range into one float -

in hlsl, how go packing 2 floats within range of 0-1 1 float optimal precision. incredibly useful compress gbuffer further. //packing float = 0.45; float b = 0.55; uint ascaled = * 0xffff; uint bscaled = b * 0xffff; uint abpacked = (ascaled << 16) | (bscaled & 0xffff); float finalfloat = asfloat(abpacked); //unpacking float inputfloat = finalfloat; uint uintinput = asuint(inputfloat); float aunpacked = (uintinput >> 16) / 65535.0f; float bunpacked = (uintinput & 0xffff) / 65535.0f;

javascript - $this - can't find the correct jQuery selector -

i'm having real trouble finding selectors use show divs on page html structure overly complicated (wordpress comments system). instead of pasting here i've created simplified version of layout , created couple of fiddles. this full page div's displayed : https://jsfiddle.net/e25zvfyg/ this how want work. reply box , associated existing comments hidden until "reply" clicked , hidden divs slidedown. i've included "non-working" js in fiddle. can show me i'm going wrong? https://jsfiddle.net/yf3oagx7/ (function ($) { $('.single-f3ed-reply').hide(); $('.f3ed-reply').hide(); $('a.this-reply').click(function () { $('.single-f3ed-reply').hide(); $(this).parents().next('.single-f3ed-reply').slidedown('fast'); $(this).parents().next('.f3ed-reply').slidedown('fast'); return false; }); })(jquery); any appreciated. .parents() returns all elements

Why not delete the node, itself? -

i real rookie here , taking data structures class in c++! above question possed when talking ablout working lists , nodes. 1 of design questions deletion delete node, itself, or node after location @ popint? last question seemed little stupid in mind , told "the answer obvious has ever tried write code, argument not reading computer programs without implementing concepts on own." but never given obvious answer...? can please elaberate me reason not deleting node, itself? if delete node pointing to, be?

java - Maven test error: javac: source release 1.8 requires target release 1.8 -

if run mvn -e test , error: [info] error stacktraces turned on. [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building skat09 0.0.1-snapshot [info] ------------------------------------------------------------------------ [warning] artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated commons-io:commons-io:jar:1.3.2 [info] [info] --- maven-resources-plugin:2.6:resources (default-resources) @ skat09 --- [info] using 'utf-8' encoding copy filtered resources. [info] copying 6 resources [info] copying 191 resources [info] [info] --- maven-compiler-plugin:3.3:compile (default-compile) @ skat09 --- [info] changes detected - recompiling module! [info] compiling 64 source files /home/buzz-dee/workspace/skat09/target/classes [info] ------------------------------------------------------------- [error] compilation error :

VB.NET MySQL - datatable returns blank row while db has no data -

i trying search data in mysql table... dim cmd new mysqlcommand dim qry string = "select sum(amt) fee_payment roll_no='" + st_roll + "' , course='" + c_id + "'" cmd.connection = conn cmd.commandtext = qry dim dt new datatable dim dadapter new mysqldataadapter dadapter.selectcommand = cmd dadapter.fill(dt) if dt.rows.count > 0 dim dr mysqldatareader = cmd.executereader while dr.read dim t_paid = dr("sum(amt)") tbdue.text = tot_fees - t_paid end while dr.close() end if surprisingly above dt.rows.count returns 1 while table fee_payment has no data. what should ?? there nothing surprising @ result. an aggregation query no group by always returns 1 row. if rows filtered out, aggregation functions return null , although count() , count(distinct) return 0 . this standard behavior , how databases work. quite convenience under circumstances. edit: if wanted behavior

ios - Sending a subview of a collection view cell to the back stops it from changing backgroundColor -

i have custom uicollectionviewcell , i'm adding subview contentview delete button it's hovering on corner of cell little bit outside bounds (just delete button of app in springboard). works fine when try change subview insetview.backgroundcolor after cell highlighted or selected doesn't change. in uicollectionviewcell - (void) layoutsubviews { [super layoutsubviews]; self.insetview = [[uiview alloc] initwithframe:cgrectinset(self.bounds, self.bounds.size.width/64, self.bounds.size.height/16)]; self.insetview.layer.cornerradius = 6; self.insetview.layer.maskstobounds = yes; self.insetview.backgroundcolor = [uicolor colorwithred:65/255.0 green:166/255.0 blue:42/255.0 alpha:1]; [self.contentview addsubview:self.insetview]; [self.contentview sendsubviewtoback:self.insetview]; self.backgroundcolor = [uicolor blackcolor]; } in collectionviewcontroller - (void)collectionview:(uicollectionview *)collectionview didselectitematindexpath

java - org.mule.api.config.ConfigurationException: Error creating bean with name '_muleSimpleRegistryBootstrap' -

i joined new project , noticed several test failures due error below. new mule. please let me know if can help: org.mule.api.config.configurationexception: error creating bean name '_mulesimpleregistrybootstrap' defined in url [jar:file:/.../.m2/repository/org/mule/modules/mule-module-spring-config/3.5.3/mule-module-spring-config-3.5.3.jar!/registry-bootstrap-mule-config.xml]: invocation of init method failed; nested exception org.mule.api.lifecycle.initialisationexception: failed lookup beans of type interface org.mule.api.transformer.converter spring registry (org.mule.api.lifecycle.initialisationexception)

javascript - Unable to add new color class to first sub - menu item when outer menu item is opened in accordion -

here fiddle: http://jsfiddle.net/d3su54rt/2/ i have used accordion implement menu sub-menus. looking everytime outer menu item clicked, want first item (first child) highlight red if isnt clicked. , when click on other menu item, should highlight 1 clicked. , when open outer menu item again, default first 1 should highlight again. trying add class innermenuitemonclick based on specific accordion open tab. here html: <div id="accordion"> <h3 class="outermenuitem">outeritem1</h3> <ul id="statusid"> <li><a class="innermenuitem" href="#!">inner item 1</a></li> <li><a class="innermenuitem" href="#!">inner item 2</a></li> <li><a class="innermenuitem" href="#!">inner item 3</a></li> </ul> <h3 class="outermenuitem">outeritem2</h3>

Bash while loop error -

this question has answer here: why should there space after '[' , before ']' in bash? 4 answers this simple school project. console keeps stating [5:command not found #!/bin/bash num=28 echo "guess number number between 1 , 100" read guess while [$guess -ne $num] if [$guess -lt $num] echo "number higher" elif [$guess -gt $num] echo "number lower" else echo "correct! number $number" fi done while [$guess -ne $num] is interpreted first expanding parameters: while [5 -ne 28] which causes command [5 executed, passing arguments -ne , 28] you wanted execute command [ , needed write: while [ $guess -ne $num ] (note spaces around both [ , ] . without space, characters become part of word.) ditto statements following if , elif .

android - Issue in changing the color of a word in strings.xml -

Image
i created layout alertdialog in there's textview shows text. text have item in strings.xml change color of single word, in image below. tried this: <string name="dialog_text">text... <font fgcolor="#000000">thewordiwantinblack</font> text text text.</string> the issue when run on device (galaxy note3) shows text in dialog except word in <font> tag on emulator (nexus 5 android 6.0) ok, how want it. me? in fgcolor replace #000000 black , like <string name="dialog_text">text... <font fgcolor="black">thewordiwantinblack</font> text text text.</string> this works on relatively short list of built-in colors: aqua, black, blue, fuchsia, green, grey, lime, maroon, navy, olive, purple, red, silver, teal, white, , yellow

Android Studio version of an Excel vlookup? -

ok i'm massive noob , apart following lots of tutorials set myself problem , try fix app. therefore i'm trying make little app that'll me when i'm @ work. basically needs breakdown 4 character string it's individual characters , display them phonetically. if (the user) type in 5f9a it'll display 5 foxtrot 9 alpha. @ work have excel spreadsheet , i'm trying reverse engineer it. spreadsheet has multiple stages, reads characters, converts them ascii , performs vlookup on range of cells each ascii code next it's phonetic pronunciation. looks number 53 (5 in ascii) , looks @ cell next says five. i've managed translate user input ascii don't know how store , access next set of data. i've been looking sqlite waaaaaay beyond me @ moment , seems far complicated simple? anyway, know it's cheating asking answer, maybe push in right direction? the dummy way be: get every letter (char) of word have switch case gives phonet

ajax - Run a JS function on Server every 5 minutes -

i apologize if way i'm asking why haven't found answer yet, i've got simple js script makes ajax request , gets data api , stores it. i'd put script on server , have run every 5 minutes, not client-side, server-side. i've found resource called later.js not sure how set on server automatically initialize , run. any appreciated!!! it's hard know without exact code. you should able jquery, like: function foo () { //your code here } foo(); //run function once on startup setinterval(foo, 5 * 60 * 1000) //and again every 5 minutes later.js is cool library calculating time in milliseconds, that's does. if have installed , required via npm, use like: var 5min = later.parse.text('every 5 min'); setinterval(foo, 5min); as can see, might use standard js/jquery solve issue.

Python Performance: remove item from list -

this question has answer here: fast way remove few items list/queue 5 answers i have list lenght of: 370000 . in list have items like: "a", "y", "y", "q", "q", "p", "p", , meaning list of words time time single characters. i want remove characters list, pretty new in python first thing came mind like: for word in words: if word== 'm' or word== 'y' or word== 'y' or word== 'p' or word== 'q' or word== 'q' or word== 'a' or word== 'uh': words.remove(word) in list 370.000 items method taking loooot of time. seriously, lot. does have awesome idea on how better performance? thanks in advance. tried bogo-benchmarks in ipython. import random # don't know how generate words, use integers substitute. words = [

functional programming - What's the equivalent of Clojure's iterate function in Racket -

i'm playing racket today, , trying produce indefinite sequence of numbers based on multiple applications of same function. in clojure i'd use iterate function this, i'm not sure equivalent in racket. in situations can replace use of iterate for/fold . > (define (mult2 x) (* x 2)) > (for/fold ([x 1]) ; initial value of x 1 ([i 8]) ; count i=0,...,7 (mult2 x)) ; put x = (mult2 x) 256 the advantage of for/fold can iterate more variables @ time: (define (mult2 x) (* x 2)) (define (div2 x) (/ x 2)) (for/fold ([x 1] ; bind x 1 [y 1]) ; bind y 1 ([i 8]) ; i=0,...,7 (values (mult2 x) ; put x = (mult2 x) (div2 y))) ; put y = (div2 y) this return 2 values: 256 , 1/256 . collecting elements easy. here fibonacci example: (for/fold ([fs '(1)] ; list of fibonacci numbers generated far [f1 1] ; fibonacci number [f2 1]) ; f

php - Laravel - Where to store statuses (flags)? Model, Class or config folder? -

i need extensively use statuses in mt project. need them users ( active , suspended , etc), entity ( active , pending_activation , inactive ) , subscriptions( active , on_grace_period , not_subscribed , never_subscribed ). so far thought best way store them in db have feeling it's easier have them in other 3 options. i thought can store them in eloquent model constants. example subscription model this: // subscriptionmodel const subscribed_active = 1; const subscribed_on_grace_period = 2; const not_subscribed = 3; const never_subscribed = 4; and retrieving them, example in blade view: // subscription/index.blade.php @if($user->subscription->status == /app/subscriptionmodel::subscribed_active) <div>you subscribed. thank you</div> @elseif($user->subscription->status == /app/subscriptionmodel::never_subscribed) <div>you need create subscription before being granted full access!</div> @elseif(...) // , on how doing same

build - Visual Studio Community 2015 Edition not building .exe -

i new c# , in first hello world program... runs fine in vs2015 community edition (win 7). now, want generate .exe file project, when click build be in release or in debug message build succeeded cannot find .exe file project. searching in same directory project resides: can see "source" subdirectory , "artifacts" subdirectory; cannot see "release" or nor "debug" or nor "bin" subdirectories. thank you! not sure if trying setup console application under file -> new project -> visual c# -> web template -> console (package). if are, need use visual c# -> windows -> console application. that create .exe file you.

c++ - The difference between 0 and '0' in array -

i have question array initialization what difference between char a[6]={0}; and char a[6]={'0','0','0','0','0','0'}; how compiler interpret above 2 expression? same or not?? '0' ascii character number 0. value 48. the constant 0 zero byte or null byte , written '\0' . these 4 equivalent: char a[6] = {0}; char a[6] = {0, 0, 0, 0, 0, 0}; char a[6] = {'\0', '\0', '\0', '\0', '\0', '\0'}; char a[6] = "\0\0\0\0\0"; // sixth null byte added automatically compiler

java - What is the Best Approach to connect to database in Spring4 and Tomcat application? -

we working on web application using spring4 , tomcat7.i doing database set part first time not sure put database confiuration part (datasource creation) in spring context.xml or in tomcat context.xml advantages of both these approaches , better approach? also,our application communicating 1 database. please me out. presuming of course new application, recommend spring boot, spring data jpa. here link tutorial spring data rest . think if insist on manually wiring entity manager , datasource, you'd best off doing in javaconfig. spring boot can configure database you have provide connection string in application.properties . so. spring.datasource.url=jdbc:mysql://localhost/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.driver important do not commit production database credentials source code. it's fine localhost developer credentials. spring boot has facilities allow avoid this.

c - How do I handle a calender without a massive 12x12 switch statement? -

i'll heading tutoring tomorrow, i'd see if can explanation here. tried ask friend class, explanation didn't make sense. i'm supposed take user's input in form of structure holds day, month, , year. here's have right now: enum month { jan = 1, feb, mar, apr, may, june, jul, aug, sept, oct, nov, dec }; struct date_t { unsigned short month; unsigned short day; unsigned short year; }; int main(void) { date_t date; /*allocates space 3 unsigned shorts, date*/ printf("please enter month integer: \n"); scanf("%hu"); printf("please enter day integer: \n"); scanf("%hu"); printf("please enter year integer: \n"); scanf("%hu"); return 0; } so, here's issue. i write absolutely massive 12x12 (144 options) switch statement every single case of month + zodiac sign combination, that'

c++ - Simplify these boolean expressions? -

i not sure if simplifying these boolean expressions correctly: 1. (a && b) || b 2. (a || b) && 3. !(a || b) && 4. !(a && b) || !b simplified expressions: 1. && b 2. || b 3. !b && 4. !a || !b fairly easy sort out truth tables 1. (a && b) || b b | e 0 0 | 0 0 1 | 1 1 0 | 0 1 1 | 1 simplified: b ################ 2. (a || b) && b | e 0 0 | 0 0 1 | 0 1 0 | 1 1 1 | 1 simplified: algebraically: using our identity we've derived part 1: (a || b) && --> (a && a) || (a && b) --> || (a && b) --> ################# 3. !(a || b) && b | e 0 0 | 0 0 1 | 0 1 0 | 0 1 1 | 0 simplified: 0 algebraically (via demorgans) !(a||b)&&a --> (!a && !b) && --> !a && !b && --> (a && !a) && !b --> 0 && !b --> 0 ################## 4. !(a && b) || !b b | e 0 0 | 1 0 1 | 1 1 0 | 1 1 1 | 0

python - Convert PIL image to OpenCV2 image -

i'm using entirescreen=imagegrab.grab() create screengrab , conduct analyses opencv2 test whether screen contains template images. templates loaded template = cv2.imread(name,0) . i have following problem: when comparing screenshot templates need first save screenshot : entirescreen.save('pics/screenshot.png', format='png') and reload : cv2.imread('screenshot.png',0) otherwise following not work: res = cv2.matchtemplate(img,template,method) i error message one: typeerror: image not numpy array, neither scalar my question: how can convert screenshot entirescreen=imagegrab.grab() format compatible opencv2, without having save , reload cv2.imread. on linux systems, 1 can use pyscreenshot docs state, replacement imagegrab module, works on windows only. so, on linux system did - import pyscreenshot imagegrab then, can grab screenshot , have access directly in memory space numpy array without having save onto disk , read im

amazon dynamodb - Querying items by secondary index with only secondary hashKey, no rangeKey -

i have table in dynamodb primary hashkey itemid . items have relationship parent item, besides querying them itemid , want able retrieve children of parent, added attribute parentid . now want able find children given parent. reading docs, understand need create secondary index, fail understand rangekey should , how construct dynamodbqueryexpression<item> without setting range condition. i missing fundamental guess... i'm assuming table looks this: itemid (hash key), parentid you need create global secondary index on table looks this: parentid (hash key), itemid (range key) now, can query set parent id in keyconditionexpression. here's example written in ruby: resp = aws::dynamodb::client.new.query( table_name: "mytablename", select: "specific_attributes", attributes_to_get: ["parentid", "itemid"], key_condition_expression: "parentid = <parent_whose_children_you_want>", exclus

laravel - Applying more query conditions after calling function -

if have like: $users = helpers::getusersfollowing($user_id); where getusersfollowing() looks this: public static function getusersfollowing($user_id) { return follow::where('user_id', $user_id) ->select('username') ->get(); } is possible to, without modifying code in function, apply more queries after function call, like: $users = helpers::getusersfollowing($user_id) ->with('posts') ->select('display_name') ->get(); i need able select display names (in addition usernames) , user's posts well, again, without modifying code in function. how can this? yes, should able this: as jensaronsson pointed out in comments, better solution because doesn't result in n+1 query $users = helpers::getusersfollowing($user_id); $user->load('posts') // if need additional query constraints $users->load(['author' => function ($query) { $query->orderby('w

RethinkDB error codes on inserting duplicate primary key -

what best way handle error thrown when row existing primary key being inserted. rethinkdb returns 'duplicate primary key...' in first_error. currently how handling it: if result['errors'] > 0 , 'duplicate primary key' in result['first_error']: but seems brittle, rethinkdb return error codes along error string messages. the driver don't return specific error codes, think code have best way go. keep in mind these messages sent directly server (not driver), if change, have change @ database level. if feel getting error codes useful, i'd suggest creating issue in rethinkdb's github issue tracker . in rethinkdb team usually, @ least, acknowledge issue , see if can include in database.

Composer update error packagists json -

i'm on windows 7. error on composer update. [composer\downloader\transportexception] "http://packagist.org/p/provider-2015-07%24eec61011fe6ec03b5dc7d406c70116caac2c28b7cb520e5a11a900b4afe8af7b.j son" file not downloaded: failed open stream: http request failed! composer self-update using composer version edf14dab1561096c10c71c7dfd81597ff94995a7. same error everytime.

javascript - Add text to an input field x when user clicks button x -

i have list of text inputs, each associated button. here's setup: jsfiddle i can working individually (see top button working), but how can make clicking of buttons change text of associated input ( button# --> text# ), without repeating code each item? html: <input type="text" id="text1" style="width: 150px;" /><input type="button" value="click me" id="button1" /><br/> <input type="text" id="text2" style="width: 150px;" /><input type="button" value="click me" id="button2" /><br/> <input type="text" id="text3" style="width: 150px;" /><input type="button" value="click me" id="button3" /><br/> <input type="text" id="text4" style="width: 150px;" /><input type="button" value="click me&qu

cordova - phonegap, jquery: function for <a> -

<a href="http://stackoverflow.com/" class="link" id="4" >stackoverflow</a> <script> $('.link').click(function(){ var idx = $(this).attr('id'); visit(idx); }) </script> i want make function run before browser opened. the function visit() defined , doesn't have error. for reason, visit(idx) ignored. can give me hints? you have prevent default behaviour of clicked link: $('.link').click(function(e){ e.preventdefault(); var idx = this.id; visit(idx); }) now depending visit() function doing, can after completes (i guess async method), redirect browser specific link done clicking on former link. for example, inside click handler , supposing visit() returns promise (ajax request e.g): visit(idx).always(function(){this.click();}.bind(this)); or using window.location = this.href; but more specific help, need post visit() method code in question itself.

reactjs - mocha + jsdom + React TypeError: Cannot read property 'addEventListener' of undefined -

i'm getting started unit testing react 0.10.0 component mocha 2.3.3, jsdom 6.5.1, , node.js 4.1.1. have unit test: var react = require('react/addons'); var testutils = react.addons.testutils; var sinon = require('sinon'); var expect = require('chai').expect; var jsdom = require('jsdom'); var view = require('../student-name-view.js'); describe('the student name view', function() { var renderedcomponent = null; var namechangedstub = sinon.stub(); var namesubmittedstub = sinon.stub(); before(function() { global.document = jsdom.jsdom('<!doctype html><html><body></body></html>'); global.window = document.parentwindow; this.renderedcomponent = testutils.renderintodocument( view({ namechanged: namechangedstub, namesubmitted: namesubmittedstub }) ); this.nameinput = testutils.findren

html - Column ordering in Bootstrap 3 -

here's demo : http://jsfiddle.net/8bxyr/215/ i want order divs in mobile screen , i'm using bootstrap 3 . recently i've read article: scotch can't handle html : <div class="container content"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-5 col-lg-4"> should below </div> <div class="col-lg-8 col-md-7 col-sm-12 col-xs-12"> should above in mobile screen </div> </div> </div> any advice ? thanks you'll place div want end below in second column, not first. don't need col- - (col-xs-* won't stack on xs viewport also) <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> <div class="container"> <div class="row"> <div class="well well-lg clea

stream - How to create a simple userprompt in clojure -

consider simple function definition in clojure: (defn prompt [] (print ">>> ") (read-line)) my ambition let user enter string prepended prompt-prefix. however, seems read-line gets executed before print statement. however, flushing output stream (defn prompt [] (print ">>> ") (flush) (read-line)) this function works intended. why manually have flush out in order ">>> " written out? according docs, functions , do should execute expressions in order. they executed in order. executing print doesn't mean given output flushed whatever stream *out* variable pointing to. docs say, print function prints object(s) output stream current value of *out*. and default, *out* points printwriter target of system.out . printwriter instances, flushing isn't enabled default. although, can enable auto-flush via using certain constructors creating instance. even then, printwriter instances

I want to make multiple mysql queries in the same time in C# -

i have code, when run select query works. when run insert query works. 2 queries can't work @ same time. don't know what's problem???! can me public partial class signupfm : form { string str = @"server=localhost;database=bullivant_arabia_archive;userid=root;password='';"; mysqlconnection con = null; mysqlcommand cmd = null; public signupfm() { initializecomponent(); } private void signupbt_click(object sender, eventargs e) { try { con = new mysqlconnection(str); con.open(); if(checkuser(usernametb.text)) { if (password1tb.text == password2tb.text) { insertuser(this.usernametb.text, this.password1tb.text); } else { messagebox.show("you haven't enter same password twice"); }

RDP through ICMP -

i have got vm in google compute engine. , want use vm using rdp. have enabled firewall settings accept rdp(tcp:3389). works fine when connect using lan connection. when try connect vm using icmp connection(icmp tunneling software), shows error couldn't connect remote computer 1 of these reasons: 1. remote access server not enabled. 2. remote computer turned on. 3. remote computer not available on network. but current configuration works fine when connect on lan. want use rdp using icmp tunnel. there way use rdp using icmp? ping works when trying connect through icmp.

android - How can I fill RecyclerView with GridLayoutManager from right to left -

i'm trying fill data recyclerview gridlayoutmanager : gridlayoutmanager layoutmanager = new gridlayoutmanager(this, 3, gridlayoutmanager.vertical, false); this fill data grid left right . first item put top-left place, etc. but app i'm developing designed rtl language, need make fill right left . i tried change last argument true . scrolled recyclerview way down. also setting layoutdirection attribute recyclerview doesn't work (without considering min api 16 , attribute added api17+): <android.support.v7.widget.recyclerview android:id="@+id/grid" android:layoutdirection="rtl" android:layout_width="match_parent" android:layout_height="match_parent"/> how can create right left filled grid using recyclerview ? create class extends gridlayoutmanager ,and override islayoutrtl() method this: public class rtlgridlayoutmanager extends gridlayoutmanager { public rtlg

android - how to save activity's data when we want to close the app or back to other activities -

for example: want enter string in (edit text) , string saved when want close app or return other activities. for need use sharedpreferences documentation first use save it: sharedpreferences myprefs = this.getsharedpreferences("myprefs", mode_world_readable); sharedpreferences.editor prefseditor = myprefs.edit(); prefseditor.putstring(my_text, edittext.gettext().tostring()); prefseditor.commit(); then when need use again : sharedpreferences myprefs = this.getsharedpreferences("myprefs", mode_world_readable); string prefedttext = myprefs.getstring(my_text, 0);

javascript - How to make an Angular.js app in Plunker -

i'm trying make example angular4 in plunker. however, don't know how make works. see how should done in correct way. myplunker example should this: firstnames url , show them. when user clicks on of these firstnames see entry's firstname, lastname , email... plunker link var app = angular.module('app', []); app.controller('mainctrl', function($scope, myservice){ var getfirstname = function(){ myservice.getfirstname(function(data){ $scope.user = data; }); }; getfirstname(); }); app.service('myservice', function($http){ return{ getfirstname: function(callback){ $http.get('http://hjgz2l4w8r2zvaym4-mock.stoplight-p roxy.io/api/users').success(calback); } } });

Android setting image resource from class inside arraylist -

i apologize if question confusing hard me word. created class holds 2 int , imageview parameters. class added arraylist , shuffled. want access drawable image based on arraylist index. below example of want do. card card00 = new card(0,0,c0) *the image arraylist<card> deck = new arraylist<deck>(); deck.add(card00); collections.shuffle(deck); arraylist<deck> player_1_hand = new arraylist<domino>(); player_1_hand.add(deck.get(0)); imgview1.setimageresource(player_1_hand.???); //this i'm having trouble public class card { private int x,y; public card (int x, int y, imageview i){ this.x = x; this.y = y; } public int getx(){ return x; } public int gety(){ return y; } public void setx(int x){ this.x = x; } public void sety(int y){ this.y = y; } public void f

c - Checking the existence of ACE in windows object DACL -

is there way check if ace exists in dacl of object? i want use rtladdaccessallowedace api call add ace object, want if ace doesn't exist already. does know how can either check if ace exist, or try remove given ace before adding it, or other solution achieve same goal? thanks! you can or use winapi or direct walk acl aces - enumerate ace 1 one , check specific ace exist: variant 1: void walkacl(pacl acl) { acl_size_information asi; if (getaclinformation(acl, &asi, sizeof(asi), aclsizeinformation)) { if (asi.acecount) { { union { pvoid pvace; pace_header paceheader; paccess_allowed_ace pallowedace; }; pwstr szsid; if (getace(acl, --asi.acecount, &pvace)) { switch (paceheader->acetype) { case acc

Java Error: String cannot be resolved into a type(S is uppercase) -

in code error (from eclipse) "string cannot resolved type": package tilegame.display; import javax.swing.jframe; public class display { private jframe frame; private string title; private int width, height; public display() { public display(string title, int width, int height){ this.title = title; this.width = width; this.height = height; createdisplay(); } } public void createdisplay() { frame = new jframe(title); frame.setsize(width, height); frame.setdefaultcloseoperation(jframe.exit_on_close); } } i searched "string" upercase , have java library eclipse. do not nest constructors. try this: package tilegame.display; import javax.swing.jframe; public class display { private jframe frame; private string title; private int width, heigh

android - GoogleMaps placeId of PointOfInterest not the same as one from API -

Image
the placeid returned api not same 1 in pointofinterest instance passed onpoiclick method (of onpoiclicklistener interface) onpoiclicklistener in googlemaps return google places api: edit: the problem google having 2 separate entries same place. determining second entry 238 bukit panjang ring rd nearest location not clickable point on map. 1 clickable returns block 238\n bukit panjang has different id. more information: the likelihood buffer returns following - places: place '238 bukit panjang ring rd' has likelihood: 0.950000 places: place 'block 238 hdb bukit panjang' has likelihood: 0.00000

php - Spotify request token returns invalid_client -

i hope can me here: i have application should use spotify api. after request authorization itself, stuck @ requesting token. related code follows: function post($content, $url,$clientid,$clientsecret) { $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_customrequest, "post"); curl_setopt($ch, curlopt_postfields, $content); curl_setopt($ch, curlopt_httpheader, array( 'content-type: application/x-www-form-urlencoded', 'authorization: basic '.base64_encode($clientid).':'.base64_encode($clientsecret))); return curl_exec($ch); } $clientid="4df42e27a76d41f9961b0952102fexxx"; $clientsecret="3088a8b6132b40dc980540880cf5bxxx"; $content=array( 'grant_type' => 'authorization_code', 'code' => $_get["code"], 'redirect_uri' => 'http%3a%2f%2fhome.xxx.de%2ftoken.php', ); echo post($content,"https://accounts.spot

javascript - Bind and un-bind hammer JS using on click events -

is there way on how can bind , un-bind hammer.js touch events using on click events. carousel slider have built. if user wants enable touch or disable touch events. i have 2 classes have created use click events. class .slider-layout enables carousel while class .tile-layout disable carousel , transforms layout in card view layout update #1 i tried removing class binds hammer.js didn't work. var activeslide = 0; $('.faculty-carousel').attr('data-slide', '0'); $('.tile-layout').on('click', function() { $('.faculty-items').each(function() { $(this).addclass('tile-view'); }) }) $('.prev').on('click', function(e) { event.stoppropagation(); var carouselwrapper = $(this).closest('.faculty-carousel'), facultyprofilepanel = carouselwrapper.find('.faculty-items li'

objective c - Convert HTML to NSAttributedString in iOS with input type checkbox -

Image
i have problem nsattributedstring. want show checkbox nsattributedstring image : but can't show that: this code: nsstring *txt = @"<br><input type='checkbox' >checkbox<br><br>"; nsattributedstring *att = [[nsattributedstring alloc] initwithdata:[txt datausingencoding:nsutf8stringencoding] options:@{nsdocumenttypedocumentattribute:nshtmltextdocumenttype, nscharacterencodingdocumentattribute: @(nsutf8stringencoding)} documentattributes:nil error:nil]; lbltitle.attributedtext = att;

mysql - Query to fetch data from the database using loop and store it in a array in PHP -

i made page accept multiple data roll no , password user , equate password of roll no the password stored in database. problem lies in fact unable solution of how execute query fetch data database under loop statement. here statement:- for( $i=0 ; $i<$count ; $i++ ){ include('connection.php'); $db[$i] = "select * login roll = $roll[$i]"; $login[$i] = mysqli_query($conn, $db[$i]); while($log[$i] = mysqli_fetch_assoc($login[$i])) { $dbemail.$i = $log[$i]['email']; $dbpass.$i = $log[$i]['pass']; $roll.$i = $log[$i]['uno']; } mysqli_close(); } before execution of above part of code $roll[$i] has entered roll no in it. thank in advance help.

r - Not showing NAs in knitr::kable output as do xtable -

this question has answer here: hiding na's when printing dataframe in knitr 2 answers i want omit nas in output of knitr::kable output same xtable (see kable , xtable outputs below). highly appreciated. thanks fm12anova <- structure(list(sov = c("days", "residuals"), df2 = c(1l, 178l ), sum.sq2 = c(162702.651909532, 405251.617480465), mean.sq2 = c(162702.651909532, 2276.69448022733), f.value2 = c(71.4644205986244, na), pr..f.2 = c(9.89409632221545e-15, na), sum.sq1 = c(30031.0139578738, na), mean.sq1 = c(30031.0139578738, na), numdf1 = c(1l, na), dendf1 = c(17.0000010028433, na), f.value1 = c(45.8530037127448, na), pr..f.1 = c(3.26378804516025e-06, na)), class = "data.frame", row.names = c(na, -2l), .names = c("sov", "df2", "sum.sq2", "mean.sq2", "f.value2"

signal processing - How to use previous element in vector in Matlab? -

i'm taking digital signal processing course requires me use matlab. i'm still beginner, i'm sorry if basic don't know how google this. i'm supposed check linearity. have couple of vectors made randn(1,100) , i'm supposed use them check if f{a·x1 [n]+b·x2 [n]} = a·f{x1 [n]}+b·f{x2 [n]} when example f{x[n]} = x[n] + 2 adding vectors easy. one of problems f{x[n]} = ¼ (x[n]+2·x[n-1]+x[n-2]) need access previous 2 elements in vector. how can this? there's 1 f{x[n]} = n·x[n] . here need specific index of element. edit: answers. didn't know how approach couldn't think sample code try. figured out should create shifted vectors n-1 , n-2 values , use separate index vector n*x[n] thing. approaching whole issue wrong angle. isn't elegant solution works. sorry wasting anyone's time. it straightforward. >> x=[1,2,3,4] >> x(2-1) ans = 1 make sure don't go beyond limit (i.e. x(0) yields error since index m

javascript - Haxe JS Deploying -

i'm making game via haxe+openfl, targeting html5. every time test application, localhost server starts , can visit localhost:2000 test game. wonder how can publish app other people got file(s) launch too, without running through flashdevelop selecting different target allows packaging executable easiest. openfl officially supports adobe air, example. if must deliver files html5, in cases browser allow open index.html directly. option bundle using nw.js or similar tool.

Oracle Toad "Editor" tab missing -

i'm using oracle toad version 9. accidentally have removed editor tab in toad. can display editor tab again in bottom original view of editor present situation that window bar. right click on main toad toolbar , make sure window bar checked. if , don't see docked side of toad right click on main toad toolbar , choose "restore defaults."

c++ - Forward Declaration of Class: Syntax Error -

i'm getting declaration syntax error in following code: fileio.h class fileio; //error here: i'm trying declare can use in read() function int read(char* file_1); //file read function fileio.cpp int read(char* file_1) { //file read function fileio object_1; int records_read=0; ifstream fin; fin.open(file_1, ios::binary); //opens file again while(fin.read((char*)& object_1, sizeof(object_1))) { records_read++; object_1.show_tablular(); } fin.close(); return records_read; } test.cpp template <class t> void addcolumn(t data, const int& width) { cout<<setw(width)<<data<<" | "; } void test_class::show_tablular() { cout<<endl; addcolumn(record_id,7); addcolumn(char_member, 20); addcolumn(int_member, 11); addcolumn(float_member, 13); } inside main() class fileio : public test_class { //trying relate 2 classes public: void show_tablular() {

python - Adding values of a key, based on the similarity of other key -

so have list of python dictionary this: [{"word": 'app idea', "post" : 'i had app idea', "likes" : 22}, {"word": 'app idea', "post" : 'this great app idea', "likes" : 29}, {"word": 'app development', "post" : 'let start our app development', "likes" : 32}, {"word": 'app development', "post" : 'app development take time', "likes" : 23}, {"word": 'app data', "post" : 'delete app data', "likes" : 32}] i want add likes word same so final output looks this [{"word": 'app idea', "likes" : 51}, {"word": 'app development', "likes" : 55}, {"word": 'app data', "likes" : 32}] in 1 line, using itertools.groupby , dictionary & list comprehension group dicts va

ios - Add property observer to global variable inside class in Swift -

i have variable globalvariable declared @ global scope may change @ time. different viewcontrollers in app need react differently, when globalvariable changes. thus desirable add property observer in each viewcontroller execute needed code when globalvariable changes. i cannot seem achieve override or extension . what way go here? if goal know when global variable changed, have post notification upon change: extension nsnotification.name { static let globalvariablechanged = nsnotification.name(bundle.main.bundleidentifier! + ".globalvariable") } var globalvariable: int = 0 { didset { notificationcenter.default.post(name: .globalvariablechanged, object: nil) } } then object can add observer notification: class viewcontroller: uiviewcontroller { private var observer: nsobjectprotocol! override func viewdidload() { super.viewdidload() // add observer; make sure `self` references `weak` or `unowned`; o