Skip to content

Instantly share code, notes, and snippets.

View elchappo's full-sized avatar
👻

Pawel Zareba elchappo

👻
View GitHub Profile
@elchappo
elchappo / boc.py
Created April 30, 2013 14:06 — forked from mekza/boc.py
#!/usr/bin/python
# -*- coding:utf-8 -*-
import itertools
import requests
import json
characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
password_length = 6
gen = itertools.combinations_with_replacement(characters,password_length)
rsync -avz /path/to/local/sync/folder -e "ssh -i /path/to/ssh/key" ubuntu@ec2instance:/path/to/remote/sync/folder
@elchappo
elchappo / gist:4188244
Created December 2, 2012 11:10
Generating W3C valid HTML5 <time> tags in PHP
<time datetime="<?php echo date('Y-m-d\Th:m:sO', strtotime($publishedDate)); ?>" ><?php echo date('l jS F Y', strtotime($publishedDate); ?></time>
@elchappo
elchappo / gist:4072999
Created November 14, 2012 16:07
Bash script to monitor /tmp folder on the server
#!/bin/sh
tmp_usage=$(df -h /tmp/ | tail -1 | awk '{print $4}' | awk -F "%" '{print $1}')
if [ $tmp_usage -gt 90 ]; then
echo "Your /tmp folder is $tmp_usage% full, please investigate" | mail -s "TMP folder on <server-id>" zareba.pawel@gmail.com;
fi
@elchappo
elchappo / gist:4002989
Created November 2, 2012 17:37
Search nginx access log for IP and url
cat /etc/nginx/logs/access.log | awk '{print $1 " " $4 " " $5 " " $6 " " $7}' | grep 'url'
@elchappo
elchappo / gist:3969871
Created October 28, 2012 20:53
PHP Regex checker
<?php
$string = "abcdefgh";
$regex = "/^[a-z]+$/i";
// Syntax is preg_match(regex, string, [, out_matches [, flags [, offset]]]);
if (preg_match($regex, $string)) {
printf("Pattern '%s' found in string '%s'\n", $regex, $string);
} else {
printf("No match found in string '%s'!\n", $string);
}
?>
@elchappo
elchappo / gist:3953057
Created October 25, 2012 14:55
htaccess php rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /subfolder/
RewriteCond %{REQUEST_URI} !^/subfolder
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]+)/$ $1.php
RewriteRule ^([a-z]+-?[a-z]+)/$ $1.php
@elchappo
elchappo / gist:3925117
Created October 20, 2012 22:53
PHP nginx configration
server{
listen 80;
server_name <domine>;
access_log /var/log/<domine>.access_log;
error_log /var/log/<domine>.error_log;
root <domine_path>;
location ~ ^/resize/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ {
@elchappo
elchappo / cacheSentinel.sh
Created October 20, 2012 22:50
PHP resizer sentinel
#!/bin/bash
CACHEDIR=
MAXSIZE=100
DIRSIZE=`du -s $CACHEDIR | cut -f 1`
MINFILES=5
echo $DIRSIZE' : '$CACHEDIR
#ls -t cache | sed -e '1,10d' | xargs -d '\n' rm
@elchappo
elchappo / resize.php
Created October 20, 2012 22:49
PHP resizer
<?php
$resizer = new Resizer();
$resizer->setRequestFileInfo($_GET['path']);
$resizer->setRequestHight($_GET['hight']);
$resizer->setRequestWidth($_GET['width']);
$resizer->setRequestMode($_GET['mode']);
$resizer->generateImage();
/**