View .backupignore
.Spotlight-*/ | |
.Trashes | |
/afs/* | |
/automount/* | |
/cores/* | |
/dev/* | |
/Network/* | |
/private/tmp/* | |
/private/var/run/* | |
/private/var/spool/postfix/* |
View waves.js
var AMP = 0.5; // amplitude | |
var len = 15; // seconds | |
e = new webkitAudioContext(); | |
var source = e.createBufferSource(); | |
var SR = e.sampleRate; | |
source.buffer = e.createBuffer(1, len * SR, SR); | |
var dat = source.buffer.getChannelData(0); | |
for (var i = 0; i < len * SR; i++) { | |
dat[i] = AMP * (Math.random() * 2 - 1); | |
} |
View Build.scala
<dependency org="org.apache.zookeeper" name="zookeeper" rev="3.4.5"> | |
<exclude org="log4j" module="log4j"/> | |
<exclude org="org.slf4j" module="slf4j-log4j12"/> | |
<exclude org="jline" module="jline"/> | |
</dependency> |
View Id64.scala
import scala.util.Random | |
import java.security.SecureRandom | |
import java.util.concurrent.atomic.AtomicLong | |
import org.joda.time.DateTimeUtils | |
/** | |
* 64 bit unique id generator | |
* Features: | |
* 1. generate ascending or descending ids | |
* 2. 64 bit id consists of: |
View ch5_streams.scala
// Excercies from chapter 5: Strictness and laziness | |
def foldRight[A,B](z: => B)(s: Stream[A])(f: (A, => B) => B): B = | |
s match { | |
case hd #:: tail => f(hd, foldRight(z)(tail)(f)) | |
case _ => z | |
} | |
def exists[A](s: Stream[A])(p: A => Boolean): Boolean = | |
foldRight(false)(s)((x,a) => if (p(x)) true else a) |
View gist:6498848
DB=my_db | |
mysqldump -uroot -h localhost $DB --opt --compress | gzip -9 -c > $DB-backup-`date +%Y%m%d%H`.sql.tgz | |
gunzip -c $DB-backup-`date +%Y%m%d%H`.sql.tgz > a.sql | |
mysql -u root $DB < a.sql |
View resize.rb
require 'aws/s3' | |
require 'RMagick' | |
include AWS::S3 | |
include Magick | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => 'key', | |
:secret_access_key => 'secret' | |
) | |
bucket = 'bucket_name'; |
View gist:6086013
If you have noticed, Mac OS X doesn’t support writing onto NTFS disks. But not to worry, you don’t have to install any third party drivers to enable this. Mountain Lion 10.8.3 already has native write support for the NTFS. OSX Mountain Lion does have built-in support for NTFS, and it can read and write. However, Apple does not enable it by default. | |
Here is what you should do: | |
Uninstall other 3rd-party NTFS software, like Paragon, Tuxera or NTFS-3G. | |
Edit /etc/fstab (you can do this with “sudo vi /etc/fstab”) | |
Add the following line: | |
LABEL=”VOLUME_NAME_WITHOUT_QUOTES” none ntfs rw,auto,nobrowse | |
Quit your editor | |
Now, just unmount and re-mount the disk |
View gist:5482957
apt-get update | |
apt-get install vim git | |
apt-get install libcurl4-openssl-dev | |
apt-get install apache2-prefork-dev | |
apt-get install libapr1-dev | |
apt-get install libaprutil1-dev | |
bash -s master < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | |
echo '[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"' >> ~/.bashrc | |
echo 'PATH=$PATH:/usr/local/rvm/bin' >> ~/.bashrc |
View gist:4507146
curl -XDELETE 'http://localhost:9200/test/' | |
curl -XPUT 'http://localhost:9200/test/' -d '{ | |
"settings" : { | |
"number_of_shards" : 1, | |
"number_of_replicas" : 1 | |
}, | |
"mappings" : { | |
"profile" : { | |
"properties" : { |