Posts

Showing posts from August, 2015

php - YouTube channel get current live event url (for scheduled live broadcasts) -

is there option youtube channel feed-like page (xml, json or else) tells if channel has live event right , youtube url of broadcast? i want to channels schedule broadcasts , create events, don't want manually embed them. thank you!!

iis - Redirect from subdomains (pages) to domain iss 8.5 -

please me. need redirect subdomains.site.com site.com subdomains.site.com/page1.html site.com/page1.html . i able redirect subdomains.site.com site.com . can not redirect subdomain page ( subdomains.site.com/page1.html site.com/page1.html ). thank you!

android - AppBarLay's onOffsetChanged outInfinite execution -

mappbarlayout.addonoffsetchangedlistener(new appbarlayout.onoffsetchangedlistener() { @override public void onoffsetchanged(appbarlayout appbarlayout, int verticaloffset) { float percentage = (float) math.abs(verticaloffset) / (float) appbarlayout.gettotalscrollrange(); int color = (int) evaluator.evaluate(percentage, color.white, color.blue); mtablayout.settabtextcolors(color, color); } }); if listener callback add tablayout.settabtextcolors method, callback executed indefinitely. please tell me why? , how use percentage in callback dynamically change title color of tablayout??

c - Why does this program output 8? -

this question has answer here: square of number being defined using #define 11 answers #include <stdio.h> #define abs(x) x > 0 ? x : -x int main(void) { printf("%d\n", abs(abs(3 - 5))); return 0; } why program above output 8 , not 2 while program below outputs 2? #include <stdio.h> int abs(int x) { return x > 0 ? x : -x; } int main(void) { printf("%d\n", abs(abs(3 - 5))); return 0; } short answer "because macro not function". long answer macro parameters expanded text of program, c compiler sees long expression: 3 - 5 > 0 ? 3 - 5 : -3 - 5 > 0 ? 3 - 5 > 0 ? 3 - 5 : -3 - 5 : -3 - 5 > 0 ? 3 - 5 : -3 - 5 in expansion, negative sign applies 3 , not (3-5) , yielding negative 8. although can work around issue placing parentheses around x in macro definition, defining inline functi

Django rest OAuth token on redis -

we planning new chat server our ecommerce django based system. chat server need authenticate user before makes connection. can have private http api validate user auth. but feel http slow. need store user token on redis , chat server directly validates redis. we using https://django-oauth-toolkit.readthedocs.io/en/latest/ token generation. default store token on database. how can make authentication happens on redis server ? is best approach ?

java - FFT Decoder for Audio Signal in Android -

i trying make decoder in android project published https://github.com/rraval/pied-piper have created decoder in python, in python pretty easy using numpy package, in java having hard time. steps used in python includes : def dominant(frame_rate,chunk): w=numpy.fft.fft(chunk) numpy.fft.fftfreq(len(chunk)) peak_coeff = numpy.argmax(numpy.abs(w)) peak_freq = freqs[peak_coeff] return abs(peak_freq * frame_rate) # in hz above code returns frequency of audio data in chunks[ ]. i trying make android code implements same logic. work far given below : public class micreadthread3 extends thread { static final int handshake_start_hz = 8192; static final int handshake_end_hz = 8192 + 512; static final int start_hz = 1024; static final int step_hz = 256; static final int bits = 4; static final int fec_bytes = 4; static final int sample_size=8; boolean callback_done=false; private static final int audio_source = mediarecorder.audiosource.mic; private static final int sample

javascript - Google sheets - make a cell value static, print value in cell on edit -

really hard explain easy question : i want b46 contain same value, if rows added or removed i'm sure there's easy script input given value on edit i'm not sure write thank in advance help! here sample. each time sheet edit, script set value on b46: function onedit(e){ var value = /* value here */ ; var sheet = spreadsheetapp.getactivespreadsheet().getactivesheet(); sheet.getrange("b46").setvalue(value); } beware: script not modify rest of sheet remove old values. example: if add row above row 46, script put value on new b46 cell, not delete old one.

tensorflow - What the meaning of the plot of tensorboard when using Queues? -

Image
i use tensorboard monitor training process , plot good, there plots confuse me. first using_queues_lib.py :(it using queues , multithreads read binary data,reference cifar 10 example ) from __future__ import absolute_import __future__ import division __future__ import print_function import os six.moves import xrange # pylint: disable=redefined-builtin import tensorflow tf num_examples_per_epoch_for_train = 50000 real32_bytes=4 def read_dataset(filename_queue,data_length,label_length): class record(object): pass result = record() result_data = data_length*real32_bytes result_label = label_length*real32_bytes record_bytes = result_data + result_label reader = tf.fixedlengthrecordreader(record_bytes=record_bytes) result.key, value = reader.read(filename_queue) record_bytes = tf.decode_raw(value, tf.float32) result.data = tf.strided_slice(record_bytes, [0],[data_length])#record_bytes: tf.float list result.label = tf.strided_slice(record_bytes, [d

java - Spring Maven + IntelliJ and 404 -

