Skip to content

Instantly share code, notes, and snippets.

View rclayton-the-terrible's full-sized avatar

Richard Clayton rclayton-the-terrible

View GitHub Profile
@jordansissel
jordansissel / foo.md
Last active February 6, 2021 22:08
logstash message format

logstash json format

{
  "message"    => "hello world",
  "@version"   => "1",
  "@timestamp" => "2014-04-22T23:03:14.111Z",
  "type"       => "stdin",
  "host"       => "hello.local"
}
@tokudu
tokudu / ec2ssh.sh
Created October 27, 2012 23:55
A helper script for SSH'ing into EC2 instances by name
#!/bin/bash
# SSH into an EC2 instance by name
# Author: tokudu@github.com (SoThree.com).
set -e
if [ $# -lt 1 ]
then
echo "Usage: `basename $0` instance_name"
exit 1
fi
@rclayton-the-terrible
rclayton-the-terrible / build_and_install_rmq_web_stomp_ssl.sh
Last active August 31, 2018 17:16
Build and Install RabbitMQ Web Stomp with SSL (from @jshiell's repo).
# Make sure you have Mercurial and Git installed
git clone https://github.com/rabbitmq/rabbitmq-public-umbrella.git
cd rabbitmq-public-umbrella
make co
cd rabbitmq-web-stomp
git clone https://github.com/jshiell/rabbitmq-web-stomp.git
make
cd dist
@ikenna
ikenna / stopwatch.rb
Last active April 21, 2021 15:01
Simple Ruby stopwatch
class Stopwatch
def initialize()
@start = Time.now
end
def elapsed_time
now = Time.now
elapsed = now - @start
puts 'Started: ' + @start.to_s
@jjb
jjb / gist:7389552
Last active March 16, 2024 18:48
Ruby 2.1 memory configuration

This all applies to Ruby 2.1. In some cases a setting is not available in 2.0, this is noted. There is also a different with 1.9, 1.8, and REE --- these are not noted.

All the relevant code is in https://github.com/ruby/ruby/blob/master/gc.c

RUBY_HEAP_MIN_SLOTS

default: 10000

The number of heap slots to start out with. This should be set high enough so that your app has enough or almost enough memory after loading so that it doesn't have to allocate more memory on the first request (althogh this probably isn't such a big deal for most apps).

(todo: figure out how big a slot is. i think the answer can be infered from this code.)

@CodingFu
CodingFu / deviseCheck.js
Created November 13, 2013 00:08
Simple devise user login check in node.js
var mysql = require('mysql')
, bcrypt = require('bcrypt')
, db = {
host: 'localhost',
user: 'root',
database: 'prod'
};
function checkUser(email, password, callback) {
var connection = mysql.createConnection(db);
cat datasets/auto_mpg.csv | python csv2vw.py car_name mpg > auto_mpg.vw
cat auto_mpg.vw | vw -f auto_mpg.sgd --sgd --loss_function=squared
cat auto_mpg.vw | vw -kc -f auto_mpg.sgd --sgd --passes 10 --loss_function=squared
cat auto_mpg.vw | vw -kc -f auto_mpg.sgd --sgd --passes 10 --loss_function=squared
cat auto_mpg.vw | vw -kc -f auto_mpg.bfgs --bfgs --hessian_on --passes 100 --loss_function=squared
cat auto_mpg.vw | vw -kc -i auto_mpg.sgd -f auto_mpg.hybrid --bfgs --hessian_on --passes 100 --loss_function=squared
head -n 350 auto_mpg.vw > auto_mpg.vw.train
tail -n 48 auto_mpg.vw > auto_mpg.vw.test
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active July 23, 2024 04:22
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@rothgar
rothgar / main.yml
Last active March 8, 2024 07:16
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@lovasoa
lovasoa / UTF8byteLength.js
Created April 27, 2014 23:23
Compute the length in bytes of a javascript string, when encoded in UTF8
function byteLength(str) {
// returns the byte length of an utf8 string
var s = str.length;
for (var i=str.length-1; i>=0; i--) {
var code = str.charCodeAt(i);
if (code > 0x7f && code <= 0x7ff) s++;
else if (code > 0x7ff && code <= 0xffff) s+=2;
if (code >= 0xDC00 && code <= 0xDFFF) i--; //trail surrogate
}
return s;