Posts

php - Admin SDK -- get information about the group -

please, help. https://www.googleapis.com/admin/directory/v1/groups/106274944935548788283 sending request obtain information group id 1062 ... here link method in google https://developers.google.com/admin-sdk/directory/v1/guides/manage-groups#get_group in response error - 401 unauthorized. oauth authenticate via user has received rights necessary request, included in console admin sdk. authorization successful, there token. not can not understand. if not hard - response. requested information: file_get_contents("https://www.googleapis.com/admin/directory/v1/groups/1062749‌​44935548788283?key=aizasybruhiomdf9nlx9lx3imxwesqmcrnhh4l4"); id group - "106274944935548788283" key applications in case - "aizasybruhiomdf9nlx9lx3imxwesqmcrnhh4l4" error: failed open stream: http request failed! http/1.0 401 unauthorized

ember.js - "template.buildRenderNodes is not a function" on latest Ember release -

html , js (non-minified versions) index.html <!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <!-- <ember> --> <script type="text/javascript" src="assets/lib/jquery/jquery.min.js"></script> <script type="text/javascript" src="assets/lib/ember.js/ember.min.js"></script> <!-- </ember> --> <!-- <app> --> <script type="text/javascript" src="assets/js/templates.min.js"></script> <script type="text/javascript" src="assets/js/app.min.js"></script> <!-- </app> --> </body> </html> app.min.js window.app = ember.application.create(); templates.min.js (the templates compiled using gulp-ember-templates ) ember.templates["index"] = emb...

php - Laravel: validate a integer field that needs to be greater than another -

