Skip to content

Instantly share code, notes, and snippets.

View ozbillwang's full-sized avatar
:octocat:

Bill Wang ozbillwang

:octocat:
View GitHub Profile
@ozbillwang
ozbillwang / asg-disable.md
Created November 17, 2014 03:15
Temporarily disable AWS auto-scaling group activities
@ozbillwang
ozbillwang / Vagrant.Multi.CPU.rb
Created November 20, 2014 01:27
Vagrant setting - Use all CPU cores and 1/4 system memory
# http://www.stefanwrobel.com/how-to-make-vagrant-performance-not-suck
config.vm.provider "virtualbox" do |v|
host = RbConfig::CONFIG['host_os']
# Give VM 1/4 system memory & access to all cpu cores on the host
if host =~ /darwin/
cpus = `sysctl -n hw.ncpu`.to_i
# sysctl returns Bytes and we need to convert to MB
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation template to deploy railo4/tomcat7/nginx.",
"Parameters" : {
"KeyName" : {
"Default" : "bacfug",
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
vagrantfile-local:
vm:
box: puphpet/debian75-x64
box_url: puphpet/debian75-x64
hostname: ''
memory: '512'
cpus: '1'
chosen_provider: virtualbox
network:
private_network: 10.10.56.101
require('http').createServer(function(q, s){s.end('ok');}).listen(51160);
---
- name: coreos-01
box: coreos-alpha
ram: 512
ip: 172.17.8.101
- name: coreos-02
box: coreos-alpha
ram: 512
ip: 172.17.8.102
- name: coreos-03
@ozbillwang
ozbillwang / servers.yaml
Last active July 1, 2017 23:48 — forked from scottslowe/yaml-vagrantfile
This Vagrantfile works with an external data file (a YAML file, named servers.yaml) to create multiple Vagrant boxes easily. The servers.yaml file contains all the specifics and can be easily edited to change the number and type of boxes to create. The Vagrantfile remains unchanged. http://blog.scottlowe.org/2014/10/22/multi-machine-vagrant-with…
---
- name: coreos-01
box: coreos-alpha
ram: 512
ip: 172.17.8.101
- name: coreos-02
box: coreos-alpha
ram: 512
ip: 172.17.8.102
- name: coreos-03
# 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
@ozbillwang
ozbillwang / ruby-one-liners.md
Last active August 29, 2015 14:13 — forked from KL-7/one-liners.md
ruby one liner collection

One-liners

Reverse every line:

Input file:

$ cat foo
qwe
123

bar

@ozbillwang
ozbillwang / Vagrantfile
Last active August 29, 2015 14:13
How-to: Use Vagrant to Set Up a Virtual Hadoop Cluster (For CDH 4)
# -*- mode: ruby -*-
# vi: set ft=ruby :
$master_script = &lt;&lt;SCRIPT
#!/bin/bash
cat &gt; /etc/hosts &lt;&lt;EOF
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback