Posts

Showing posts from March, 2010

Android ActionBar with AdMob -

i have created application actionbar , actionbar tabs. wish add advertisements in application admob, in actionbar top , bottom. how via code.? if adding actionbar linearlayout, can add admob in part (top,left,right,bottom) of tab bar pages. how achieve this.?

java - Performance Impact of RDD to JavaRDD conversion -

i have code , wan work against javardd instead of rdd i'm doing conversion here. know performance impact of transformation specialy when i'm dealing gbs of data. rdd<string> textfile = sc.textfile(filepath, 2); javardd<string> javardd = textfile.tojavardd(); this wide or narrow transformation ? difference between javardd , rdd ? there's no significant performance penalty - javardd simple wrapper around rdd make calls java code more convenient. holds original rdd ad member, , calls member's method on method invocation, example (from javardd.scala ): def cache(): javardd[t] = wraprdd(rdd.cache()) wraprdd boils down new javardd[t](rdd) , performance penalty creating thin java object every method invocation, that's entirely negligible it's not done per element in rdd, once entire object.

Hypothetically speaking, how could adding a protected variable in a superclass create an error in Java? -

just fun, i'm trying think of scenario in protected variable can cause compilation error. lets had class fruit , class apple inherits fruit. and go ahead , add protected variable x in fruit, causing program no longer compile. happen if how, causing error? x inherited apple without problems. able use inside either fruit or apple . might decide override and/or implement setter and/or getter.

Search xml file and fill HTML table with result in php -

hello every body have xml file showing in html table using simplexml library. want search file records using elements values. here xml file content. <?xml version="1.0" encoding="iso-8859-1"?> <studentslist> <student> <student_id email="test@yahoo.com">18700</student_id> <firstname>jhon</firstname> <lastname>smith</lastname> <address>dragon vally china</address> </student> <student> <student_id email="leesin@gmail.com">18701</student_id> <firstname>lee</firstname> <lastname>sin</lastname> <address>league of legend uk</address> </student> </stuedntslist> i using php right able find specified student searched value of firstname or lastname. have no clue how reset current html table records , fill result of searched value. using following php code searching. $firstname = "lee"; $searched_stu_f

python - How to sum numbers in Dataframe based on length of keywords? -

i have sample of search engine dataframe has 2 columns: entered keyword search , number of searches of keyword. example: df = pd.dataframe({'keyword': ['one','one two','2','two 34 45', 'ab', 'long 1 4 ab'], 'number of searches': ['4', '9', '1', '2', '7', '1']}) i sum how many searches made (not count number of words) keywords consist of 1 word, 2 words, 3 words, etc. final result must like: 1 word: 13 2 words: 9 3 words: 2 4 words: 1 any suggestions? you can way: first, make sure number of searches column of integer data type: df['number of searches'] = df['number of searches'].astype(int) (df.groupby(df.keyword.str.split().apply(len))['number of searches'] .sum() .to_frame() .reset_index() .apply(lambda x: '{0[0]} words: {0[1]}'.format(x), axis=1) ) output: 0 1 words: 12 1 2 words: 9 2 3 w

swift - dynamicType of optional chaining not the same as assignment -

optional chaining returns always optional value. to reflect fact optional chaining can called on nil value, result of optional chaining call optional value, if property, method, or subscript querying returns nonoptional value. the swift programming language why heck in playground type not optional? let stringoptempty: string? = "" stringoptempty?.isempty // true stringoptempty?.isempty.dynamictype // bool.type but following code is let isok = stringoptempty?.isempty.dynamictype isok.dynamictype // optional<bool.type>.type tldr; the playground sidebar/column dynamically resolve expressions in playground, values assigned variables (mutables/immutables) or "free-floating" non-assigned values. your first example applies dynamictype value , resolve type of specific value ( true.dynamictype : bool.type ). your second example, on other hand, applies dynamictype variable (an immutable, i'll use variable here differ val

c++ - Strange Qt include dir structure under OSX -

