Skip to content

Instantly share code, notes, and snippets.

@mtrl
mtrl / ncftpget-recursive-download
Created July 11, 2011 11:34
ncftpget recursive download from list of dirs
#!/bin/bash
a=0
while read line
do a=$(($a+1));
echo $line;
mkdir $line;
cd $line;
ncftpget -u USER -p PASSWORD -R -d stdout -t 300 "ftp://[HOST]/$line"
cd "..";
done < "../dir-list"
@mtrl
mtrl / preg_match_email.php
Created July 12, 2011 16:26
preg_match loose email match
//Matches [email protected]
preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $_POST['email'])
@mtrl
mtrl / .zshrc
Created August 6, 2011 15:16
.zshrc
autoload -U colors && colors
PS1="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
alias la="ls -a"
alias ll="ls -l"
alias lal="ls -al"
bindkey '^[[1;5C' emacs-forward-word
bindkey '^[[1;5D' emacs-backward-word
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
@mtrl
mtrl / Create mysql user via command
Created August 19, 2011 16:05
Create mysql user via command
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES
ON databasename.*
TO 'username'@'localhost' IDENTIFIED BY 'password';
@mtrl
mtrl / gist:1167685
Created August 24, 2011 09:38
mysqldump db to db copy
Copy database and schema
---
mysqldump -u [user] -p[password] -h localhost --databases [databases] -Ccqf --no-data | mysql -u [user] -p -h [host] -P 3306
Copy data
---
mysqldump -u [user] -p[password] -h localhost --databases [databases] -Ccqf --no-create-db --no-create-info | mysql -u [user] -p -h [host] -P 3306
@mtrl
mtrl / hosts
Created August 24, 2011 11:55
ubuntu hosts file
127.0.0.1 localhost.localdomain localhost
::1 [hostnane] localhost6.localdomain6 localhost6
127.0.1.1 [hostname]
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
@mtrl
mtrl / create-vhosts.sh
Created August 26, 2011 11:29
Create apache virtual host on Ubuntu and create entry in hosts file
#! /bin/sh
if [ "$(id -u)" -ne "0" ] ; then
echo "This script must be run as root"
else
if [ -z "$2" ] ; then
echo Usage ./create-vhost.sh [full path to site root directory] [url of vhost without http://]
exit 1;
else
DIRECTORY=$1;
@mtrl
mtrl / [example.com].conf
Created September 9, 2011 10:59
Magento nginx conf
server {
listen 81;
server_name
[www.example.com]
[example.com]
;
rewrite ^(.*) https://[www.example.com]$1 permanent;
}
server {
@mtrl
mtrl / centos
Created September 15, 2011 14:33
CentOS start init.d on startup
chkconfig sphinx off
chkconfig sphinx on