i have 2 fields optional if both aren't present: $rules = [ 'initial_page' => 'required_with:end_page|integer|min:1|digits_between: 1,5', 'end_page' => 'required_with:initial_page|integer|min:2|digits_between:1,5' ]; now, end_page needs greater initial_page . how include filter? there no built-in validation let compare field values in laravel , you'll need implement custom validator , let reuse validation needed. luckily, laravel makes writing custom validator really easy . start defining new validator in yor appserviceprovider : class appserviceprovider extends serviceprovider { public function boot() { validator::extend('greater_than_field', function($attribute, $value, $parameters, $validator) { $min_field = $parameters[0]; $data = $validator->getdata(); $min_value = $data[$min_field]; return $value > $min_value; }); validator::replacer('greater_tha...

java - How can I change color of button's background -

i have many buttons in calculator app. testing 1 button start, buttons id "one" , should change colour when click blue theme button. have tried following methods: bluetheme = (button) findviewbyid(r.id.bluetheme); bluetheme.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { one.setbackgroundcolor(color.argb(175, 144, 202, 249)); one.setbackgroundcolor(color.parsecolor(/*hex code here*/)); one.setbackgroundcolor(color.blue); } }); nothing seems anything. trying change colour of button in 1 activity via option in activity. here's actual button one : one = (button) findviewbyid(r.id.one); one.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { result.append("1"); } }); xml code of one in activity_main.xml: <button android:id="@+id/one" android:layout_width="wrap_content" android:...

PHP not echoing after file upload completed -

i have simple code upload file using drop zone. it's uploading file fine reason doesn't echo "done uploading" @ end of code. am missing obvious here? <script type="text/javascript"> dropzone.options.mydropzone = { addremovelinks: true, removedfile: function(file) { var _ref; return (_ref = file.previewelement) != null ? _ref.parentnode.removechild(file.previewelement) : void 0; } }; </script> <div id="dropzone"> <form id="mydropzone" action="#" class="dropzone" id="demo-upload"> <div class="dz-message"> drop files here or click upload.<br /> </div> </form> </div> <?php $ds = directory_separator; //1 $storefolder = 'uploads'; //2 if (!empty($_files)) { $tempfile = $_files['file']['tmp_name']; //3 $targetpath = dirname(...

celery - Improve RabbitMQ throughput -

i'm using rabbitmq , celery project , i've reached bottleneck. my architecture follows: 1 rabbitmq node between 1 , 7 nodes read rabbitmq via celery i started performance measurements , pre-populating rabbit 200k messages, node performs 600msg/sec. starting 2 nodes same pre-populated queue, little under 600msg/sec both nodes. adding more node same scenario leads drastic loss in throughput, reaching under 400msg/sec 7 nodes. i've started add settings (some rabbitmq site) lead no improvement. my current settings configuration is [ {kernel, [ {inet_default_connect_options, [{nodelay, true}]}, {inet_default_listen_options, [{nodelay, true}]} ]}, {rabbit, [ {tcp_listeners,[{"0.0.0.0", 5672}]}, {vm_memory_high_watermark, 0.6}, {tcp_listen_options, [binary, {packet, raw}, {reuseaddr, true}, {backlog, 128}, {nodelay, t...

javascript - Function apply with Promises -

i'm working on promise-based project in node.js using bluebird , , in native promises es6. in both, have chain query database in following form: some_function(/*...*/) .then(function () { return query("select `whatever` `wherever` ") }) .then(/*...*/) note query returns promise resolved query result. repeats in several chains, , i'm looking way clean unused function wrapper. i'd naturally use function.prototype.apply() , in case, when try: .then(query.apply(this, ["select * ... "])) .then(function(rows){ /*...*/ }) the next function in chain gets rows undefined . thanks ahead. appreciated. you have pass function reference .then() choices follows: use inline anonymous function are. create own utility function returns function (see example below) use .bind() create function. the inline anonymous some_function(/*...*/).then(function () { return query.apply("select `whatever` `wherever` ...

How - create and use database directly after creation in SQL Server? -

i created sql script check if database exist, if exists deletes , re-creates. after connect directly after creation creating tables .. here code not work. announces error message msg 911, level 16, state 1, line 10 database 'arms2' not exist. make sure name entered correctly. my script if exists (select * sys.databases name = 'arms2') begin drop database arms2 print 'drop database arms2' end create database arms2; print 'create database arms2' use arms2 create table ..... put go statement after create... ... create database arms2; print 'create database arms2' go use arms2

c - Variable isn't storing return value -

i trying make program converts hex string decimal. having issue assigning returned integer value findlength function. going printf statements can tell findlength(thestring) yield correct value length showing value of 0 despite fact have length = findlength(thestring). this isn't homework problem, i'm absolutely stumped why simple assignment isn't working. i've declared length know that's not issue. i'm getting no compiler messages. appreciated. edit: know convert doesn't useful , loop needs fixed shouldn't effecting findlength return right? second edit: i've submitted string of '324' tested. #include <stdio.h> int convert(char s[], int thelength); int findlength(char s[]); int main(){ char thestring[100]; int result; int i; int length; printf("%s","hello, please enter string below. press enter when finished."); scanf("%s",thestring); //apparently scanf b...

xquery - UTC time zones calculation -

departuredatetime:2015-08-15t09:50:00 (gmtoffset=10) arrivaldatetime:2015-08-15t06:30:00(gmtoffset=-7) flightduration= arrivaldatetime-departuredatetime flithtduration =13:40 hours, giving, but how calculating unable understand, according formula giving 13:40 hours,could pls , explain. thanks in advance. 2015-08-15t09:50:00 (gmtoffset=10) = 2015-08-14t23:50:00z 2015-08-15t06:30:00(gmtoffset=-7) = 2015-08-15t13:30:00z = 13h40m i think need brush on time zone concepts bit, because there's nothing wrong calculation itself. if you're feeding bad data return bad results.

performance - numpy count sum of costs for points in same group -

i have vector each point @ index belong group vector[i] vector=np.array([[1,1,4,1,4,3,1]]) i have cost every point: cost=np.array([[10,10,40,1,4,1,2]]) i want compute in efficient way without loops sum of costs each group, point. for example except output: [[23,23,44,23,44,1,23]] for group 1 10+10+1+2 = 23 for group 2 40+4 = 44 for group 3 1 just: counts = np.bincount(vector, weights=cost) output = counts[vector]

ruby - Rescue block did not run in rails migration script -

i have generated following migration: class addmarketstatusidtoproducts < activerecord::migration def change add_column :products, :market_status_id, :integer end end but started raising following error @ heroku: 20150816131733 addmarketstatusidtoproducts: migrating ===================== -- add_column(:products, :market_status_id, :integer) (1.7ms) alter table "products" add "market_status_id" integer pg::undefinedtable: error: relation "products" not exist : alter table "products" add "market_status_id" integer (1.0ms) rollback rake aborted! standarderror: error has occurred, , later migrations canceled: error message quite clear, used following migration script instead: class addmarketstatusidtoproducts < activerecord::migration def change begin add_column :products, :market_status_id, :integer rescue pg::undefinedtable create_table :products |t| t.float :price ...

javascript - How can I make only one column of a table selectable? -

can prevent user highlighting 1 column in table? i have 2-column table. users want copy content in second column, not first column. <table> <tr> <td>col1</td> <td>line1</td> </tr> <tr> <td>col1</td> <td>line2</td> </tr> <tr> <td>col1</td> <td>line3</td> </tr> </table> here's jsfiddle example: http://jsfiddle.net/vepq0e29/ when user copies , pastes, want output be: line1 line2 line3 ... line7 i don't want col1 show or highlighted when user selects table. how can make users can select , copy content second column? thanks! you can use pseudo-elements show text. text pseudo-elements never copied @ moment (not sure, if it'll changed sometime). http://jsfiddle.net/vepq0e29/3/ td:first-child:after { content: attr(aria-label); } <table> ...

Is it possible to get a stack trace for chrome console warning? -

react warned me bad state logic somewhere: warning: setstate(...): can update mounted or mounting component. means called setstate() on unmounted component. no-op. when click line number, points console.warn line in react source code. how can see in code warning coming from? there way stack trace warn ? it's hard track down when there's > 20 distinct components. when inspecting react source code in chrome, can click on line number add break point. once refresh page, debugger halt @ given line , via call stack on right can see how got there.

java - how to monitor progress of uploading file in servlet 3.1 -

i want monitor progress of file getting uploaded m using servlet 3.1 i know specs of servlet 3.1 , don't need apache common fileupload can part class i did this inputstream inputstream = null; double s; string size=null; string contenttype=null; string submittedname=null; string tim=null; string actuallocation=null; system.out.println("getting here"); part filepart = request.getpart("file"); system.out.println("getting here"); if(description.equals("")) { system.out.println("please provide description file"); } else{ if (filepart != null ) { s=(double)filepart.getsize(); double mb=(s/1048576); if(mb != 0) { size=string.valueof((float)mb); contenttype=fil...

vb.net - Creating a console to edit code inside a form VB/C# -

i wondering if me problem. creating home project , wondering if there way of creating console (much in games under esc key) edit lines of code without having close form/application , recomplie it? plus possible in vb or c#? any words of advice or if possible great! thanks in adavance!

c++ - Calling random altered functions based on an original function -

let's have 10 altered functions each original function, same, different process of execution , maths. want call random function out of 10 altered functions instead of original function every time original function supposed used in code. how can , avoid getting 9 other altered functions compiled, not selected random , won't used? this hand out "different" build each receiver unique signature. possible way of doing it, can think of, have folder each original function holds 10 separate include files, each altered function. kinda messy, it's way can think of. if there's easier way of doing, want achieve, please let me know. example adding junk code original function randomly on compiling - better, since it's dynamic. can't imagine of way on how it. here's pseudo: http://pastebin.com/v7hv53ns this problem can divided 2 smaller problems. part 1: determine variant give receiver. equivalent mapping signatures {1,...,10} without colli...

r - Getting specific line from Cash Flow -

i'm trying data cash flow getfinancials function in r. library(quantmod) s <- c("aapl","goog","ibm","gs","amzn","ge") fin <- lapply(s, getfinancials, auto.assign=false) names(fin) <- s but when try specific line with fin$aapl$cf$a["cash operating activities"] fin$aapl$cf$a["capital expenditures"] i na return. how can these specific lines cash flow? since fin$aapl$cf$a matrix, need comma after name because asking row name. without comma asking vector element named "cash operating activities", , since have matrix individual elements not named. class(fin$aapl$cf$a) # [1] "matrix" "cash operating activities" %in% rownames(fin$aapl$cf$a) # [1] true ## no comma - na because "cash operating activities" not named vector element fin$aapl$cf$a["cash operating activities"] # [1] na this can more illustrated with x <- 1 x[...

php - add to deepest array child element -

how select deepest child element multidimensional-array in order add element specific 1 in php (always knowing added, in case additional information parent needed in order create new child)? eg. having array want able add aaaa, bbbb, cccc each: aaa, bbb, ccc? , later on aaaaa, bbbbb,… each aaaa, bbbb… , on (where each new element aware of it's parent's name). array( "a"=> array( "aa"=> array( "aaa", "bbb", "ccc" ), "bb"=> array( "aaa", "bbb", "ccc" ), "aa"=> array( "aaa", "bbb", "ccc" ), ), "b"=> array( "aa"=> array( "aaa", "bbb", "ccc" ), "bb"=> array( "aaa", "bbb", "ccc" ...

Rails - How to Pass Parameter to Different Controller to edit Object -

i have store class want enter in toy id simple form attach toy object store. thing passing through params[:id], not params[:toy_id] store _form.html.erb: <%= form_tag({controller: "toys", action: "update"}, method: "post") %> <%= text_field_tag(:toy_id) %> <%= submit_tag("update") %> <% end %> after clicking submit, should go toyscontroller 2 parameters: 1) params[id] store id , 2) params[:toy_id] toyscontroller=>update: def update respond_to |format| store = store.find(params[:id]) toy = toy.find(params[:toy_id]) toy.store_id = store.id toy.save if @toy.update(toy_params) format.html { redirect_to @toy, notice: 'toy updated.' } format.json { render :show, status: :ok, location: @toy } else format.html { render :edit } format.json { render json: @toy.errors, status: :unprocessable_entity } end end end as using form_tag , have...