Skip to content

Instantly share code, notes, and snippets.

View Sjeanpierre's full-sized avatar
💭
🤷🏿‍♂️

Stevenson Jean-Pierre Sjeanpierre

💭
🤷🏿‍♂️
View GitHub Profile
require "minitest/autorun"
# Each member of a Cartesian Array corresponds to the selection of one element each in every one of those sets.
# http://en.wikipedia.org/wiki/Cartesian_product
class CartesianArray < Array
# CartesianArray.new([0,1], [a,b], etc)
def initialize(*args)
super args
@Sjeanpierre
Sjeanpierre / credentials.yml
Last active August 29, 2015 14:06
run ss_update.sh and follow the prompts
:access_key_id: 'ACCESS_KEY'
:secret_key: 'SECRET_KEY'
@Sjeanpierre
Sjeanpierre / create.rb
Last active August 29, 2015 14:16
Create dynamodb table with global index example aws-sdk ruby
def setup_dynamo
options = {
:table_name => 'servers',
:attribute_definitions => [
{
:attribute_name => 'uid',
:attribute_type => 'S'
},
{
:attribute_name => 'private_ip',
require 'sinatra'
require 'multi_json'
class App < Sinatra::Application
configure do
# Don't log them. We'll do that ourself
set :dump_errors, false
# Don't capture any errors. Throw them up the stack
set :raise_errors, true
@Sjeanpierre
Sjeanpierre / convert.sh
Created September 1, 2015 05:49
iso to mkv conversion, cygwin
#! /usr/bin/bash
for i in $( ls *.iso ); do
filename=$i
base=${filename%.*}
echo processing $filename
/cygdrive/c/Program\ Files\ \(x86\)/MakeMKV/makemkvcon.exe mkv iso:$filename 0 processed/
mv processed/title00.mkv processed/$base.mkv
echo done
done
@Sjeanpierre
Sjeanpierre / dropbox
Created July 31, 2012 20:22 — forked from nyarla/dropbox
/etc/init.d/SpiderOak.sh
#!/bin/sh
# /etc/init.d/SpiderOak
### BEGIN INIT INFO
# Provides: SpiderOsk
# Required-Start: $network $syslog $remote_fs
# Required-Stop: $network $syslog $remote_fs
# Should-Start: $named $time
# Should-Stop: $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@Sjeanpierre
Sjeanpierre / redis.conf
Created December 12, 2012 02:34 — forked from anonymous/redis.conf
Spec and conf file for building redis on CentOS 5.8
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@Sjeanpierre
Sjeanpierre / db_connect.sh
Created June 15, 2015 19:04
Connect to database defined by rails databae.yml when on a server
#! /usr/bin/env bash
USERNAME=`cat config/database.yml | grep username | awk {'print$2'}`
PASSWORD=`cat config/database.yml | grep password | awk {'print$2'}`
HOST=`cat config/database.yml | grep host | awk {'print$2'}`
DATABASE=`cat config/database.yml | grep database | awk {'print$2'}`
mysql -h $HOST -u $USERNAME -D $DATABASE -p$PASSWORD
@Sjeanpierre
Sjeanpierre / redis
Last active December 12, 2015 06:08
Monit configuration for Redis on platform servers
check process redis-server
with pidfile "/var/run/redis/redis.pid"
start program = "/etc/init.d/redis start"
stop program = "/etc/init.d/redis stop"
if cpu usage > 95% for 3 cycles then restart
if failed host localhost port 6379 then restart
if 5 restarts within 5 cycles then timeout
@Sjeanpierre
Sjeanpierre / list_env.rb
Created January 4, 2014 01:56
List environment variables used by ruby script
#!/bin/ruby
REGEX = Regexp.new('ENV\[\s*(\S.*?)\s*\]')
def report
list = list_found
if list.empty?
puts 'No environment variables found'
else