Posts

Showing posts from May, 2012

jsp - Google App Engine Java Datastore Query - Limit Results? -

i trying fetch entries datastore , need filter them genre: <%@ page import="com.google.appengine.api.datastore.query.filter"%> <%@ page import="com.google.appengine.api.datastore.query.filterpredicate"%> <%@ page import="com.google.appengine.api.datastore.query.filteroperator"%> <%@ page import="com.google.appengine.api.datastore.*"%> <%@ page import="com.google.appengine.api.datastore.query.*"%> query confquery = new query("track"); query.filter topicfilter = new filterpredicate("genre", filteroperator.equal, genre); confquery.setfilter(topicfilter); confquery.addsort("lastplayed", sortdirection.ascending); preparedquery results = datastore.prepare(confquery); this return of entries given genre. how can limit e.g. 10 entries? you can use use fetchoptions this datastore.prepare(confquery).aslist(withlimit(10));

android - Textviews show linkable text when there isn't an actual link -

in lollipop, have textview populated html.fromhtml(). the text example can "hello.world" , shows link. in layout textview i've specified autolink="web" want links in string clickable actual url. android:autolink="web" this issue persists in whatsapp messages. any thoughts ?

Meteor: Calling/trigerring events from inside JavaScript? -

i have event looks this: template.foo.events({ 'bar': function() { console.log("hello!"); } }); how call/trigger within client using js? like: qwe = new event(foo); qwe.dispatchevent();? see events in meteor docs: http://docs.meteor.com/#/basic/template-events "the first part of key (before first space) name of event being captured. pretty dom event supported. common ones are: click, mousedown, mouseup, mouseenter, mouseleave, keydown, keyup, keypress, focus, blur, , change." so in example, 'bar' should replaced 'click'. fired when template clicked.

mysql - SQL join some tables -

i have 4 tables: user(userid,username,password) book(id,title,author,isbn,cost) orders(orderid,orderdate,userid) (manytoone user , onetomany orderitem ) orderitem(id,quantity,totalprice,book_id, order_orderid) (manytoone order , manytoone book ) i ma going retrieve title , cost , author , orderid , quantity userid=1 here query: select book.title, book.cost, book.author, orders.orderdate, orderitem.quantity, orderitem.totalprice book join orderitem on book.id = orderitem.id join orders on orders.orderid = orderitem.order_orderid user_id=1; but query has no result! select book.title, book.cost, book.author, orders.orderdate, orderitem.quantity, orderitem.totalprice book inner join orderitem on book.id = orderitem.book_id inner join orders on orders.orderid = orderitem.order_orderid user_id = 1;

html - border-radius not working with border-image output -

i'm creating css3 loading icon effect instead of using gif. have created loading icon effect i'm unable make circle. revolving in square instead of circle. border-radius not working border-image property ? html <div id="progress"> <span class="spinner-icon"></span> </div> css #progress { pointer-events: none; } #progress .spinner-icon { width: 30px; height: 30px; display:block; border: solid 2px transparent; border-radius:50%; -webkit-animation: progress-spinner 600ms linear infinite; animation: progress-spinner 600ms linear infinite; -moz-border-image: -moz-linear-gradient(top, #3acfd5 0%, #3a4ed5 100%); -webkit-border-image: -webkit-linear-gradient(top, #3acfd5 0%, #3a4ed5 100%); border-image: linear-gradient(to bottom, #3acfd5 0%, #3a4ed5 100%); border-image-slice: 1; } #progress { position: absolute; } @-webkit-keyframes progress-spinner { 0% { -webkit-transform:

c++ - error C3499: a lambda that has been specified to have a void return type cannot return a value -

