Posts

Showing posts from January, 2012

Amazon Cloud Watch Maintenance Window -

we pushing metric cloud watch , create alarm when value goes below value. the problem have maintenance causes metric drop don't want alarm during maintenance window. i can't see way of doing besides disabling alarm during maintenance window. there better way of doing this? can maintenance window specified?

@decorators in Python: why the inner defined function? -

i'm starting python , have been exposed decorators. wrote following code, mimicking seeing, , works: def decorator_function(passed_function): def inner_decorator(): print('this happens before') passed_function() print('this happens after') return inner_decorator @decorator_function def what_we_call(): print('the actual function called.') what_we_call() but wrote this, throws errors: def decorator_function(passed_function): print('this happens before') passed_function() print('this happens after') @decorator_function def what_we_call(): print('the actual function called.') what_we_call() so, why need have inner nested function inside decorator function? purpose serve? wouldn't simpler use syntax of second? not getting? the funny thing both have same (correct) output, second on has error text well, saying "typeerror: 'nonetype' object not callable...

ruby - Pick two different items randomly from an array -

in fighting program, have 2 players in array: players = [brad, josh] i want randomly select 2 distinct players, 1 of attack other, schematically this: random_player.attack(other_random_player) i want make sure players never attack themselves. if do: players[rand(0..1)].attack(players[rand(0..1)]) there chance 1 player fight itself. how make once first player chosen , fights remaining player(s) array? you use .sample : match = players.sample(2); match[0].attack(match[1]); this randomly pick 2 players array, have them fight each other. there no way same player picked both. more cleanly: p1, p2 = players.sample(2) p1.attack p2

Javascript and google Chrome -

when i'm executing javascript code in loop on google chrome console, every javascript things on page not work because i'm on loop. there way have infinite loop on script , continue have web page working fine ? have use kinds of threads ? thanks, xavier no, don't have multiple javascript threads in browser window. if executing tight loop, browsers may either lock because javascript process freezes ui, or may detect loop , kill it. chrome this, , newer versions of internet explorer. if browser did not intervene , allow user kill script other methods killing process or restarting machine. (tight loop example: while(2+2!==5); ) if want things @ regular intervals - animation - use setinterval call function every many milliseconds. can in loop maintaining simple loop counter. example: function blink(el) // millenials won't { el.blink_visible = !el.blink_visible; el.style.visibility = el.blink_visible ? 'visible' : 'hidden'...

javascript - AngularJS Filter Array with Array -

i trying use ng-repeat filter, can't seem working. html: <li dnd-draggable="item" ng-repeat="item in items| filter: integratefilter"> </li> filter: $scope.integratefilter = function (item) { return !$scope.integratesinput ? item : (item.type == $scope.itemtypes[0].type); }; the structure of data: $scope.itemtypes array of types want filter with: products: array[2] 0: object type: "food" 1: object type: "beverage" the "items" in list array of objects like: 0: object name: "steak" type: "food" so want filter items array ($scope.itemtypes). filter i'm using right returns 1 result (0) beginning of array. there way use filter this? or need loop through $scope.itemtypes? thanks

python - Lookup value inside dictionary-of-dictionary -

i'm creating python application input twitch emote name, , spits out link image. (i.e.; if input "kappa", result link this ) can use api emote name , id, entries in returned json formatted such: "id":{"code": "emote name","channel":"channel name", "set":"set number"} what want dictionary such: {"emote name": "id", "emote name": "id"...} i've tried plenty of methods (parsing xml, key-value pairs), , nothing has worked. here's code far: import requests r = requests.get("http://twitchemotes.com/api_cache/v2/images.json") # here, i'd handle json response; don't know how. query_name = input("enter emote name:") k,v in emote_dict.items() if k == query_name: response = "http://static-cdn.jtvnw.net/emoticons/v1/" + v + "/1.0" print("here go: " + response) how using dict compreh...

angularjs - Angular Ui router - parameters disappearing from URL when anything on page causes a digest -

i have strange problem ui-router. have stripped code relating ui-router page, remains config code... app.config(function ($stateprovider, $uiviewscrollprovider, $urlrouterprovider, $locationprovider, appconfig) { 'use strict'; $urlrouterprovider.otherwise("/search"); $stateprovider .state('search', { url: "/search?locationtext?&method?&page?", templateurl: "templates/searchresults.tpl.html", controller: 'searchresultsctrl searchresults', reloadonsearch : false }) }); so, when go url domain.com/page automatically changes url domain.com/page#/search want do. unfortunately when click on on page triggers digest cycle (e.g. open modal, click menu item) after # disappears url, bizarre. no other code in app router. code on page runs when click doing entirely unrelated routing. has seen before? ...

mysql - My SQL Command takes too long, any simplification? -

i have table (player) of following columns: playerid varchar(20) mmr int(10) rank int(10) there 500k~ rows @ moment. now want update rank column of top 10k players. so created following sql command start transaction; update player set player.rank = 10001 player.rank < 10001; set @rank := 0; create temporary table if not exists tmprank (select @rank := @rank + 1 rank, playerid, mmr player order mmr desc limit 10000); update player, tmprank set player.rank = tmprank.rank player.playerid = tmprank.playerid; commit; sadly command takes 25 seconds complete, set indices on playerid , mmr , , rank . can me simplify command or suggest how improve piece of code? best regards edit #1 table player : column typ null standard ----------------------------------------------------------- playerid (primärschlüssel) varchar(20) nein name varchar(16) nein password ...

backbone.js - "Load" event in "events" property of Backbone View -

normally event can listen in jquery can listen in backbone. in other words, if have: var myview = backbone.view.extend(); var view = new myview(); view.$el.html('<button>'); var onclick = function() { alert('woot!'); }; and want trigger onclick when button clicked, could do: $('button').on('click', onclick); but because i'm using backbone i'd instead do: var myview = backbone.view.extend({ events: {click: onclick} }); however, doesn't work load event of iframes, if have: view.$el.html('<iframe src="www.stackoverflow.com"></iframe>'); var onload = function() { alert('woot!'); }; i can do: $('iframe').on('load', onload); but can't do: events: {load: onload} my question two-part: 1) why doesn't work, , 2) there way work around it, still use backbone's events instead of raw jquery? the events in events attached using dele...

