Skip to content

Instantly share code, notes, and snippets.

@stamm
stamm / Firewall.sh
Created April 20, 2011 20:26
Put in /etc/init.d/rc.firewall
#! /bin/sh
### BEGIN INIT INFO
# Provides: rc.firewall
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the firewall, NAT
# Description: starts the firewall, NAT
### END INIT INFO
@stamm
stamm / mysql.sh
Created November 7, 2011 15:15
mysql copy
#!/bin/sh
if [ ! -f "$1" ]; then
echo "File $1 not exists"
exit;
fi
mysqlPath="/var/lib/mysql.bak.`date +%Y%m%d_%H%M`"
sudo mkdir $mysqlPath
sudo service mysql stop
@stamm
stamm / main.php
Created November 7, 2011 19:13
yii config
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
'name' => 'FPR',
'sourceLanguage' => 'en_us',
'language' => 'ru',
@stamm
stamm / nginx.conf
Created November 30, 2011 08:17
symfony vs yii
framework | rel | avg | 1 | 2 | 3 | 4 | 5
------------------------ | -------- | -------- | -------- | -------- | -------- | -------- | --------
baseline-php | 1.0000 | 2579.36 | 2594.56 | 2581.71 | 2587.63 | 2581.61 | 2551.30
symfony-2.0.0alpha1 | 0.0878 | 226.37 | 226.44 | 227.65 | 226.11 | 225.54 | 226.09
yii-1.1.1 | 0.0827 | 213.34 | 213.50 | 213.45 | 213.50 | 213.32 | 212.94
yii-1.1.8 | 0.0738 | 190.29 | 190.04 | 190.29 | 190.11 | 190.10 | 190.93
framework | rel | avg | 1 | 2 | 3 | 4 | 5
@stamm
stamm / .gitconfig
Created April 4, 2012 08:37
gitconfig
[push]
#Пушить только текущую ветку
default = tracking
[branch]
# Делать rebase при пуле при создании новой ветки
autosetuprebase = always
[user]
name = Rustam Zagirov
email = rustam@zagirov.name
[color]
@stamm
stamm / CopyTestDb.php
Created April 4, 2012 16:59
Copy db in
<?php
/**
* Копируем данные из одной базы в другую
*/
class CopyTestDb {
/** @var array Таблицы, которые не будут копироватся */
static private $skip = array();
/** @var array Таблицы, у которых нужно скопировать только схему */
static private $onlySchema = array();
@stamm
stamm / mongo_remove.js
Created September 6, 2012 13:21
Mongo removing partials
function microtime() {
return new Date().getTime() / 1000;
}
/**
* Удаляет данные из монги частями
* @param last_time - время последнего запроса
* @param collection - имя коллекции
* @param criteria - критерия для удаления
* @return {Array}
@stamm
stamm / gist:4160699
Created November 28, 2012 11:52
speed grep from macos
#grep from macos
➜ tmp time /usr/bin/grep "GET /out" nginx-access_log.2 | wc -l
140858
/usr/bin/grep "GET /out" nginx-access_log.2 26.49s user 0.28s system 97% cpu 27.443 total
wc -l 0.03s user 0.02s system 0% cpu 27.443 total
➜ brew install grep
➜ tmp time grep "GET /out" nginx-access_log.2 | wc -l
@stamm
stamm / vk_remove_all_from_wall.js
Created August 8, 2013 18:27
Remove all from your wall. 1) repeatedly press end on your wall. 2) insert this code in google chrome console and press enter
var posts=$$('.post_delete_button'), length = posts.length; for (i=0; i <length; i++) { posts[i].click() }
####### PHP 5.4.23 BENCHMARK #######
Start : 12/24/2013 16:49:12 pm
Server : @
Platform : Darwin
PHP version: 5.4.23
####################################
for : 0.02550 sec
while : 0.01702 sec
if else : 0.08580 sec
switch : 0.11273 sec