i experimenting qt headers (for using vim's clang-complete plugin). trying compile simple qt function (note: not supposed work, trying compile it). #include <qwidget> int main(int, char**) { qwidget* a; } i compile with clang try.cpp -o try -dqt_gui_lib -dqt_widgets_lib -isystem/applications/qt/5.6/clang_64/lib/qtcore.framework/headers -isystem/applications/qt/5.6/clang_64/./mkspecs/macx-clang -isystem/applications/qt/5.6/clang_64/lib/qtgui.framework/headers -isystem/applications/qt/5.6/clang_64/lib/qtwidgets.framework/headers and error in file included /applications/qt/5.6/clang_64/lib/qtwidgets.framework/headers/qwidget:1: /applications/qt/5.6/clang_64/lib/qtwidgets.framework/headers/qwidget.h:37:10: fatal error: 'qtgui/qwindowdefs.h' file not found #include <qtgui/qwindowdefs.h> this because qwidgets header has #include <qtgui/...> includes. ok instance in linux installations because folders set in order. in osx, folders have dist

javascript - How to save/clear setTimeout's array using loop's index? -

i calling loop multiple times. save single settimeout each index. idea use loop's index settimeout's array index, settimeout returns incremental id number, reset it, or override take control of returning id, can identify each timeout given index, within range of loop's index executed on , on again. being able use cleartimeout later on specific index. var timeouts = []; for(var i=0; < 5 ; i++) { ... (function(delay, timeouts, i){ // keeps reference of timeout clear later. timeouts[i] = settimeout(function() { countinview--; }, delay); console.log("i: "+5+ " | timeout: "+timeouts[i]); // i: 5 | timeout: 25 -> surpasses index, // i'd override positions id or index. }(delay, timeouts, i)); ... } when loop executed more once, timeouts[i] value surpasses value of loop's index: i want clear timeout in other part of code, when reaching part of code, value of timeouts[i] may 140,

php - MongoDB - Count every record where timestamp <= yesterday -

--solved-- timestamp within quotation marks fix it! i have mongodb instance running on ubuntu test bench. i'm doing harvesting tweets, generate statistics tweeting behavior in amsterdam. 1 of stats want visualize amount of tweets per day. every tweet has timestamp in milliseconds, guess can query on that, right? unfortunately, query made doesn't generate expected outcome: db.testtweets.count({ "timestamp_ms": { "$lte": 1464432361000 } }); the query above returns 0, expected return 196827 (all tweets in db till today). doing wrong? if change query is not null below, returns count of tweets should. db.testtweets.count({ "timestamp_ms": { "$ne": null } }); hope guys can me out make query counts every tweet below timestamp (for example yesterday: 1464354713000). edit full document preview, try url: http://pastebin.com/fddpynx1 in document, value in seconds or milliseconds? timestamp

objective c - How can I achieve luminescent shadows? -

