curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-uninstall.sh | bash -s
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice | |
device = MonkeyRunner.waitForConnection() | |
for i in range(1, 1000000): | |
MonkeyRunner.sleep(0.1) | |
device.touch(692, 1129, 'DOWN_AND_UP') |
if (request.method === 'options') { | |
let response = request.response.isBoom ? request.response.output : request.response; | |
response.statusCode = 200; | |
response.headers['access-control-expose-headers'] = 'content-type, content-length, etag'; | |
response.headers['access-control-max-age'] = 60 * 10; // might be not needed | |
// dynamically set allowed headers & method (this is the important part) | |
if (request.headers['access-control-request-headers']) { | |
response.headers['access-control-allow-headers'] = request.headers['access-control-request-headers'] | |
} |
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
// Refer to https://gist.github.com/remy/350433 | |
try { | |
// Test webstorage existence. | |
if (!window.localStorage || !window.sessionStorage) throw "exception"; | |
// Test webstorage accessibility - Needed for Safari private browsing. | |
localStorage.setItem('storage_test', 1); | |
localStorage.removeItem('storage_test'); | |
} catch(e) { | |
(function () { | |
var Storage = function (type) { |
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem | |
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem | |
// to avoid the entire page breaking, without having to do a check at each usage of Storage. | |
if (typeof localStorage === 'object') { | |
try { | |
localStorage.setItem('localStorage', 1); | |
localStorage.removeItem('localStorage'); | |
} catch (e) { | |
Storage.prototype._setItem = Storage.prototype.setItem; | |
Storage.prototype.setItem = function() {}; |
// --- Compiling --- | |
$ wget http://download.redis.io/releases/redis-3.0.7.tar.gz | |
$ tar xzvf redis-3.0.7.tar.gz | |
$ cd redis-3.0.7 | |
$ make | |
$ make install | |
// --- or using yum --- | |
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | |
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm |
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.
JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.
Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new
. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date
requires new Date()
you are probably very new. We have adopted Upper Camel Case variable names for all module global variables
#!/bin/sh | |
# This will allow you to rebalance the Cassandra ring | |
# Accepts hosts from stdin and automatically rebalances | |
# tokens in your ring. | |
# | |
# $ echo "one two three" | ./rebalance.sh | |
RING_SIZE=$(echo "2^127" | bc) |