Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️
<typing sounds>

Matthew Tovbin tovbinm

⌨️
<typing sounds>
View GitHub Profile
@tovbinm
tovbinm / .backupignore
Created Feb 26, 2014
Backup Mac using rsync
View .backupignore
.Spotlight-*/
.Trashes
/afs/*
/automount/*
/cores/*
/dev/*
/Network/*
/private/tmp/*
/private/var/run/*
/private/var/spool/postfix/*
@tovbinm
tovbinm / waves.js
Created Jan 26, 2014
Breaking waves sound (Open (http://myjavatools.com/js.html) in Chrome paste the code and hit run)
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);
}
@tovbinm
tovbinm / Build.scala
Created Jan 21, 2014
Kafka 0.8.0 with Zookeeper 3.4.5
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>
@tovbinm
tovbinm / Id64.scala
Last active Jan 20, 2017
64 bit unique id generator
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:
@tovbinm
tovbinm / ch5_streams.scala
Last active Dec 26, 2015
Reading Functional Programing In Scala
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)
@tovbinm
tovbinm / gist:6498848
Created Sep 9, 2013
Backup/Restore with MySQL
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
@tovbinm
tovbinm / resize.rb
Last active Dec 20, 2015
S3 Resize images
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';
@tovbinm
tovbinm / gist:6086013
Created Jul 26, 2013
NTFS Write Support On OS X Mountain Lion
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
@tovbinm
tovbinm / gist:5482957
Created Apr 29, 2013
Setup Apache + Ruby on Rails + Passenger on Debian
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
@tovbinm
tovbinm / gist:4507146
Last active Dec 10, 2015
Searching photo caption and filtering by owner's gender
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" : {
You can’t perform that action at this time.