Image
the entire mockup has shadow reminds me of philip's ambilight tvs . look @ "trailer , photos" section tiles have type of shadow. this effect fascinating watch , i'd incorporate app. here's i've thought: take screenshot of view , enlarge 110% place behind view. blur screenshot. apply inner white shadow. any suggestions? your thoughts correct, there no need apply inner shadow, it's possible add transparent insets screenshot, , when blurred, create gradient you're looking for. the following code should job: - (void)addluminescentshadowtoview:(uiview*)contentview { //the bigger radius of blur //the more spread shadow cgfloat blurradius = 15.0f; //in order shadow becomes transparent on edeges //we're adding transparent insets snapshot cgfloat insetssize = 2.0f * blurradius; //getting superview of content view //it's important before getting snapshot //as during snapshot parent

mysql - am getting something like this,"Failed to load resource: the server responded with a status of 404 (Not Found)" -

i getting details of product database. here sample code unable display images of products! can me out please? the code insert product details in database: <!doctype> <?php include("includes/db.php"); ?> <html> <head> <title> inserting product</title> <script src="//tinymce.cachefly.net/4.1/tinymce.min.js"></script> <script> tinymce.init({ selector:'textarea' }); </script> </head> <body bgcolor="skyblue"> <form action="insert_product.php" method="post" enctype="multipart/form-data"> <table align="center" width="700" border="2" bgcolor="orange"> <tr align="center"> <td colspan="7"><h2>insert new post here.</h2></td> </tr> <tr> <td align="right"><b>product title:&

Laravel use array of controller to echo something in view -

i'm new laravel , i'm stuck @ this. code gives me results table $categories = new categories(); $categories = categories::all(); in view got foreach loop values table: categories. so: @foreach($categories $categories) <tr> <td>{{$categories->category_id}}</td> <td>{{ $categories->description }}</td> @endforeach my question is, there way print values seperate? can put anchor before them? have put in array? output must this: 1----<a href="gogsm.php">gsm</a> 2----<a href="gogps.php">gps</a> thanks lot! $categories = new categories(); // line??? $categories = categories::all(); @foreach($categories $category) <tr> <td>{{$category->id}}</td> <td> <a href="{{ yourfunctionthatgeneratesurl($category) }}"> {{ $category->name }} </a> </td> // or suggested in comments &l

javascript - How to export an html table as an xlsx file -

i have question exporting html table xlsx file. did work , can export xls , need export xlsx . here jsfiddle : https://jsfiddle.net/272406sv/1/ here html : <table id="toexcel" class="uitable"> <thead> <tr> <th>kampanya başlığı</th> <th>kampanya türü</th> <th>kampanya başlangıç</th> <th>kampanya bitiş</th> <th style="text-align: center">aksiyonlar</th> </tr> </thead> <tbody> <tr ng-repeat="item in campaign.campaignlist"> <td> item.campaigntitle </td> <td> item.campaignhoteltype </td> <td> item.campaignhotelcheckindate) </td> <td>item.campaignhotelcheckoutdate</td> <td style="text-align: center"> <button> action </button> </td> </tr> </tbody> <

How to translate an ElasticSearch multimatch search query from cURL into JAVA? -

so, having made (right) query in es , tested against local es installation using sense plugin, facing problem: how same code using es java api. here query trying translate: { "size": 5, "query": { "multi_match": { "query": "physics", "type": "most_fields", "fields": [ "document.title^10", "document.title.shingles^2", "document.title.ngrams", "person.name^10", "person.name.shingles^2", "person.name.ngrams", "document.topics.name^10", "document.topics.name.shingles^2", "document.topics.name.ngrams" ], "operator": "and" } } }' i know should this, not quite sure: node node = nodebuilder().client(true).node(); client client = node.client(); searchresponse response =

d3.js - ds3.js Horizontal bar - How to centralise y axis? -

i'm following mike bostock's example produce horizontal bar chart positive , negative values. i'm trying centralise y-axis, there same length of x-axis each side. can't find examples out there. want scale of x-axis remain sensitive data, don't want specify range. i can't example gives work. : for quantitative scale, compute data domain (the minimum , maximum value) using d3.extent: var x = d3.scale.linear() .domain(d3.extent(data, function(d) { return d.value; })) .range([0, width]); nicing scale extend extent nearest round numbers. if want zero-value centered in middle of canvas, take greater of minimum , maximum value magnitude, or hard-code desired domain. any examples of how correctly calculate domain or welcome! first, let's discover 1 greater, minimum or maximum value: var greater; if (math.abs(d3.min(data, function(d){ return d.value})) > math.abs(d3.max(data, function(d){ return d.value}))) {

html - Full Body Overlay With inner divs clickable -

i'm trying add overlay page 100% in size. problem inner divs , buttons not clickable anymore. there way out of this? i used answer here add overlay: css: how overlay extend 100% scrolling? what i'm trying achieve mask add layer/group in photoshop. thanks the overlay, being on layer above of button container, intercepting pointer events. disable them: .overlay { pointer-events: none; }

javascript - $.each and $.getJSON methods to array of links -

after converting array of names in array of url links users online , offline , names closed accounts ["https://link_1","https://link_2",name(for closed account),"https//link_3",...] through $.map method , the .getjson within that. i try apply $.each method condition within again, if element starts "http" applied .getjson method work json object of element (link) , add html values of properties( e.g. html+=json.name); if element doesn't start "http" add value of element (e.g. html+=value). doesn't work; html variable takes index , value within jquery.each, not json object of nested .getjson method. lost? channels=["https://link1","https://link2","name(for closed account)",....]; var html=""; $.each(channels,function(index,value){ // elements links if(value.substring(0,4)=="http"){ $.getjson(value,function(json){ html+=json.name; });

java - After new Controller created i'm getting "Injection of autowired dependencies failed" in Spring MVC , Hibernate -

i have added new controller in spring mvc project , added annotations below ...but here while running project i'm getting 404 exception , in console i'm getting exception below ...i'm confused figure out issue... here controller: @controller @requestmapping("/escprojectprogstatuscontroller") public class escprojectprogstatuscontroller { @autowired escprojectprogstatusservice escprojectprogstatusservice; @requestmapping(value = "/fetchunitnamedropdown") public @responsebody string fetchunitnamedropdown(httpservletrequest request){ string strunitnames = ""; string strprojectid = request.getparameter("projectid")==null?"":request.getparameter("projectid"); try { strunitnames = escprojectprogstatusservice.fetchunitnamefromprojectid(strprojectid); } catch (exception e) { //logger.error(e); throw e; } return strun

A simple variable in swift -

i know basic don't this. want set variable class (uiview) , , later set value, give me error on init method : var cellsize:cgfloat override init (frame : cgrect) { super.init(frame : frame) cellsize=self.frame.size.width then trying : var cellsize:cgfloat cellsize=1.0 super.init(frame : frame) cellsize=self.frame.size.width which compile, , seems wrong . 1 working : var cellsize:cgfloat=1.0 override init (frame : cgrect) { super.init(frame : frame) cellsize=self.frame.size.width which works seems wrong because i'v told him cgfloat why if tell complier cgfloat , won't let me continue without setting value ? all class variable or instance variable should initialised before class instantiated. reason instance of class need class variable , instance variable , without value leads chaos. there need initialise it. swift on other hand provide exception above said conc

ios - How is loading from a remote database typically managed? (conceptually) -

i'm making app, , each view loads differently remote database, each view going have own query. best way manage database access in app? my possible solution: i'm wondering if idea create separate nsobject file functions data controller stored , loaded database. theoretically, have bunch of functions take data database , store arrays. way, of database access code in 1 file, call these functions in files needed. is standard approach? there better / more trivial / more robust approach? i'm looking best way keep code clean, clear, , easy update in future. thanks suggestions! i've done using separate class downloading, not store data. class defines delegate protocol sending data caller. create instance of class in controller needs download something, , have set delegate of download class. have 1 method in class pass in url, , in call methods (i used nsurlconnection), call delegate method passes raw data (or error object) each class can manipulate data i

python - can not deploy django scikit learn project on heroku, slug size too large error -

i trying deploy pet project on heroku, keep getting error: "slug size 314 mb, maximum limit 300 mb". tried purging cache no effect. it's small project, listing requirements.txt file here, if helps. suggestion on deploying appreciated. thank you. requirements.txt django==1.9.6 django-bootstrap3==7.0.1 django-registration-redux==1.4 gunicorn==19.4.5 psycopg2==2.6.1 whitenoise==2.0.6 dj-database-url==0.4.0 conda-requirements.txt numpy scipy scikit-learn using conda buildpack: https://github.com/kennethreitz/conda-buildpack

javascript - calling php from aspx -

i have contact form in aspx page after clicking submit posts php page. see php not being called. when click submit no email sent or when fileds empty nothing happens. form in aspx file: <form action="form-to-email.php" method="post"> <div class="contact-form margin-top"> <label> <span>full name</span> <input type="text" class="input_text" name="name" id="name" /> </label> <label> <span>email</span> <input type="text" class="input_text" name="email" id="email" /> </label> <label>

matlab - Compression of the .mat file -

i need compress .mat file .zip , reduce it's size. it's current size 8mb. compressing .zip doesn't change it's size. tried compressing text file using dlmwrite , zipping. doing achieved 3mb 8, maximum can use 2mb. there way compress file less 2mb? other saving functions?

PHP - Temp File Path is null -

i have script handles file uploads. have uploaded files under 1 mb, when file on 1 mb script seems set temporary file path null. here script below: $total = count($_files['docname']['tmp_name']); for($i = 0; $i < $total; $i++) { // temp file path $tmpfilepath = $_files['docname']['tmp_name'][$i]; // check if have path if ($tmpfilepath != "") { // variables form $foldername = $_post['foldername']; $foldername = stripslashes($foldername); $foldername = mysql_real_escape_string($foldername); //setup our new file path // check if folder name home, if so, set file path folder if ($foldername == "home") { $target_dir = "../../cdn.brmbc.com/usercontent/".$userid."/"; } // if folder name not home, make file go folder else {

machine learning - Calculating TP,FP,TN,FN for multiple class label in decision tree -

i beginner in machine learning , classification, tried code decision tree algorithm prediction of 2 classes.it worked well, problem facing , if try predict more 2 class labels,?? how calculate precision , recall dataset having 5 classes.. came know , can possible calculating precision , recall values classes , taking average of that, can me how need calculate tp,tn,fp,fn if have 5 classes? what false positive on non-binary problem be? you asking not defined. you can compute precision, recall, , f1.

swift - Computed properties cannot store a value but hold a value, what is hold and how to hold? -

quote "swift apprentice second edition page 225": properties(computed) hold values can , set. methods perform work quote "swift official document": in addition stored properties, classes, structures, , enumerations can define computed properties, not store value one says "store", 1 says "hold". bit confused computed properties, computed properties not store value means? means system not assign memory space save value , hold it. what's hold means? can't hold in nowhere, need maybe box hold something, isn't it? simple example documentation struct cuboid { var width = 0.0, height = 0.0, depth = 0.0 var volume: double { return width * height * depth } } volume never stored in memory. whenever getter called result of multiplication returned dynamically math operation in local scope. the official apple documentation not use term hold @ all.

asp.net mvc - What would unhook my View and Controller from each other in Chrome and IE but not in Firefox? -

i have tested mvc functionality in app in chrome have recenlty tested in ie (10) , firefox. when mash submit button on page sends model values controller running query , generating report, works in firefox (each of 3 browser indeed have own peculiar characteristics -- shine or "dull" in relation cohorts (gleaming in purple , gold) -- chrome , firefox seem have lost connection between submit button's click handler , corresponding controller's method. the app seems hang after mashing submit button in chrome , ie; breakpoints have -- first of @ beginning of corresponding [httppost] actionresult in controller class -- not reached. in fact, app seems freeze after mashing button -- right-clicking submit button after not give me "inspect element" in context menu. [httppost] public actionresult receiptcriteria(salesreceiptcriteriamodel model) { if (modelstate.isvalid) // <-- there breakpoint here; firefox reaches {

vb.net - This request is not supported in the specified qbXML version -

i using vb.net 2008, qbfc 12. when try payroll summary report, error. this request not supported in specified qbxml version. the error happens on following line of code: dim payrollsummaryreportqueryrq ipayrollsummaryreportquery payrollsummaryreportqueryrq = requestmsgset.appendpayrollsummaryreportqueryrq() i copied code directly osr sdk. have no idea why won't work. osr says request has been available since sdk v3. best can see, should working. why not?

ios - UICollectionView Cells not shown if UITabBarController is on second tab Swift -

Image
i have weird issue uicollectionview , uitabbarcontroller. inside uitabbarcontroller have references 2 different viewcontrollers. if put view controller has uicollectionview first page of uitabbarcontroller list cells (uicollectionview) loading this: but if put second view controller when open tab uiimageview , uilabel disappearing cells: i have checked collectionview method getting cells , there data printed label , image. here code of methods datasource , delagate // tell collection view how many cells make func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { return self.items.count } // make cell each cell index path func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { // reference our storyboard cell let cell = collectionview.dequeuereusablecellwithreuseidentifier(reuseidentifier, forindexpath: indexpath) as! adscollectionviewce

java - View not added to application -

i confused. action: public class zoppenactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); final hostnamechecker c = new hostnamechecker(); c.execute(this); } } and zoppen_main.xml: <?xml version="1.0" encoding="utf-8"?> <view xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000"> </view> the preview (graphicallayout-tab) has black background, if debug application, there no black background. looks view never added application. what did wrong? you need use setcontentview in activity load view.so add oncreate. public class zoppenactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate

node.js - Update Array Value With Unknown Index Using Mongoose -

this question has answer here: update array object based on id? 2 answers how query , update value in array index of value unknown , array known key of object? example: doc: { _id: 1, stripe: { // need update value id 2, not know index accounts: [{name: 'value1' id: 1}, {name: 'value2', id: 2}] } } i'm not sure of operator/query this. find doc _id 1 >> find account id 2 in doc.stripe.accounts >> update account id 2 this doing now, works, know there better way. querying doc _id , finding index of account want update , replacing stripe value. let obj = doc.stripe.accounts.find(item => { return item.id === params.externalaccountid; }); let index = doc.stripe.accounts.indexof(obj); let arr = doc.stripe.accounts.slice(); arr[index] = item; doc.stripe = object.assign({}, doc.stripe, { accoun

javascript - Google Analytics Doesn't Work on Django Site -

i set google analytics placing tracking script tag , code @ bottom of head tag in base.html template every other page extends from. i created 2 click events when people click on pdf links. none of events showing up. here code. $(document).ready(function() { $(document).on('click', '.cs-link', function() { ga('send', 'event', { eventcategory: 'case study', eventaction: 'click', eventlabel: event.target.href, transport: 'beacon' }); }); $(document).on('click', '.brochure-link', function() { ga('send', 'event', { eventcategory: 'brochure', eventaction: 'click', eventlabel: event.target.href, transport: 'beacon' }); }); }); i'm not sure why doesn't work. page tracking works events don't i'm not sure how tel

objective c - __NSStackBlock__ isEqualToString: issue -

i experimenting this code . in 1 of viewcontroller 's using next snippet: - (bool)textview:(uitextview *)textview1 shouldchangetextinrange:(nsrange)range replacementtext:(nsstring *)text { if([text isequaltostring:@"\n"]) { [textview resignfirstresponder]; return no; } return yes; } i found in web dismissing keyboard pressing returnbutton . works when calling viewcontroller . in root klnoteviewcontroller adding notification in handle state changes-method: - (void) setstate:(klcontrollercardstate)state animated:(bool) animated { [[nsnotificationcenter defaultcenter] postnotificationname:@"refresh" object:self]; if (animated) { [uiview animatewithduration:self.noteviewcontroller.cardanimationduration animations:^{ [self setstate:state animated:no]; }]; return; } //full screen state if (state == klcontrollercardstatefullscreen) { [self expandcardtoful

java - SimpleGrantedAuthority cannot be cast to GrantedAuthority -

the specific error is: exception handling request /login: java.lang.classcastexception: org.springframework.security.core.authority.simplegrantedauthority cannot cast org.springframework.security.core.grantedauthority. update : complete stacktrace error [io.undertow.request] (default task-9) ut005023: exception handling request /login: java.lang.classcastexception: org.springframework.security.core.authority.simplegrantedauthority cannot cast org.springframework.security.core.grantedauthority @ org.springframework.security.authentication.abstractauthenticationtoken.<init>(abstractauthenticationtoken.java:62) @ org.springframework.security.authentication.usernamepasswordauthenticationtoken.<init>(usernamepasswordauthenticationtoken.java:73) @ com.actividades.components.customauthenticationprovider.authenticate(customauthenticationprovider.java:38) @ org.springframework.security.authentication.providermanager.authenticate(providermanager.java:174) @ org.springframew

python - trouble querying an SQL database held on a Flask app - returning "None" in Flask when it returns data when I interact with the database -

Image
i'm working in flask app, , i'm trying set create dynamic webpages based on data in sql database. example, if scrape data criminal, want flask route requests such can type: myflaskapp.com/criminal/[criminal's name]/ and taken page criminal. relevant portion of views.py i've written: @app.route('/criminal/<first_name>') def criminal(first_name): criminal = individual_criminal.query.filter_by(first_name=first_name).first() return render_template('user.html', criminal=criminal) now, when call individual_criminal.query.filter_by(first_name=first_name).first() in python shell, returns expected: however, when set flask server, , (what believe be) exact same command query, gives me blank page (with navbar , stuff extended base html.) the html page i'm trying call simple: <!-- extend base layout --> {% extends "base.html" %} {% block content %} <h1>{{ criminal.full_name

javascript - How do run a command through Google Chrome's console with a hotkey through Tampermonkey -

Image
i have been working on program "slither.io" , in order function correctly every time change servers need run bit of code through google chromes console. (you can open shift+ctrl+j) know possible way send line of code google chromes console , run hotkey. in other words, when on main page of "slither.io", should able press "e" , without having open google chromes console automatically type in , run command in console. if possible, i'd have tampermonkey script this. have not tried on own due fact bad @ programming tampermonkey. if else me appreciate it. :) here picture of command run once "e" pressed: all want set global variable on page when press "e" key. can achieved in javascript in event handler. for example: document.addeventlistener("keypress", function(e) { if (e.which == 101) { window.xhttp = .........; // .... code in screenshot } }); you need inject page via tampermonkey or ch