start new:
tmux
start new with session name:
tmux new -s myname
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then | |
// use window.btoa' step. According to my tests, this appears to be a faster approach: | |
// http://jsperf.com/encoding-xhr-image-data/5 | |
/* | |
MIT LICENSE | |
Copyright 2011 Jon Leighton | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
var reg = /^[a-z]$/; | |
console.log('case 01: typeof /^[a-z]$/ returns %s', typeof reg); | |
console.log('case 02: /^[a-z]$/ instanceof RegExp returns %s', reg instanceof RegExp); | |
console.log('case 03: /^[a-z]$/.constructor.name === "RegExp" returns %s', reg.constructor.name === 'RegExp'); | |
var util = require('util'), | |
vm = require('vm'), | |
sandbox = { u: reg }; |
{ | |
"AL": "Alabama", | |
"AK": "Alaska", | |
"AS": "American Samoa", | |
"AZ": "Arizona", | |
"AR": "Arkansas", | |
"CA": "California", | |
"CO": "Colorado", | |
"CT": "Connecticut", | |
"DE": "Delaware", |
for line in yourString:gmatch("([^\n]*)\n?") do | |
-- do something | |
end |
SSH into your EC2 instance. Run the following:
$ sudo yum install gcc
This may return an "already installed" message. That's OK.
$ wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
-- Get Max ID from table | |
SELECT MAX(id) FROM table; | |
-- Get Next ID from table | |
SELECT nextval('table_id_seq'); | |
-- Set Next ID Value to MAX ID | |
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table)); |
# Given an input, this program returns a list of all primes numbers less than the input. | |
defmodule NPrimes do | |
def get_primes(n) when n < 2, do: [] | |
def get_primes(n), do: Enum.filter(2..n, &is_prime?(&1)) | |
defp is_prime?(n) when n in [2, 3], do: true | |
defp is_prime?(x) do | |
start_lim = div(x, 2) | |
Enum.reduce(2..start_lim, {true, start_lim}, fn(fac, {is_prime, upper_limit}) -> |