i using following lambda , getting error. can't figure out why compiler doesn't doing. std::string captchaword(6, 0); std::generate(captchaword.begin(), captchaword.end(), []() { unsigned int num = randomizer('z' - 'a' + 1 + '9' - '0' + 1); char ch = num + 'a'; if (num >= 'z' - 'a' + 1) { ch += '0' - 'z' - 1; } return ch; }); by way, randomizer function following signature: unsigned int randomizer(unsigned int); this error message get: error c3499: lambda has been specified have void return type cannot return value. you have specify return type: []() -> char { // code; } the automatic deduction works if whole lambda consists of single return statement only (in c++11), otherwise, need specify type. see documentation on lambda on cppreference . in c++14, rules allow other statements before return.

select - Show name of columns in mysql -

i have 3 date values in table, namely activationdate, registrationdate, , creationdate , have select show name of column least value. i used select least(activationdate, registrationdate, creationdate) table name and returns smallest value. however, want know of these 3 smallest value. so, expected outcome name of column has least date can activation date, registration date or creation date. for solution, kindly state result if 3 of them have similar values? return or one? thanks you need test least value against each column, in conditional statement. assuming following table structure create table `test` ( `activationdate` datetime default null, `registrationdate` datetime default null, `creationdate` datetime default null ) with these values mysql> select * test; +---------------------+---------------------+---------------------+ | activationdate | registrationdate | creationdate | +---------------------+--------------------

Overload operator for int and char in c++ -

i want have class can accept assignment both , int , string literal. string literal, turns out, must of type char[]. have whole lot of data types taken assignment operator. compiler gets confused between these two. how interchangeable char can int, use quick ascii comparisons. i'd know if there's way compiler stop trying send string literals int version of overloaded operator. none of other types have problem, these 2 getting mixed up. mydatatype& operator = (int right); mydatatype& operator = (const char &right); when try: mydatatype test; test = "hello world."; the compiler tries interpret string literal int , throws error: error: invalid conversion ‘const char*’ ‘int’ [-fpermissive] thanks. if string must of type char[] , must have [] , or * , in signature. mydatatype& operator = (int right); mydatatype& operator = (const char *right); or mydatatype& operator = (int right); template<size_t n>

java - Two objects from singleton -

i want make 2 objects following class , have stored 2 arraylist well, matter of fact want store 2 variations of same type in singleton i call crimelab.get(getactivity()).getcrimes(); in different activities encounter problem due referring same object (arraylist) public class crimelab { private static final string tag = "crimelab"; private static final string filename = "crimes.json"; private arraylist<crime> mcrimes; private criminalintentjsonserializer mserializer; private static crimelab scrimelab; private context mappcontext; private crimelab(context appcontext) { mappcontext = appcontext; mserializer = new criminalintentjsonserializer(mappcontext, filename); try { mcrimes = mserializer.loadcrimes(); } catch (exception e) { mcrimes = new arraylist<crime>(); } } public static crimelab get(context c) { if (scrimelab == null) {

php - How to make my website url SEO friendly and tell google bots that there is an important content -

i using windows hosting. website written in php . have contents mysql database using id like... <a href="view.php?id='.$row['id'].'">'.$row['title'].'</a> and url shown in browser address bar below http://www.mywebsite.com/view.php?id=1025896 you can understand above url. my questions are... is there way make url seo friendly ? like http://www.mywebsite.com/view/1025896/ and how tell google bots or other crawler there important content in link (as link getting content directly database using id) . i have seen this reference written .htaccess not work in iis

swift - One rotation around the point of IOS? -

when put anchor point set (0, 0) of time, turn, jump first (0.5, 0.5) position , began spin, why, rather directly around anchor point (0, 0) rotating??? self.layer.anchorpoint = cgpointmake(0.18,0.18) uiview.animatewithduration(1.2, animations: { () -> void in self.layer.transform = catransform3dmakeaffinetransform(cgaffinetransformmakerotation(cgfloat(-m_pi/5))) })

Kendo UI Pie chart incase of no data -

Image
i want show @ least 1 circle incase of no data in piechart. disappearing if percentage zero. label text appearing. i don't think kendo provides out of box. please find workaround specified in 1 of post in forum. no data message pie chart

java - How can I make a list print out A1-A6, then B1-B6, etc? -

i'm creating vending machine has print out list of options user can enter, problem facing can not print need input item. program gets items print text file. example can print this: almond joy mentos skittles but need this: a1: almond joy a2: mentos a3: skittles so on , forth through a6, go on b1-b6, on , forth. how can print out in fashion? you need generate prefix yourself: int num_columns = 6; char rowprefix = 'a'; int colprefix = 1; scanner s = new scanner("/path/to/file.txt"); while (s.hasnextline()) { string product = s.nextline(); system.out.println(string.valueof(rowprefix) + colprefix + ": " + product); colprefix++; if (colprefix == num_columns) { colprefix = 1; rowprefix++; } }

java - HttpServletResponse redirect with application/json as Content-Type -

i'm trying redirect post request json host using following code. when tested out, got error "unsupported media type" , browser indicated content type of redirected request "text/html". does have idea how correctly set content type of redirected request? in advance. @override protected void dopost(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { string targeturl = "http://localhost:8080/getjson"; resp.setstatus(httpservletresponse.sc_temporary_redirect); resp.setcontenttype("application/json"); resp.setheader("location", targeturl); }

PostgreSql : using a statement as case condition -

when use statement case condition returns false ; select * table order (case when (true) id else 1/0 end) desc -- works select * table order (case when (select true) id else 1/0 end) desc -- exception select * table order (case when (1=1) id else 1/0 end) desc -- works select * table order (case when (select 1=1) id else 1/0 end) desc -- exception what wrong condition? the case when expects boolean result condition per documentation : each condition expression returns boolean result. the select statements return relation (yes, single row having single column boolean type , value of true still not boolean ).

Neo4j 2.2.1 server does not start after db is generated via java code -

started new graph.db folder. using embedded graph db, java , cypher query create nodes. seems create nodes successfully. have debugged , checked result object. i want start neo4j server check nodes in browser. however, gives message: bash-4.2$ ./neo4j-community-2.2.1/bin/neo4j start warning : max 1024 open files allowed, minimum of 40 000 recommended. see neo4j manual. starting neo4j server... warning : not changing user process [2868]... waiting server ready...... failed start within 120 seconds. neo4j server may have failed start, please check logs. i checked console.log , message.log. there not error. don't know read in log files put here diagnosis. please advice. console.log: 2015-04-26 05:14:47.278+0000 info [api] setting startup timeout to: 120000ms based on 120000 2015-04-26 05:14:49.700+0000 info [api] shutdown neo4j server. 2015-04-26 05:15:24.684+0000 info [api] setting startup timeout to: 1200

swift - Parse/PFNullability.h not found -

hi i'm trying update facebook sdk 3.x 4.0 using parse. it works if don't use facebook integration. when try use facebook,pffacebookutils.h generate error. said "parse/pfnullability.h not found" heppened. parsefacebookutilsv4/pffacebookutils.h file try import 3 files parse.framework. #import <parse/pfconstants.h> #import <parse/pfnullability.h> #import <parse/pfuser.h> "pfconstants.h" , "pfuser.h" seems imported successfully. search path should okay. and think "pfnullability.h" exist , don't know why "pfnullability.h" cause error. please me! here's bridge header file. #import <fbsdkcorekit/fbsdkcorekit.h> #import <bolts/bolts.h> #import <parse/parse.h> #import <parsefacebookutilsv4/pffacebookutils.h> i'm using parse-library-1.7.1 on xcode 6.3.1 (swift). i solved problem. since imported frameworks , deleted them again , again, have multiple reco

ajax - How to update model after making json get request? (Angular JS) -

Image
i have simple page shows set of records according year. note, sidebar not highlighting selection properly. i able load data first time come page. when try change year , hit go, main content area goes blank , url changes localhost:8080/cg/ here controller code. app.controller('annualreportcontroller', ['$scope', '$http', function ($scope, $http) { $scope.annuals = []; $scope.selection = 0; // gives me year value drop down. // initial load works $http.get('annualreport/list').success(function (data) { $scope.annuals = data; $scope.selection = data.year; }); // on-click event 'go' $scope.searchgo = function () { $http.get('annualreport/list', {params: {year:$scope.selection} }).success(function (data) { $scope.annuals = data; $scop

windows - Assign content of DIR to a variable -

i wrote following cmd dir /b "%appdata%\mozilla\firefox\profiles" which returns following single folder exists @ dir location 4jktnrk2.default i wish store 4jktnrk2.default in variable. i tried following set a=dir /b "%appdata%\mozilla\firefox\profiles" and set a="dir /b %appdata%\mozilla\firefox\profiles" however neither of these work. i think best not use for loop there 1 folder in directory. @echo off setlocal enabledelayedexpansion set "dir_c=" /f "delims=" %%a in ('dir /b "%appdata%\mozilla\firefox\profiles"') ( if "!dir_c!" equ "" ( set "dir_c=%%~a" ) else ( set "dir_c=!dir_c!;%%~a" ) ) echo %dir_c% you have no other option use for /f .there's no unix style assigning result of command variable in batch.

php - Silex, bad credentials with security firewalls and custom user provider -

i have bad credentials on login attempt security firewalls , custom user provider. here's code. $app->register(new securityserviceprovider(), array( 'security.firewalls' => array( 'admin' => array( 'pattern' => '^/admin', 'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), 'logout' => array('logout_path' => '/admin/logout'), // url call logging out 'users' => $app->share(function() use ($app) { // specific class user\userprovider return new userprovider(); }), ) ), 'security.access_rules' => array( // can rename role_admin wish array('^/admin', 'role_admin'), ) )); $app['secur

node.js - Building a chat app: How to get time -

i building chat app pubnub. problem app/frontend point of view, how should time (server time). if every message sent server, server time there. 3rd party service pubnub, how can manage this? since app sends messages pubnub rather server. dont want rely on local time users might have inaccurate clocks. the simplest solution thought of is: when app starts up, server time. record difference between local time , server time ( diff = date.now() - servertime ). when sending messages, time date.now() - diff . correct far? i guess solution assumes 0 transmission (or latency) time? there more correct or recommended way implement this? your use case reason why pubnub.time() exists. in fact, have code example describing drift calculation. https://github.com/pubnub/javascript/blob/1fa0b48227625f92de9460338c222152c853abda/examples/time-drift-detla-detection/drift-delta-detection.html // drift functions function now(){ return+new date } function clock_drift(cb) { clock_dr

android - Transparent background on custom Dialog -

i'm trying transparent backgroud on custon dialog, can't done on android 4.4.4. works on android 5.1. the result i'm looking this: http://www.americocarelli.com.br/android_5.1.png but this: http://www.americocarelli.com.br/android_4.4.4.png this custom layout: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dialogo_layout_root" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/transparente" android:windowbackground="@color/transparente"> <textview android:id="@+id/titulo_dialogo" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignparenttop="true"

php - Cookie does not set -

i have cookie not set on remote server, works find locally. no error messages, var_dump gets me null, echo blank. <php setcookie('ymp','14', time()+3600); session_start(); ?> i can set javascript cookie fine. opening tag line 1 of page. any ideas thanks gary on edit i have comments posted below, 3 file process. page 1 set cookie, above. page 2 have debugging <php var_dump($_cookie['ymp']); echo'<br />'.$_cookie['ymp'];?> page 3, , again worked locally have <?php if($_cookie['ymp']!=='14') {die('sorry, have not had delightful little pastry yet.... try again.');} ?> i set js cookie, , changed code reflect different cookie name , worked fine. i reset time +86400, because of 2 hour time difference server, though don't think required. thanks help gary you can't read value of cookie until new page request made. because value of cookie data sent

c++ - Compiling a program under Windows gives a bunch of "error: template with C linkage" reports -

i have made opengl project compilable gcc (version 4.7.3 , newer) , runable on linux. when trying compile same code under windows using msys2 gcc 4.9.2 installed, tons of error reports: g++ -g --std=c++11 src/*.cpp -iinclude -isrc -lil -lilu -lilut -lgl -lglu -lglut -lm -dwin32 -i/mingw64/include windows/src/*.cpp -o "achtung, die kurve 3d!" in file included /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/stringfwd.h:40:0, /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/string:39, include/windows.h:1, /usr/include/w32api/gl/gl.h:13, /mingw64/include/gl/freeglut_std.h:143, /mingw64/include/gl/freeglut.h:17, src/controls.cpp:1: /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:63:3: error: template c linkage template<typename> ^ /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:66:3: error: template specialization c linkage templa

ios - reusing the same UITableViewController -

Image
i have tableviewcontroller needs drill down , show 3 layers of data. have no problem drilling down when go back, cells , table become empty. i'm using storyboard , didn't have problem when using nib. had to alloc , initwithnibname same view , create instance of same tableview , can go , data there. i've tried using segue it's not working need tableviewcontroller segue if i'm drilling down. i've created own method push view controller , pass data new instance of itself - (void)drilldown{ uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:[nsbundle mainbundle]]; exercisetableviewcontroller *tableview = [storyboard instantiateviewcontrollerwithidentifier:@"exercisetableview"]; tableview.title = _detailtitle; tableview.delegate = self; tableview.level = _level; tableview.currentsmid = _currentsmid; tableview.currentmid = _currentmid; tableview.musclenamearray = _musclenamearray;

javascript - Sending json with $.post in express/node -

this app.js file: var express = require('express'); var app = express(); var path = require('path'); var $ = require('jquery'); var nodemailer = require('nodemailer'); app.use('/static', express.static(path.join(__dirname, 'static'))); app.get('/', function(req, res) { res.sendfile('./views/index.html', {"root": __dirname}); }); app.post('/contact/', function(req, res){ console.log(req.body); }); and post request file, called when form submitted: $('form').submit(function(e){ e.preventdefault(); var content = $('#message').val(); var email = $('#emailinput').val(); var reason = $('#reason').val(); $.post('/contact', { 'content': content, 'email': email, 'reason': reason }, function(data){ console.log(data); }); }) however, whenever form submitted, post request successful, it's no

python - why wont pygame quit? -

the game freezes instead of quitting. have exit idle. ideas on do? def quit_game(): event in pygame.event.get(): if event.type == pygame.quit: sys.exit() quit_game() this idle bug. recommend using real ide such pycharm. fix issue, have @ pygame faq . offer solution: # ... running = true while running: event = pygame.event.wait () if event.type == pygame.quit: running = false # idle friendly pygame.quit ()

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\update.php on line 14 -

this question has answer here: can mix mysql apis in php? 5 answers reference - error mean in php? 29 answers i'm getting error on gambling site, it's on progressbar error occurs. warning: mysql_fetch_object(): supplied argument not valid mysql result resource in c:\xampp\htdocs\update.php on line 14 update.php: <?php if(session_id() == '') { session_start(); } ?> <?php try { $apikey = "c897813f4999af1eda50aeecfd9eccfe"; $servername = "127.0.0.1"; $username = "root"; $password = "admin123"; $dbname = "skingamble"; $conn = new mysqli($servername, $username, $password, $dbname); $result = $conn->query("se

xaml - Silverlight - Adding MediaElement via C# - short time to manage Play() method -

i made simple app in windows phone silverlight 8.1. looks cell phone keypad lcd-looks screen shows number of current tapped button , plays tone sound of number. i've been searching while found nothing specific. i have problem play(); method because execute while i'm debugging in realtime after app-deploy device hear nothing... i researched many topics , can tell depends on mediaelementobject.currentstate; sometimes it's on "closed" state , on "opening"(and hear sound while debugging). c# private void keypadbuttonclick(object sender, routedeventargs e) { button currentbutton = sender button; mediaelement keysound = null; if (currentbutton != null) { string buttoncontentvalue = currentbutton.content.tostring(); keysound = new mediaelement(); contentpanel.children.add(keysound); playtargetkeypadsound(buttoncontentvalue, keysound); refreshnumbe

jquery - Accessing $_POST data in functions.php from a template file after it's been sent via ajax -

i able retrieve data sent via ajax in functions.php. need data in template.php (of theme). first time using ajax , maybe i'm going wrong way. able echo $_post['myvar']; within functions.php (i posting code once work). assuming setup correct, can access ajax data outside of functions.php? btw, signed here @ stack well, if failed follow procedure, apologize. edited thanks guys - here sample code. in js file have: $(window).load(function(){ $("#cat").on("click",function() { var selectedcat = $(this).children("option").filter(":selected").text(); $.get('../../../../../../wp-admin/admin-ajax.php', { action: "parent_cat_send", parent_cat: selectedcat }); }); }); and in functions.php have: add_action('wp_ajax_parent_cat_send', 'current_par_cat'); add_action('wp_ajax_nopriv_parent_cat_send'

java.lang.NullPointerException at org.apache.jsp.mouseproduct_jsp._jspService(mouseproduct_jsp.java:145) -

i getting following exception while running application on tomcat8 using intellij idea14. 25-apr-2015 16:30:49.221 severe [http-nio-8443-exec-133] org.apache.catalina.core.standardwrappervalve.invoke servlet.service() servlet [jsp] in context path [] threw exception [an exception occurred processing jsp page /mouseproduct.jsp @ line 35 <% string ppic = oc.getppicture(); ppic = ut.findproductpicture(ppic, oc.getpcolor()); int [] wh = swutil.getpicwhbymin(application.getrealpath("images").replacefirst("newportal_admin","newportal")+"\\"+ppic); %> <img src="<%="../images/"+ppic%>" width="<%=wh[0]%>" height="<%=wh[1]%>" border="0"> </td> stacktrace:] root cause java.lang.nullpointerexception @ org.apache.jsp.mouseproduct_jsp._jspservice(mouseproduct_jsp.java:145) @ org.apache.jasper

sql server - How to add a single quote when I have single quote in PHP for SQL Management studio -

i having trouble sql management studio , not want connect sql server want make data ready lines inserted in database have text file lines of strings want insert in sql server line this: you're doing wrong!!,mike walsh,intermediate so should ready sql server. you''re doing wrong!!,mike walsh,intermediate i have in lines: never have "mayday!!!" again is 1 going become problem? should have plan also? i tried use addslash , replace slash single quote doing: $str=",('".addslashes ($array[0])."')"; $str=str_replace("\\","\'",$str); echo $str; i did comma , parenthesis when have insert query in sql server result of 1 be: ,('you\''re doing wrong!!'), ,('never have \'"mayday!!!\'" again'), what did wrong here? using prepared statements best way. if insist on regex way, can double single quotes preg_replace there number of consequ

fork - GDB and LLDB "swallow" status set by child process in OS X -

given following code: #include <stdio.h> #include <signal.h> #include <unistd.h> #include <sys/wait.h> int main(int ac, char** av) { int status; pid_t cpid = fork(); if(0 == cpid) { /* child */ return *(volatile int*) 0; /* exits signal 11 */ } else { /* parent */ { waitpid(cpid, &status, wuntraced); if(wifsignaled(status)) { printf("\nchild exited signal %d\n\n", wtermsig(status)); return 0; } } while (!wifexited(status) && !wifsignaled(status)); printf("\nchild exited normally\n\n"); } return 0; } i expected result running app terminal: $ ./fork4gdbtests.exe child exited signal 11 running app within lldb (or gdb), strangely, get: $ lldb ./fork4gdbtests.exe (lldb) target create "./fork4gdbtests.exe" current executable set './fork4gdbtests.exe' (x86_64). (lldb) r process 4681

sqlite3 cannot open database file, running Centos, flask uwsgi nginx -

i have simple flask app runs fine on local machine. app uses sqlite3. trying deploy centos machine running nginx , uwsgi. app starts when try access site through chrome, raises exception: sqlite3.operationalerror: unable open database file i believe have permissions correct, user starting app has ownership of database file. directories have 777 permissions. database has 665 permissions. nginx started using sudo. i have combed through existing posts kind of thing. people talk permissions, pretty sure have correct. name of file correct. database = 'sqlite:////home/.../firstdb.db' i same error if database points nonexistent file. else going wrong? so turns out file name prefix of sqlite/// incorrect. don't understand this, worked before. put file name , works now.

javascript - Angularjs chaining promises: propagation of notify vs resolve -

i trying chain 3 promises. find if resolve promise1, result in promise2's success callback , can control what , if need send promise3. if issue notify in promise1, not matter in promise2, promise3's notifycallback triggered immediately. how can prevent , make conditional based on business rules in promise2 ? here simple example in jsfiddle: http://jsfiddle.net/deepfiddle/rxv8322s/ if issue .notify() instead of .resolve() (uncomment/comment line in promise1), see promise3 gets notified immediately. here relevant code: var myapp = angular.module('myapp', []); myapp.controller('myctrl', function($scope, $q, $timeout) { console.log("--app controller"); var p0 = $q.when(); p0 .then( //promise: p1 function(result) { console.log("p1", result); var deferred = $q.defer(); $timeout(function() { console.log("in timeout of p1"); //note1: propagation of resolve can controlled not

ios - WatchKit call webview -

i'm working on apple watch app , i'm facing problem. since app company i'm working on doesn't have api, , not planning make, use uiwebview parse html app. i'm trying port apple watch, cannot open uiwebview in background using handlewatchkitextensionrequest delegate. is there way run uiwebview background task , send data apple watch app? i'm not aware of method run uiwebview in background. think you'll have use nsurlsession download html. hopefully, can reuse parsing logic as-is.

javascript - SlickGrid requires a valid container, #myGrid does not exist in the DOM -

i've been trying use slickgrid dataview json no avail. keep getting above error. "javascript runtime error: slickgrid requires valid container, #mygrid not exist in dom." <div id="mygrid" style="width:100%;height:500px;"></div> and script file load json: var dataview = new slick.data.dataview(); var grid = new slick.grid("#mygrid", dataview, columns, options); //sample data var columns = [ { id: "codeid", name: "codeid", field: "codeid", width: 50 }, { id: "name", name: "name", field: "name", width: 200 }, width: 100 } ]; var options = { enablecolumnreorder: false, multicolumnsort: true }; // wire model events drive grid dataview.onrowcountchanged.subscribe(function (e, args) { grid.updaterowcount(); grid.render(); }); dataview.onrowschanged.subscribe(function (e, args) { grid.invalidaterows(args.rows); grid.render();

java - Reading text file from url gives IllegalStateException -

i trying read text file url string in android. have tried multiple codes, , using one: bufferedreader in = new bufferedreader(new inputstreamreader(new url("https://wordpress.org/plugins/about/readme.txt").openstream())); every single code has given me illegalstateexception in line. have following permissions: <uses-permission android:name="android.permission.internet"></uses-permission> <uses-permission android:name="android.permission.access_network_state"></uses-permission> <uses-permission android:name="android.permission.read_phone_state"></uses-permission> <uses-permission android:name="android.permission.write_external_storage" /> i hope can give me explanation why happening. here full error: fatal exception: main process: com.example.myapp, pid: 15407 java.lang.illegalstateexception: not execute method of activity @ android.view.view$1.onclick(view.java:3996) @

swift - NSURLConnection The certificate for this server is invalid -

recently i've been trying connect test server of mine using self-signed ssl certificate using nsurlsession.sharedsession().datataskwithrequest() now error: the certificate server invalid. might connecting server pretending “...” put confidential information @ risk. i've been searching web how solve it. of them advised using 1 of these: func connection(connection: nsurlconnection, canauthenticateagainstprotectionspace protectionspace: nsurlprotectionspace) -> bool func connection(connection: nsurlconnection, didreceiveauthenticationchallenge challenge: nsurlauthenticationchallenge) func connection(connection: nsurlconnection, willsendrequestforauthenticationchallenge challenge: nsurlauthenticationchallenge) func urlsession(session: nsurlsession, didreceivechallenge challenge: nsurlauthenticationchallenge, completionhandler: (nsurlsessionauthchallengedisposition, nsurlcredential!) -> void) now, when ran app noticed func connection(connection: nsurlconne

php - Slim - Swift Mailer on the route is work but if after moved on controller get errors -

i add libraries slimcontroller , swift mailer in slim project, when in route goes well: route::get('/send', function() use ($app, $mailer) { $message = swift_message::newinstance('activation code') ->setfrom(array('xxx@gmail.com' => 'xxx')) ->setto(array('xxxs@gmail.com' => 'xxxs')) ->setbody('test'); // send message $results = $mailer->send($message); // print results, 1 = message sent! print($results); }); but after run on controller there error class mycontroller extends \slimcontroller\slimcontroller { public function getregisters() { $data = (empty(\session::flash())) ? array( 'token' => \token::gettoken() ) : array_merge(\session::flash(), array( 'token' => \token::gettoken() )); return $this->render('auth/register.html', $data); } public

java - ArithmeticException division by zero... how to fix this method? -

the purpose of method iterate through 2d array of integers called grid[][], , translate integers based on maximum , minimum values smaller range between 100 , 250 (the original minimum value becomes 100, original maximum value becomes 250, , in between calculated respectively). when method called, division 0 arithmeticexception occurs. clearly i'm making logic mistakes here... don't see fix. can help? public int greenvalues(int arrayval) { int max = 0; int min = 0; int colorvalue = 0; int temp; (int = 0; < grid.length; i++) { // finds maximum , minimum numbers in file (int j = 0; j < grid.length; j++) { if (max < grid[i][j]) { max = grid[i][j]; } if (min > grid[i][j]) { min = grid[i][j]; } } } int arrayrange = (max-min); // arrayval, arrayrange, , max , min 0 temp = (((arrayval-min) * color_range) / arrayrange)

mysql - Convert SQL Query into C# -

i have following sql query: select s.name, count(sc.id) classes students s left join studentsclasses sc on s.id = sc.studentid group s.name having count(sc.id) = 0 order count(sc.id); that query gets count of students classes , returns students least classes. how can convert c#? attempt not yield expected result. have: var query = (from students in ent.students join classes in ent.studentsclasses on students.id equals classes.studentid gj subpet in gj.defaultifempty() select new { students.name }).tolist(); however returns names of students registered in courses. ================================ here tables: ================== studentsclasses ---------------- id (registration id of class) studentid (id of student taking class) classid (id of class) ---------------- ================== students --------------- id (id of student) name (name of student) gradelevelid (grade of student) -----

excel - In Perl, how can I copy a subset of columns from an XLSX work sheet to another? -

Image
i have .xlsx file (only 1 sheet) 15 columns. want read specific columns, let's columns 3, 5, 11, 14 , write new excel sheet. in case cells of input files empty means don't have value. here trying: use warnings; use strict; use spreadsheet::parsexlsx; use excel::writer::xlsx; $parser = spreadsheet::parsexlsx->new; $workbook = $parser->parse("test.xlsx"); if ( !defined $workbook ) { die $parser->error(), ".\n"; } $worksheet = $workbook->worksheet('sheet1'); # here don't know how define row , column range specific column data. # trying data in array, can write in new .xlsx file. # function write data in new file sub writetoexcel { @fields = @_; $workbook = excel::writer::xlsx->new( 'report.xlsx' ); $worksheet = $workbook->add_worksheet(); $row = 0; $col = 0; $token ( @fields ) { $worksheet->write( $row, $col, $token ); $col++; } $row++; } i followe

ios - TextField not being added to ScrollView -

when input following code, textfields added not being displayed in scrollview: .h @interface firstviewcontroller : uiviewcontroller <uiscrollviewdelegate> @property (strong, nonatomic) iboutlet uiscrollview *scrollview; @property (strong, nonatomic) uitextfield *firstfield; @property (strong, nonatomic) uitextfield *secondfield; @property (strong, nonatomic) uitextfield *thirdfield; .m (viewdidload) self.firstfield.placeholder = @"first"; self.firstfield.textalignment = nstextalignmentcenter; self.firstfield.font = [uifont fontwithname:@"helvetica neue light" size:50.0]; self.secondfield.placeholder = @"second"; self.secondfield.textalignment = nstextalignmentcenter; self.secondfield.font = [uifont fontwithname:@"helvetica neue light" size:50.0]; self.thirdfield.placeholder = @"third"; self.thirdfield.textalignment = nstextalignmentcenter; self.thirdfield.font = [uifont fontwithname:@"helvetica neue light"