Skip to content

Instantly share code, notes, and snippets.

View tovbinm's full-sized avatar
⌨️
<typing sounds>

Matthew Tovbin tovbinm

⌨️
<typing sounds>
View GitHub Profile
@tovbinm
tovbinm / gist:6498848
Created September 9, 2013 17:30
Backup/Restore with MySQL
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 December 20, 2015 22:39
S3 Resize images
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 July 26, 2013 03:50
NTFS Write Support On OS X Mountain Lion
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 April 29, 2013 16:53
Setup Apache + Ruby on Rails + Passenger on Debian
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 December 10, 2015 23:08
Searching photo caption and filtering by owner's gender
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" : {
@tovbinm
tovbinm / Output
Last active October 27, 2015 21:46
Unique paths
Some tests...
Number of unique paths from (0,0) to (0,0) on board of size 1x1 is 1
Number of unique paths from (0,0) to (1,1) on board of size 2x2 is 2
Number of unique paths from (0,0) to (2,2) on board of size 3x3 is 12
Number of unique paths from (0,0) to (3,3) on board of size 4x4 is 184
Number of unique paths from (0,0) to (4,4) on board of size 5x5 is 8512
@tovbinm
tovbinm / gist:4157917
Created November 27, 2012 23:25
Debian Squeeze Virtual Machine
http://virtual-machine.org/debian-6-amd64-x86_64-vmware-image-download
@tovbinm
tovbinm / setup_ec2.sh
Created November 2, 2012 19:03
Install EC2 command line tools
#!/bin/bash
EC2_DIR=/usr/local/ec2
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip -O ec2-api-tools.zip
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip -O ec2-ami-tools.zip
mkdir -p $EC2_DIR
rm -rf $EC2_DIR/*
unzip -o -d $EC2_DIR ec2-api-tools.zip
unzip -o -d $EC2_DIR ec2-ami-tools.zip
cp -r $EC2_DIR/ec2-api-tools*/* $EC2_DIR
cp -r $EC2_DIR/ec2-ami-tools*/* $EC2_DIR
@tovbinm
tovbinm / gist:3977493
Created October 30, 2012 00:07
Unattended Java installation on Debian
echo "sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive aptitude install -y -f sun-java6-jre sun-java6-bin sun-java6-jdk
@tovbinm
tovbinm / gist:3763987
Created September 21, 2012 21:23
MacOSX port tweaks
sudo vim /etc/sysctl.conf
#Increase ephemeral port range
net.inet.ip.portrange.first=32768
#Decrease closing timeout
net.inet.tcp.msl=1000