so, today decided try out intellij idea. after setting tried make simple spring webmvc project. and spring application, i'm @ point don't have errors or warnings 404 page when run project... tomcat 9 runs without warnings or errors , java seem have no problems. running open browser way way common 404 - resource not found error. springtest.xml <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.clomez</groupid> <artifactid>springtest</artifactid> <version>1.0-snapshot</version> <packaging>war</packaging> <dependencies> <dependency> &l

android - RecyclerView with checkbox checks all items in subcategories of same index value -

i have recyclerview lists number of items , clicking on1 item opens dialog subcategories of item.each subcategory has checkbpx it.the problem when click on 1 checkbox , click ok , go select category item of same index in subcategory checked.this code dialog box lists subcategories @override public void onclick(view view) { switch (view.getid()) { case r.id.bt_ok: // updatecatagory(); (int = 0; < mysubcatagoryadapter.catagory_list.size(); i++) { if (!mysubcatagoryadapter.ischecked) { // mysubcatagoryadapter.removehash.get(i).; //mysubcatagoryadapter.removehash.clear(); mysubcatagoryadapter.removehash.remove(i); } } finish(); } } this adapter public class customrecycleviewadapter_language extends recyclerview.adapter<customrecycleviewadapter_language.mylanguageviewholder> { private context context; public arrayli

.net - Dealing with potentially null datetime value in a SQLParameter -

i trying thought pretty straightforward thing, having issue. have code in .net application insert new record table using sqlcommand. i passing in either datetime value or null. code below doesn't seem work though: command.parameters.addwithvalue("@settledate", iif(string.isnullorempty(settledate), nothing, datetime.parse(settledate))) where "settledate" string containing date null. think code cover condition of not attempting parse null value, when ran following error looks datetime.parse method: string reference not set instance of string. parameter name: s how be? if "settledate" null should never reach parse method. you should use short circuit opertator of vb.net dbnull.value if(string.isnullorempty(settledate), dbnull.value, datetime.parse(settledate))) the if operator , contrary iif function doesn't try evaluate both sides of expression if first 1 true. note pass null value sqlparameter use dbnull.value .

Improve performance of NGINX Server on a Worker Node -

i have deployed 10 nginx servers on single worker node using docker services. 10 services 1 machine- each service giving me x performance. when remove 9 of services, performance of 1 service remaining still x. 1 service 1 machine - still giving me same x performance. why isn't performance of service running improving upon me removing other services? i testing performance using apache benchmark:'ab -n 1000 -c 10 ', looking @ requests per second. remain around 1200, whatsoever configuration of worker node use.

windows - Installed Anaconda 4.3.1 (64-bit) which contains Python 3.6 but pip3 missing, cannot install tensorflow -

i downloaded latest stable anaconda install off continuum website turned out anaconda 4.3.1 (64-bit) , comes python 3.6.0. in windows 10 environment. however pip3 missing , cannot install python 3.x packages via pip3. what doing wrong? if not have environment installed python 3+ default pip believe since pip3 alias pip. pip install --upgrade pip or can associated python binary too; if executable python3, use that: python3 -m pip install --upgrade pip after check: pip --version otherwise try pip-3.6 for tensorflow on conda: pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.1-cp35-cp35m-win_amd64.whl for python 3.6 due conda providing 3.5 one: from pip install https://testpypi.python.org/packages/db/d2/876b5eedda1f81d5b5734277a155fa0894d394a7f55efa9946a818ad1190/tensorflow-0.12.1-cp36-cp36m-win_amd64.whl since wheel had version undesirable instead install wheel directly gohlke's

php - How to use comaprision in this case -

if(isset($_post["request"])){ $email = $_post['email']; $p_name = $_post['p_name']; $noc = $_post['noc']; $year = $_post['year']; $get_email = "select email book email = '$email' "; $run_email = mysqli_query($con,$get_email); $check = mysqli_num_rows($run_email); if($check==1){ echo "<script>alert('you have booked') </script>"; exit(); } $get_name = "select capacity party type_party='$p_name' "; $run_name = mysqli_query($con,$get_name); $checkk = $run_name > '$noc'; if(checkk){ echo "<script>alert('out of bound') </script>"; exit(); } how compare capacity party table value of $noc?? please me out. thank you! you have missed $ in last condition. <?php $email = $_post['email']; $p_name = $_post['p_name']; $noc = $_post['noc']; $y

HTML Drop down Default Error while using Laravel -

Image
while i`m creating crud operations using laravel 5 .it give following error here view.blade.php <select class="form-control"> <option selected="selected">select institute</option> <option name="institute" value="university of moratuwa">university of moratuwa</option> <option name="institute" value="university of peradeniya">university of peradeniya</option> </select> can me solve

php - How can i make the call better Trading API -

i trying build monitor ebay store.. dont know recommended way work trading api. found on internet can make call in curl tried this: $xml = '<?xml version="1.0" encoding="utf-8"?>'. '<getebayofficialtimerequest xmlns="urn:ebay:apis:eblbasecomponents">'. '<requestercredentials>'. '<ebayauthtoken>'. 'xxxxxxxxxxxxxxxxxx'. '</ebayauthtoken>'. '</requestercredentials>'. '<errorlanguage>en_us</errorlanguage>'. '<warninglevel>high</warninglevel>'. '</getebayofficialtimerequest>'; $headers = array( 'content-type: text/xml', 'x-ebay-api-compatibility-level: 967', 'x-ebay-api-dev-name: xxxxxx', 'x-ebay-api-app-name: xxxxxx', 'x-ebay-api-cert-name

networking - How to set position and orientation of nodes displayed in NAM using TCL code? -

Image
using ns2 , nam, want display tree topology containing many nodes. how set position of nodes , orientation displayed in image. first image shows before editing , changing position of nodes in nam tool. second image displays after editing node position manually using nam tool. want see nodes position displayed in second image. not want edit manually. how write tcl code ? here tcl code #create simulator object set ns [new simulator] $ns color 1 green $ns color 2 red $ns color 3 blue $ns color 4 magenta #tell simulator use dynamic routing $ns rtproto dv set tracefile [open out.tr w] $ns trace-all $tracefile #open nam trace file set nf [open out.nam w] $ns namtrace-all $nf #define 'finish' procedure proc finish {} { global ns tracefile nf $ns flush-trace #close trace file close $nf #execute nam on trace file exec nam out.nam & exit

Swapping two integers using pointers using c -

i trying swap value of 2 integers using pointers, see code below: swapping number using pointer in c: { int = 10; int b = 20; swapr(&a, &b); printf("a=%d\n", a); printf("b=%d\n", b); return 0; } void swapr(int *x, int *y) //function { int t; t=*x; *x=*y; *y=t; } in code why swap(&a, &b); used when *x , *y point value not address when (int *x, int *y) you're declaring x , y pointers. in future usages, when x , means pointer , when *x , means value points to.

apigee - Is there any alternative for API chaining? -

i looking alternative api-chaining work in apigee older version. migrating api-proxies apigee cloud apigee older version, stuck in migration api-chaining not working in apigee. as creator of api chaining, can apigee cannot it. the reason being api chaining(tm) relies on new api pattern abstracts communication layer business logic solving architectural cross cutting concern caused old api pattern in distributed architectures. api chaining intended 1 can chain multiple api calls using 1 request/response unless abstract communication layer, backend still have redirect handle each separate api call creating separate request/response each call. you can see more on following videos springone conference videos: https://www.infoq.com/profile/owen-rubel

java - LibGDX button not working properly? -

i confused @ moment. know feeling when app should working fine, isn't reason?! in app's playstate, have 3 states, defined variable "currentstate". currentstate = 0 = running currentstate = 1 = pause currentstate = 2 = game over public class playstate extends state { public static final int tube_spacing = 420; private static final int tube_count = 4; public static spritebatch batch; public static preferences prefs; private array<tube> tubes; private array<coin> coins; private boolean hasbeenplayed = false; private texture pausemenu, coin, bg, grass, gameover; private sound boop, wow, ding; private music failed; private bird bird; private vector2 groundpos1, groundpos2, groundpos3; private playstatebuttons pausebutton; private bitmapfont highscorefont, coinsfont, font120; private viewport viewport; private int score = 0; private int gamestate; private boolean tablevisible, restartvisible; public playstate(gamestatemanager gsm, assetload

c++ - tensorflow Invalid argument: In[0] is not a matrix -

i new tensorflow c++ api , struggling find documentation online. short code performs inner product of 2 vectors w , x1, compile fine there run time errors, copy code , error logs here. lot help #include "tensorflow/cc/client/client_session.h" #include "tensorflow/cc/ops/standard_ops.h" #include "tensorflow/core/framework/tensor.h" int main() { using namespace tensorflow; using namespace tensorflow::ops; tensor w (dt_float,tensorshape({2})); tensor x1(dt_float,tensorshape({2})); auto w_map = w .tensor<float,1>(); auto x1_map = x1.tensor<float,1>(); for(int i=0;i<l;++i) { w_map(i) = -1; x1_map(i) = 1; } std::cout<<"w \n"<<w .flat<float>()<<"\n debug "<<w .debugstring()<<std::endl; std::cout<<"x1 \n"<<x1.flat<float>()<<"\n debug "<<x1.debugstring()<<std::endl; scope r

Issue in regex_replace in Apache Spark Java -

we facing couple of issues 1. "org.apache.spark.sql.catalyst.expressions.generatedclass$generatediterator" grows beyond 64 kb". 2. "java.lang.stackoverflowerror" first issue reported major bug in jira of apache spark https://issues.apache.org/jira/browse/spark-18492 we got these issues following program. trying replace manufacturer name equivalent alternate name, these issues occur when have huge number of alternate names replace, small number of replacements works no issues. datafilecontent=datafilecontent.withcolumn("manufacturersource", regexp_replace(col("manufacturersource"),str,manufacturernames.get(str).tostring())); kindly suggest alternative method or solution go around problem. hashtable manufacturernames = new hashtable(); enumeration names; string str; double bal; manufacturernames.put("allen","apex tool group"); manufacturernames.put(&