Skip to content

Instantly share code, notes, and snippets.

@rickytato
rickytato / gDNS.py
Created November 3, 2011 22:37 — forked from gleicon/gDNS.py
gevent/dnslib/redis based DNS server
# dns server using dnslib and gevent
# based on https://bitbucket.org/paulc/dnslib/src/80d85555aae4/src/server/gevent_server.py
# set the key as
# set IP:name ip_addr
# set TXT:name txtfield
# fallback on gevent's dns resolver
# gleicon 2011
import gevent
import re
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone
from metaphone import dm as double_metaphone
# get the Redis connection
from jellybean.core import redis
import models
# Words which should not be indexed
@rickytato
rickytato / vbox_to_kvm.txt
Created June 15, 2012 07:33 — forked from bdha/vbox_to_kvm.txt
Migrating from VirtualBox to KVM on ZFS
# It's important to convert the vbox image (VMDK or VDI or whatever) using
# the same version of VirtualBox that created it. You can try converting the image
# with qemu-img or kvm-img, but weird version mismatches will possibly make it not
# work.
# On your VirtualBox machine:
cd $VBOX_ROOT/$MACHINE_ROOT/
VBoxManage clonehd machine.vmdk machine.img --format RAW
scp machine.img root@kvm-host:/somewhere
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
@rickytato
rickytato / normalize_cpu_affinity.cron
Last active September 17, 2015 18:48 — forked from israelshirk/normalize_php_fpm_affinity.cron
Normalize PHP-FPM CPU affinityAssumes 8 processors, #0 assigned to kernel+nginx
* * * * * root /usr/local/bin/normalize_cpu_affinity.sh
@rickytato
rickytato / benchmark.php
Created May 1, 2016 13:54 — forked from BlakeGardner/benchmark.php
Benchmark of all the hashing algorithms provided by PHP
<?php
foreach (hash_algos() as $algo) {
$start_time = microtime(TRUE);
for ($index = 0; $index <= 500000; $index++) {
$hash = hash($algo, $index);
}
@rickytato
rickytato / set_php_fpm_affinity.sh
Created May 3, 2016 16:44 — forked from kamermans/set_php_fpm_affinity.sh
Set PHP-FPM pool workers CPU affinity so each worker gets one CPU core
#!/bin/bash
# Set PHP-FPM pool workers CPU affinity so each worker gets one CPU core
# Note that FPM recycles threads, so you'll need to run this on cron periodically
# Author: Steve Kamerman
CPUS=$(grep -c processor /proc/cpuinfo)
FPM_PIDS=$(ps auxw | grep php-fpm | grep pool | awk '{ print $2; }')
if [ "$FPM_PIDS" = "" ]; then
@rickytato
rickytato / dash-avc264 command lines
Created December 1, 2016 15:30 — forked from ddennedy/dash-avc264 command lines
Use ffmpeg and mp4box to prepare DASH-AVC/264 v1.0 VoD
See my DASH-IF presentation from October, 2014:
https://s3.amazonaws.com/misc.meltymedia/dash-if-reveal/index.html#/
1. encode multiple bitrates with keyframe alignment:
ffmpeg -i ~/Movies/5D2_Portrait.MOV -s 1280x720 -c:v libx264 -b:v 1450k -bf 2 \
-g 90 -sc_threshold 0 -c:a aac -strict experimental -b:a 96k -ar 32000 out.mp4
My input was 30 fps = 3000 ms. If it were 29.97, then a GOP size of 90 frames will yield a base segment
size of 3003 milliseconds. You can make the segment size some multiple of this, e.g.: 6006, 9009, 12012.
@rickytato
rickytato / README.md
Created December 2, 2016 11:08 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@rickytato
rickytato / HAProxy PEM order
Last active January 4, 2017 11:30 — forked from kehers/gist:48d1dc99c9cae0ceac0c
Order of SSL pem file for HAProxy
1. key
2. crt
3. COMODORSADomainValidationSecureServerCA.crt
4. COMODORSAAddTrustCA
5. AddTrustExternalCARoot