start new:
tmux
start new with session name:
tmux new -s myname
var http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
// default exports | |
export default 42; | |
export default {}; | |
export default []; | |
export default foo; | |
export default function () {} | |
export default class {} | |
export default function foo () {} | |
export default class foo {} |
implicit object ProductItemFormat extends RootJsonFormat[ProductItem] { | |
// some fields are optional so we produce a list of options and | |
// then flatten it to only write the fields that were Some(..) | |
def write(item: ProductItem) = JsObject( | |
List( | |
Some("product_number" -> item.productNumber.toJson), | |
item.ean.map(ean ⇒ "ean" -> ean.toJson), | |
Some("title" -> item.title.toJson), | |
item.description.map(description ⇒ "description" -> description.toJson), | |
Some("price" -> item.price.toJson), |
#!/bin/bash | |
# Stop all containers | |
containers=`docker ps -a -q` | |
if [ -n "$containers" ] ; then | |
docker stop $containers | |
fi | |
# Delete all containers | |
containers=`docker ps -a -q` | |
if [ -n "$containers" ]; then | |
docker rm -f -v $containers |
If you don't have homebrew installed - get homebrew here
Then run: brew install elasticsearch
Update the elasticsearch configuration file in /usr/local/etc/elasticsearch/elasticsearch.yml
.
/** | |
* @author Dongjun Lee <[email protected]> | |
* Game AI for dodgygame. (http://brandonstilson.com/dodgygame/) | |
* | |
* How to use | |
* Copy and paste in browser's inspector console. | |
*/ | |
// constants | |
var BOARD_SIZE = 11; |
// getComponent is a function that returns a promise for a component | |
// It will not be called until the first mount | |
function asyncComponent(getComponent) { | |
return class AsyncComponent extends React.Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { | |
if (!this.state.Component) { | |
getComponent().then(Component => { |
-- Create a group | |
CREATE ROLE readaccess; | |
-- Grant access to existing tables | |
GRANT USAGE ON SCHEMA public TO readaccess; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
-- Grant access to future tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; |