Skip to content

Instantly share code, notes, and snippets.

@esurdam
esurdam / install-ffmpeg-amazon-linux.sh
Last active May 25, 2019 04:35 — forked from gboudreau/install-ffmpeg-amazon-linux.sh
How to compile ffmpeg on Amazon Linux (EC2)
#!/bin/sh
# Based on instructions found here: http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat#FFMpegInstallationonCentOSandRedHat-InstallX264
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
cat > /etc/yum.repos.d/centos.repo<<EOF
@esurdam
esurdam / nginx.default.conf
Last active May 19, 2017 01:41 — forked from sumardi/nginx.default.conf
Install PHP-FPM, Nginx & MySQL on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and PHP-FPM
sudo yum install -y nginx php70-fpm
# Install PHP extensions
sudo yum install -y php70-devel php70-mysql php70-pdo \
php70-pear php70-mbstring php70-cli php70-odbc \
@esurdam
esurdam / bm.rb
Created December 21, 2016 23:38 — forked from thejefflarson/bm.rb
poor man's benchmark
def measure
t = Time.now
yield
puts Time.now - t
end
@esurdam
esurdam / work
Last active September 14, 2016 04:09
py.py
output = popen("/usr/local/bin/ffprobe -v error -show_format -show_streams %s" % self._audio).read()
for spec in {'sample_rate', 'channels'}:
eval(u'{0:s} = popen("echo "{0:s}" | grep {0:s}).read().replace("{0:s}=", "").rstrip("\n")'.format(spec))
# sample_rate = popen("echo \"%s\" | grep sample_rate" % output).read().replace("sample_rate=", "").rstrip('\n')
# channels = popen("echo \"%s\" | grep channels" % output).read().replace("channels=", "").rstrip('\n')
if int(sample_rate) > 16000 or int(channels) > 1:
filename, extension = self._audio.split('.')
output_file = ".%s_mono.%s" % (filename, extension)
@esurdam
esurdam / runner.py
Last active September 4, 2016 03:50
sample
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
sys.path.insert(0, os.path.abspath('..'))
from facebookads.objects import (
AdUser,
@esurdam
esurdam / MIU.agda
Created August 3, 2016 02:05 — forked from gergoerdi/MIU.agda
The "MI to MU" puzzle from GEB
module MIU where
data Symbol : Set where
I : Symbol
U : Symbol
open import Data.List
Word : Set
Word = List Symbol
@esurdam
esurdam / MIU.agda
Created August 3, 2016 02:05 — forked from gergoerdi/MIU.agda
The "MI to MU" puzzle from GEB
module MIU where
data Symbol : Set where
I : Symbol
U : Symbol
open import Data.List
Word : Set
Word = List Symbol
@esurdam
esurdam / cache_class_methods.rb
Last active July 26, 2016 09:42
Magic Sauce Caching ;)
module CacheClassMethods
def has_serializer
if self.instance_eval "Object.const_defined? #{self.class.name}Serializer.to_s"
self.instance_eval "#{self.class.name}Serializer"
end
end
def hash_key(source = nil)
"#{self.class.name.to_s.downcase}:#{source.to_s.downcase}"
@esurdam
esurdam / awslogs.conf
Last active January 12, 2018 09:18
AWSlogs config file
[general]
state_file = /var/lib/awslogs/agent-state
[messsages]
datetime_format = %b %d %H:%M:%S
file = /var/log/messages
buffer_duration = 5000
log_stream_name = {hostname} - {instance_id}
initial_position = start_of_file
log_group_name = messages
@esurdam
esurdam / nginx_njs.md
Last active August 19, 2018 18:38
njs for nginx configuration

NJS/nginScript

Configure nginx with HTTP JavaScript module using the --add-module option:

./configure --add-module=<path-to-njs>/nginx

Alternatively, you can build a dynamic version of the njs module

./configure --add-dynamic-module=<path-to-njs>/nginx