javascript - Why isn't chrome.pageCapture.saveAsMHTML working in my Google Chrome Extension? -

in google chrome extension, background.js defines function: function submitmhtml() { console.log("entered submitmhtml()"); chrome.tabs.query( {active: true, lastfocusedwindow: true}, function(array_of_tabs) { if (array_of_tabs.length > 0) { var tab = array_of_tabs[0]; console.log("submitmhtml() found active tab has id of " + tab.id); chrome.pagecapture.saveasmhtml( tab.id, function(mhtml) { var xhr = new xmlhttprequest(), formdata = new formdata(); formdata.append("mhtml", mhtml); formdata.append("surveyid", localstorage["id"]); xhr.open("post", "http://localhost:3000/task/mhtml", true); xhr.setrequestheader('authorization', 'token token=<redacted>'); xhr.send(formdata); console.log("submitmhtml() sent mhtml server"); } ...

python - Redis-py Sentinel ConnectionError race condition during failover -

i'm having issues redis-py sentinel in high-availability asynchronous work queue project design. starters, here's code (simplified): from redis.sentinel import sentinel sentinel = sentinel(sentinels=sentinel_hosts, socket_timeout=0.1) r = sentinel.master_for('redis-sentinel-cluster') while true: item = r.rpop('work-queue') if item none: break else: # work on item continue now, stands, redis-py has retry logic in determining redis connection use. basically, if socket fails, try , new one: https://github.com/andymccurdy/redis-py/blob/master/redis/sentinel.py#l44-l45 https://github.com/andymccurdy/redis-py/blob/master/redis/sentinel.py#l99-l108 and requests current master existing sentinels: https://github.com/andymccurdy/redis-py/blob/master/redis/sentinel.py#l204-l223 this works fine long outage (and new master election) completed before next redis call attempt. however, if redis failure occurs—and s...

Issue of memory exceed when update array values in loop in php -

the situation have array of 15000 records , each record have 67 key-value paired values. want update values using trim, str_replace or type-cast, error of php memory leak. don't understand why happening. array format this array ( [0] => array ( [id] => 1 [parent_id] => 1 [login] => 123 [login_nickname] => [password] => 123 [subuser] => 0 [subuser_id] => [email] => usersemail@email.com ), [1] => array ( [id] => 1 [parent_id] => 1 [login] => 123 [login_nickname] => [password] => 123 [subuser] => 0 [subuser_id] => [email] => anotheruser@email.com ) ) in array have fields comments, address , want them trim, str_replace, fields branches(array) want type-cast in object. when error of memory e...

php - How do I display data from different tables with a single query? -

**how display data below 1 query?** //limit 2 , order date , date2. data tabel | 1 | aaa | 2014-06-16 16:29:51 data tabel b | 1 | aa2 | 2014-06-16 16:29:52 table +-------+--------+------+-----+---------+----------------+ | field | type | null | key | default | | +-------+--------+------+-----+---------+----------------+ | id | int(3) | no | pri | null | auto_increment | | name | varchar(3) | yes | | null | | | date | datetime | yes | | null | | +-------+-------------+------+-----+---------+----------------+ table b +-------+--------+------+-----+---------+----------------+ | field | type | null | key | default | | +-------+--------+------+-----+---------+----------------+ | id | int(3) | no | pri | null | auto_increment | | name2 | varchar(3) | yes | | null | | | date2 | datetime | yes | | null | | +-------+------------+-...

certificate - Java's SHA1 deprecation plan -

microsoft ceases trust code signing certificate use sha-1 january 2016 ( https://www.comodo.com/e-commerce/sha-2-transition.php ). not able find such reference or deprecation policy sha-1 java. if can provide relevant pointers helpful.

yii - Yii2 GridView hide column conditionally -

i displaying columns in yii2 gridview widget, 'executive name' 1 of should displayed when supervisor logged in not when executive logged in. when hard coding visible 0 not displaying follows: [ 'label' => 'executive name', 'attribute' => 'cs.first_name', 'visible' => '0', ], but want display conditionally this: [ 'label' => 'executive name', 'attribute' => 'cs.first_name', 'visible' => function ($data) { if ($data->hc_customersupport->is_supervisor) { return '1'; // or return true; } else { return '0'; // or return false; } }, ], please tell if approach correct. yii\grid\datacolumn extended yii\grid\column has visible property. can see docs, accepts boolean values, of course can dynamically calculate passing expression returning boolean value. example ...

How to add new column to MySQL table without listing other existing columns -

say have mysql table has 100 columns. now, know if wanted have new column has sum of values of 2 columns use sum function on 2 columns after select , have list names of other 100 columns. there way have table has 100 columns plus sum function without listing columns after select . select c1+c2, c1, c2, c3, c4,...,c100 columns try: select c1+c2, t.* columns t

apache - Using Regular Expression in updating an argument in Mod Security Core Ruleset OWASP -

i ran problem rule 981173 [msg "restricted sql character anomaly detection alert - total] sending youtube ids database. ids has special characters - , guess reason warning raised i have been trying exclude $_post key video[391][] rule, 391 product id , it's not fix key. can video[500][] or alike. i have tried secruleupdatetargetbyid 981173 !args:video[*][] but isn't working. idea on how excluding dynamic $_post key rule? message: access denied code 403 (phase 2). pattern match "([\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\+\\=\\{\\}\\[\\]\\|\\:\\;\"\\'\\\xc2\xb4\\\xe2\x80\x99\\\xe2\x80\x98\\`\\<\\>].*?){4,}" @ args_names:video[391][]. [file "/etc/httpd/crs-tecmint/owasp-modsecurity-crs/base_rules/modsecurity_crs_41_sql_injection_attacks.conf"] [line "159"] [id "981173"] [rev "2"] [msg "restricted sql character anomaly detection alert - total # of special characters exceed...

c# - Serializing to disk sometimes fails on Android, but on iOS works fine (Unity3d) -

i'm using binary formatter , writing disk save game state. on ios works perfectly, no issues @ all. on android on other hand fails. progress lost, 2 variables lost, 2 others saved, goes bonkers. what might issue? here code serialize/deserialize: // path file private static string savefilename = "047.bin"; // deserialization function public globalstate(serializationinfo info, streamingcontext ctxt) { lastbosskilled = (int)info.getvalue("lastboss", typeof(int)); currentlyselectedspells = (spelltype[])info.getvalue("spells", typeof(spelltype[])); learnedtalents = (int[])info.getvalue("talents", typeof(int[])); talentpointsavailable = (int)info.getvalue("talentpoints", typeof(int)); } //serialization function. public void getobjectdata(serializationinfo info, streamingcontext ctxt) { info.addvalue("lastboss", lastbosskilled); info.addvalue("spells", currentlyselectedspells); i...

cakephp - Anonymous functions not working in PHP 5.5.x -

Image
so, here small code snippet project if (!empty($user['industryuser'])) { $user['industryuser'] = array_filter($user['industryuser'], function ($ku) { $k = !empty($ku['industry']['name']) ? trim($ku['industry']['name']): ''; return $k != ''; }); $userindustries = array(); foreach ($user['industryuser'] $ku) { $userindustries[] = $ku; } $user['industryuser'] = $userindustries; } this code present inside model named user.php . , there shell script named fetchindustriesshell.php inside app/console/command , makes use of model. when run script command line, cake fetchindustries , following error parse error: syntax error, unexpected t_function in d:\wamp\www\industry-svn\ app\model\user.php on line 203 where line 203, anonymous function defined(line 2 code snippet). what tried is 1) run phpinfo() inside bootstrap.php verify php version. s...

jquery - Recommended way to handle Thymeleaf Spring MVC AJAX Forms and their error messages -

what recommended way handle ajax forms , error messages on thymeleaf side of things? i have spring controller returns json overview of fields , respective error messages, having resort using handwritten jquery (or regular javascript) feels bit wrong, , slow; because of large amount of forms intend have in application. what replace entire form when error occurs. following super primitive example. i'm not going use ton of fragments rendering form... keeping simple. this written in spring 4.2.1 , thymeleaf 2.1.4 a basic class representing user info form: userinfo.java package myapp.forms; import org.hibernate.validator.constraints.email; import javax.validation.constraints.size; import lombok.data; @data public class userinfo { @email private string email; @size(min = 1, message = "first name cannot blank") private string firstname; } the controller: usersajaxcontroller.java import myapp.forms.userinfo; import myapp.services.userservices; i...

php - Two LIKE concate with Two Limits in sql -

i fetching data server this: $con = mysqli_connect($servername, $username, $password, $dbname); $sql2 = "select * story category concat('%' ,'worldlist', '%') order idstory desc limit 20"; $result2 = mysqli_query($conn, $sql2); mysqli_query ($con,"set character_set_results='utf8'"); while($finalresult=mysqli_fetch_assoc($result2)){} now want data of category : $conn = mysqli_connect($servername, $username, $password, $dbname); $sql2 = "select * story category concat('%' ,'worldlist', '%') order idstory desc limit 20 , concat('%' ,'worldtop', '%') order idstory desc limit 1,20"; $result2 = mysqli_query($conn, $sql2); mysqli_query ($conn,"set character_set_results='utf8'"); while($finalresult=mysqli_fetch_assoc($result2)){} i know wrong not query how can make possible this.ps: new in php use sql union ...

Requested registry access is not allowed. (mscorlib) -- SQL Server 2014 Upgrade advisor issue -

while running sql server 2014 upgrade advisor against remote sql server 2005, error shows up: could not populate sql instances: system.security.securityexception: requested registry access not allowed it's able connect sql server 2005 database , populating required databases, when i'm tring click run @ last step error occurs. i installed sql server 2012 upgrade advisor in system , tried run against same sql server 2005 database getting same error. however if use sql server 2008 upgrade advisor , connect sql server 2005 i'm not getting error. tool generating pre , post upgrade issues. please me in identifying issue. i'm running tool run administrator option.

Bigcommerce Coupon creation redeem per customer not working -

i trying create coupon code following customer uses settings. code can used unlimited number of customers. setting 0. max uses per customer set 1. with settings first customer applying code can redeem fine other customers sees code expired though expiry set 1 year later. how can make type of coupon code working in bigcommerce? go marketing › coupon codes . existing , sample coupon codes displayed. click create coupon code . fill out coupon code details: coupon code - code entered @ checkout e.g. freeshipping coupon name - name of coupon (for reference) e.g. free shipping on $50 discount type - choose options provided dollar amount off order total dollar amount off each item in order percentage off each item in order dollar amount off shipping total free shipping discount amount - percentage or dollar amount take off (for discount types except free shipping) minimum purhcase optional - minimum amount customer must spend in 1 order able ...

javascript - How to access child elements? -

i using jquery plugin. after rendering in browser, html layout following lines of code. <html> <body> <div class="mce-container-body"> ... <input type="text" id="textedit01"> ... </div> <iframe> <html> ... <input id="submitbuttonid" type="submit" /> <script type="text/javascript"> jquery(document).ready(function ($) { $('#submitbuttonid"').click(function () { var url = "http://localhost:61222/14communityimages/hands.png"; var $container = $(this).parent(); $container.toggle(); $(".mce-container-body input", $container).val(url); tinymcepopup.close(); }); }); </script> ... </html...

reflection - C# Method Attributes -

is there way achieve without injection? topic usercontrol. trying check title , set in attribute. public partial class topic: topicbase { [topic(title = "my topic")] protected override void oninit(eventargs e) { base.oninit(e); } } when attribute null in topicbase.cs protected override void oninit(eventargs e) { var topicattr = attribute.getcustomattribute(this.gettype(), typeof(topicattribute)); //topicattr null here. if (topicattr != null) { settopic(((topicattribute)topicattr).title); } } you checking attribute on type . attribute sits on method . either change query or put attribute on type expected query: [topic(title = "my topic")] public partial class topic : topicbase { }

drag and drop cannot drop in my layer java -

i have problem label when drag it. i'm using jlayerpane. label didn't want dropped layer. code.am wrong code? preview error http://i.stack.imgur.com/vvpa2.jpg http://i.stack.imgur.com/mzh8q.jpg this global variable cursor draggingcursor = cursor.getpredefinedcursor(cursor.hand_cursor); point anchorpoint; private int xoffset; private int yoffset; private jlabel draggy; private string oldtext; and jlabel.event mouse released private void jlabel1mousereleased(java.awt.event.mouseevent evt) { if (draggy != null) { draggy.settext(oldtext); draggy.setsize(draggy.getpreferredsize()); draggy = null; } draggy.setlocation(evt.getx() - xoffset, evt.gety() - yoffset); } and mousepressed event private void jlabel1mousepressed(java.awt.event.mouseevent evt) { jcomponent comp = (jcomponent) evt.getcomponent(); component chi...

php - Yii2: Model 'fields' ignore null values -

yii 2 docs explains can set fields should returned default toarray() . ( http://www.yiiframework.com/doc-2.0/yii-base-model.html#fields()-detail ) theres possibility ignore when contains null values? function fields() { return [ 'email', // ignore if email null. 'fullname', // ignore if fullname null. ]; } try this: function field() { $return = []; if(!empty($this->email)) { $return[] = 'email'; } if(!empty($this->fullname)) { $return[] = 'fullname'; } return $return; }

Run batch "not as administrator" -

my main batch runs several small batch files administrator. need run current user exe il start says "dont run admin" i have tried in mybatch1.bat runas /profile /user:%username% start /wait /min mybatch2.exe this gives me list of "runas"available commands read entire runas /? ; excerption follows: runas usage: runas [ [/noprofile | /profile] [/env] [/savecred | /netonly] ] /user:<username> program ... program command line exe. see below examples examples: > runas /noprofile /user:mymachine\administrator cmd > runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc" > runas /env /user:user@domain.microsoft.com "notepad \"my file.txt\"" note: enter user's password when prompted. read examples above multi-word program usage . note program should command line exe start internal command. hence, runas /profile /user:%username% "start \"\" /wait...

sql server - VARCHAR(MAX) Issue: String or binary data would be truncated -

my problem string or binary data truncated. i tried researching on error , still doesn't solve problem. checked declarations , varchar(max) disable trigger membership.member_id_emergency_contact_tr_critical_change_log on membership.member_id_emergency_contact; disable trigger membership.member_images_tru on membership.member_images; disable trigger membership.member_other_info_tru_critical_change_log on membership.member_other_info; disable trigger membership.member_tr_critical_change_log on membership.[member]; declare @field varchar(max), @new_value varchar(max) declare crit_loop cursor select mccl.field, mccl.new_value membership.member_critical_change_log mccl mccl.member_code = 'mem-ho-2015-0000026' open crit_loop fetch crit_loop @field, @new_value while @@fetch_status = 0 begin exec [membership].[commitcriticalchanges] @field, @new_value,'mem-ho-2015-0000026'; fetch crit_loop @field, @new_value end close crit_loop d...

r - How can I make the loop to count the gene against query id -

i have data frame in r 14 columns , 4.4 million rows. column 1 has query id , column 4 has gene name. i want make data frame can show , how many genes corresponding each query id. i have 44k different query ids , each query have maximum ~100 genes hit csai_contig04661_6 sp o65396 gcst arath 86.03 408 56 1 72 478 1 408 0.0e+00 738.0 csai_contig04661_6 sp q681y3 y1099 arath 22.55 337 244 10 140 474 103 424 8.0e-09 56.6 csai_contig04661_6 sp q9flr5 smc6a arath 24.27 103 66 3 04. jun 249 342 441 4.6e+00 28. sep csai_contig04661_6 sp q9lqi7 gcst arath 24.28 74 47 2 17. aug 300 31 100 8.1e+00 27. jul csai_contig04661_6 sp p56795 rk22 arath 28.95 76 49 4 11. mrz 509 15 87 8.4e+00 27. mrz csai_isotig00001_4 sp q8vze4 pp299 arath 29.63 108 55 5 31. jul 307 10 109 1.6e+00 30. apr i interested in type of output. csai_contig04661_6 gcst 2 y1099 1 smc6a 1 rk22 ...

ios - How to measure the pixels provided in iPhone UI -

currently working on iphone application. find difficulties in fixing ui layouts. is there tool thats measures pixels given in application? ruler in microsoft word or photoshop around application allows me find measurements in app. thanks screen height , width macros: #define screen_width ((([uiapplication sharedapplication].statusbarorientation == uiinterfaceorientationportrait) || ([uiapplication sharedapplication].statusbarorientation == uiinterfaceorientationportraitupsidedown)) ? [[uiscreen mainscreen] bounds].size.width : [[uiscreen mainscreen] bounds].size.height) #define screen_height ((([uiapplication sharedapplication].statusbarorientation == uiinterfaceorientationportrait) || ([uiapplication sharedapplication].statusbarorientation == uiinterfaceorientationportraitupsidedown)) ? [[uiscreen mainscreen] bounds].size.height : [[uiscreen mainscreen] bounds].size.width) these macros give screen_height , screen_width whenever use them current iphone or ipad dev...

ios - Ionic iframe zoom -

i'm using iframe in ionic framework load external website, in able zoom iframe content, current code is: <ion-content class="has-header" overflow-scroll="true" direction="xy" locking="false"> <div class="scroll-wrapper"> <iframe data-tap-disabled="true" onload="loaddone();" sandbox src="{{url}}"></iframe> </div> </ion-content> the css class: .scroll-wrapper { position: fixed; right: 0; bottom: 0; left: 0; top: 0; -webkit-overflow-scrolling: touch; overflow-y: scroll; } i testing in ios (haven't tested on android) , can't scrolling work, played around no success. tried: <ion-content class="has-header" overflow-scroll="true"> <ion-scroll zooming="true" direction="xy" locking="false"> <div class="scroll-wrapper"> <iframe data-tap-disab...

java - Make member public to unit-test it -

i know there many question concerning unit-tests of private members within classes. of them come conclusion having private members need tested design-flaw needs refactoring (e.g. see here ). still have 1 last question: when refactor private members new classes become (public) api-members intended avoid. simplifying our client class polute our api designing new publicly visibly helper-class. of course 1 might write test-code within assembly , make helpers internal we´d ship test-code production-site. i assume there no right answer issue perhaps have great ideas avoid situations? regarding c# there 1 last trick try make class /members internal in assembly test, open assemblyinfo.cs file , make internals visible test-project/assembly adding following attribute: [internalsvisibleto("yourtestproject")] this makes members invisible outside assembly, except sake of test within "yourtestproject"-assembly. more info on attribute can found on msdn ...

javascript - Google sign in API does not work on Mozilla Firefox -

i handling web app requires user sign in using google account gain access core functionalities. when using google chrome works way it's expected work: user clicks "sign in", pop-up opens google sign in form, user signs in, , transferred main page. (good) however when using mozilla firefox 38.0.1, web app cannot used in way because when user clicks "sign in", nothing. literally nothing, not error on console. here login button: //head <meta name="google-signin-client_id" content="{client id}.apps.googleusercontent.com"> //body <button class="g-signin2 login-button" data-onsuccess="onsignin"></button> is there known issue firefox , google sign in api? ok, found solution: followed this . basically, didnt use easy integration of google signin , created custom handler , listeners. kept original buttons because required , added javascript: html <script src="https://apis.googl...

java - Retrieve auto_increment value of multiple rows from MySQL in batch mode -

there mysql table primary key id int auto_increment , need insert multiple rows in batch multiple insert statement, autocommit disabled, following: set autocommit=0; insert dummy(name, `size`, create_date) values('test', 1, now()); insert dummy(name, `size`, create_date) values('test', 2, now()); commit; is possible each generated id, instead of last id. if yes, when each id generated, , how ids via jdbc ? thx. if want retrieve auto_increment keys via jdbc need use jdbc features doing ( return_generated_keys , .getgeneratedkeys() ), this: try (connection conn = drivermanager.getconnection(myconnectionstring, "root", "beer")) { try (statement st = conn.createstatement()) { st.execute( "create temporary table dummy (" + "`id` int auto_increment primary key, " + "`name` varchar(50), " + "`size` int, " ...

json - AngularJS $http REST call returns null data (SOLVED) -

i have rest service returns json object. trying make authentication responses empty data. i did notice call asychronous , when user pressing login button makes call before getting username , password. decided use $q constructor in order fix it, problem consists, still returns null data. what doing wrong? thanks in advance. factory angular.module('myapp', ['ngroute']) .factory('user', ['$http', '$q', function($http, $q) { return { login: function(username, password) { var deferred = $q.defer(); $http.post('http://localhost:8080/cashinrestservices_war/rest/user/login', {username: username, password: password}) .then (function(data, status, headers, config){ deferred.resolve(data); }, function(data, status, headers, config) { deferred.reject(data); }) return deferred.promise; } } }]) controller .controller(...

r - Unlisting columns by groups -

i have dataframe in following format: id | name | logs ---+--------------------+----------------------------------------- 84 | "zibaroo" | "c47931038" 12 | "fabien kelyarsky" | c("c47331040", "b19412225", "b18511449") 96 | "mitra lutsko" | c("f19712226", "a18311450") 34 | "paulsandoz" | "a47431044" 65 | "beamvision" | "d47531045" as see column "logs" includes vectors of strings in each cell. is there efficient way convert data frame long format (one observation per row) without intermediary step of separating "logs" several columns? this important because dataset large , number of logs per person seems arbitrary. in other words, need following: id | nam...

Handling different screen sizes (Android) -

Image
since starting android development have have been using following drawable folder structure... drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi now problem this, im testing on 2 different devices lenovo tab s8 - 1980*1200 - xxhdpi nexus 5 - 1080*1920 - xxhdpi the lenovo tabs physical screen-size twice of nexus, both pull images drawable-xxhdpi. this means if build app nexus, when deployed on tab surrounded lots of blank unused space. if develop fit nicely on tab appears blown on nexus. i have read here ( http://www.techotopia.com/index.php/handling_different_android_devices_and_displays ) to add drawable folder name drawable-sw200dp drawable-sw600dp drawable-sw800dp to handle different screen sizes crashes app on nexus. tab fine. can explain why and/or workaround handle different sizes within xxhdpi category? update:- xml layout appears causing proble (fragment_tutorial2.xml)... <relativelayout xmlns:android="http://schemas.android.c...

javascript - convert date from 23-08-2015 00:00:00 to Tue Aug 23 2015 00:00:00 GMT+0530 -

i have date in 23-08-2015 00:00:00 format in controller , pass view using viewdata. want convert date tue aug 23 2015 00:00:00 gmt+0530 format.. possible controller or can convert in view using jquery? can me solve this? in javascript, if create new date object string have, you'll desired format. var testdate = new date("23-08-2015 00:00:00"); console.log(testdate); output: tue nov 08 2016 00:00:00 gmt+0530 (india standard time)

xcode - Changing background color of NSView in Swift 2.0 -

i trying change background color of nsview , have tried 1 of solution outlined in this answer . however, it's not working me. missing here? should use viewwillappear() here or meant ios? related code: class viewcontroller: nsviewcontroller { override func viewdidload() { super.viewdidload() self.view.wantslayer = true } override var representedobject: anyobject? { didset { // update view, if loaded. } } override func awakefromnib() { if self.view.layer != nil { let color : cgcolorref = cgcolorcreategenericrgb(1.0, 0, 0, 1.0) self.view.layer?.backgroundcolor = color } } } p.s - i'm new os x/ios programming , trying figure way out through documentation , existing solutions. using xcode 7 beta 4. import cocoa class viewcontroller: nsviewcontroller { override func viewdidload() { super.viewdidload() view.wantslayer = true vie...

javascript - Create handler for asynchronous code -

i'm trying create async version of eval , i'm looking method of converting or wrapping async operation doesn't supply it's own callback. each 1 of these lines runs time-consuming operation doesn't have handler when it's done. var fs = require('fs') settimeout(function () { throw new error ('hi') }, 3000) settimeout(function () { return 'hi' }, 3000) eval("settimeout(function () { throw new error ('hi') }, 3000)") fs.readfilesync('./package.json', 'utf8') i know fs has "async" counterpart fs.readfile , example i'm interested in how i'd convert sync version async. how craft way of wrapping 1 of these operations? i got close doing using domain module. the normal try / catch wont cut because code asyncronous. try { settimeout(function () { throw new error ('hi') }, 3000) } catch (e) { // no error } however can use domain catch error, this. var domain = r...

java - Trying to print the lesser string from standard input, getting mixed outputs -

import java.util.scanner; public class lesserstring2 { public static void main(string args[]) { scanner r = new scanner(system.in); int y = 0; int result = 0; string s = null; string q = null; while (y < 2) { s = r.nextline(); y = y + 1; q = r.nextline(); y = y + 1; } if (y >= 2){ result = s.compareto(q); } if(result == 0) { system.out.println("the strings equal, please try again."); } else if(result == 1) { system.out.println("lesser is: " + s); } else if(result < 0) { system.out.println("lesser is: " + q); } } } i getting mixed results when try submit 2 different sentences through standard input. instance... c:\users\...>java lesserstring2 how cat jump think lesser is: think c:\users\...>java lesserstring2 jack sprat can eat no fat wife can eat no lean...

JSch for pbrun not working -

i tried execute pbrun using jsch. gets infinite loop. tried same program using jsch site examples execute command. tried session.setpty(true) before session. connect(). still, not working. please help. i've found solution own research. can use pbrun -c option launch pbrun , command output in 1 shot. in case, have passwordless connectivity. pbrun su - username -c 'command'

c++ Producer Consumer Code Design -

i have design producer consumer problem restrictions. struct data{ int id; int value; }; std::list<struct data> g_dataq; class consumer{ void process_data(){ struct data my_data = g_dataq.pop_front(); if(my_data.id == 0){ //consumer 0 }else if(my_data.id == 1){ //consumer 1 } //process data } }; void consume(struct data pdata){ g_dataq.push_back(pdata); } description: producer calling "consume" function. , there can multiple producer/consumer. data consumed current consumer determined data.id . every consumer instantiate class consumer . there 1 consume function. restrictions have: "consume" function has global. there can multiple producer/consumer my main concern having global g_dataq. 1 way resolve having list of list first dimension handles consumer belongs to. my query can done without making q global? thanks in advance.