Skip to content

Instantly share code, notes, and snippets.

View wdalmut's full-sized avatar
💭
Fantasy Land

Walter Dal Mut wdalmut

💭
Fantasy Land
View GitHub Profile
#!/usr/bin/python -O
################################################################################
################################################################################
#
# State-Based Text Merging Algorithm
# For 6.033 Design Project 2
# TA: Katherine Fang
# 9 May 2012
#
@wdalmut
wdalmut / rc4.js
Last active August 29, 2015 14:19 — forked from farhadi/rc4.js
/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str) {
var s = [], j = 0, x, res = '';
# lib/puppet/parser/functions/pw_hash.rb
module Puppet::Parser::Functions
newfunction(:pw_hash, type: :rvalue) do |args|
raise Puppet::ParseError, "pw_hash takes exactly two arguments, #{args.length} provided" if args.length != 2
# SHA512 ($6), default number of rounds (5000)
# rounds could be specified by prepending rounds=<n>$ parameter before the salt, i.e.
# args[0].crypt("$6$rounds=50000$#{args[1]}")
args[0].crypt("$6$#{args[1]}")
end
@wdalmut
wdalmut / gist:3744907
Created September 18, 2012 18:33
Amazon RDS Performance Tuning Settings
rds-modify-db-parameter-group {param-group-name} \
--parameters="name=character_set_server, value=utf8, method=pending-reboot" \
--parameters="name=collation_server, value=utf8_general_ci, method=pending-reboot" \
--parameters="name=tmp_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=max_heap_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=query_cache_type, value=1, method=pending-reboot" \
--parameters="name=query_cache_size, value={DBInstanceClassMemory/32}, method=pending-reboot" \
--parameters="name=table_open_cache, value=2500, method=pending-reboot" \
--parameters="name=join_buffer_size, value={DBInstanceClassMemory/64}, method=pending-reboot" \
--parameters="name=thread_cache_size, value={DBInstanceClassMemory/12582880}, method=pending-reboot" \
@wdalmut
wdalmut / launch_instances
Created September 18, 2012 18:36 — forked from jlindsey/launch_instances
Launch AWS instances
#!/usr/bin/env ruby
# Require gems with versions
begin
require 'logger'
require 'rubygems'
gem 'fog', '~> 0.6.0'
gem 'trollop', '~> 1.16.2'
require 'fog'; require 'trollop'
@wdalmut
wdalmut / build.sh
Created December 11, 2012 22:14 — forked from igorw/build.sh
#!/bin/bash
# Amazing static site generator
# Works for PHP and HTML sites
# Assumes web root to be in /web
# Dumps the site into a directory named "static"
PORT=9999
php -S localhost:$PORT -t web >/dev/null &
PID=$!
@wdalmut
wdalmut / clone_redis.py
Created October 14, 2015 15:19 — forked from jimmyislive/clone_redis.py
Redis Elasticache Export
from optparse import OptionParser
import sys
import redis
__author__ = 'Jimmy John'
__doc__ = '''
This is a script to make a copy of a redis db. Mainly to be used for cloning AWS Elasticache
instancces. Elasticache seems to disable the SAVE/BGSAVE commands and you do not have access to
the physical redis instances. The UI allows you to create 'Snapshots', but no way to download
# Terminal output control (http://www.termsys.demon.co.uk/vtansi.htm)
TC='\e['
CLR_LINE_START="${TC}1K"
CLR_LINE_END="${TC}K"
CLR_LINE="${TC}2K"
# Hope no terminal is greater than 1k columns
RESET_LINE="${CLR_LINE}${TC}1000D"
@wdalmut
wdalmut / docker advertise + overlay
Created July 11, 2017 20:00
CoreOS + Docker Swarm
sudo mkdir /etc/systemd/system/docker.service.d/
sudo vim /etc/systemd/system/docker.service.d/cluster.conf
[Service]
Environment="DOCKER_OPTS=--cluster-advertise=10.0.0.2:2375 --cluster-store=etcd://10.0.0.2:2379 --host=tcp://10.0.0.2:2375"
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker
@wdalmut
wdalmut / config.yml
Created January 24, 2018 13:47 — forked from K-Phoen/config.yml
Storing Symfony2 sessions in memcached
imports:
# ....
- { resource: services/session.yml }
framework:
# ....
session:
handler_id: session.handler.memcached