Skip to content

Instantly share code, notes, and snippets.

@kesor
kesor / Gemfile
Last active September 30, 2019 09:04
Vagrantfile to create a chef-server (11.x) and a client box that uses it.
source :rubygems
gem 'json', '= 1.5.4' # knife/chef 11.0 and 11.20 is broken with json 1.5.5/1.7.7
gem 'vagrant'
gem 'vagrant-hostmaster'
@Hydrotoast
Hydrotoast / AdversarialSearchAI.java
Last active December 10, 2015 15:18
An pseudocode AI demonstrating the Minimax algorithm. Note that the algorithm has two helper functions: min and max.
class AdversarialSearchAI {
private PieceType piece;
public AdversarialSearchAI(PieceType piece) {
this.piece = piece;
}
/**
* Returns the best move given the state of the game
*/
@fnichol
fnichol / 00_README.md
Created December 20, 2012 06:36
Chef Metadata Chopper!

MetadataChopper

MetadataChopper.extract('metdata.rb') # => [ "rvm", "0.9.1" ]
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jtimberman
jtimberman / gist:3088517
Last active February 7, 2018 16:40
Replace $VAGRANTBOX with box names that should be repackaged with updates. Don't specify it for up, ssh, and package if you're not using a multi-VM vagrantfile
% vagrant up --no-provision $VAGRANTBOX
% vagrant ssh $VAGRANTBOX
vagrant$ wget -O - http://opscode.com/chef/install.sh | sudo bash
vagrant$ rm /tmp/chef*{rpm,deb}
vagrant$ exit
% vagrant package $VAGRANTBOX
% rm -rf ~/.vagrant.d/boxes/$VAGRANTBOX
% vagrant box add $VAGRANTBOX package.box
@sperlic
sperlic / fabfile.py
Created May 13, 2012 10:01 — forked from whiteinge/fabfile.py
Example fabric script with VirtualBox automation
# -*- coding: utf-8 -*-
"""MyCompany Fabric script.
* Deploy code
* Set up a local development environment
There are two ways to deploy the myrepo code:
1. :func:`deploy` will do a full virtualenv installation/update and expand a
tarball of the specified git revision (defaults to HEAD) to a timestamped
@krosenvold
krosenvold / gist:2508909
Created April 27, 2012 12:43
Try this on your multimodule maven build and watch the performance difference !
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
.....
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>1.8.6</version>
</dependency>
@jtimberman
jtimberman / rename-node.rb
Created March 2, 2012 07:47 — forked from mpasternacki/rename-node.rb
A knife exec script to change Chef node's name.
#!./bin/knife exec
# A knife exec script to change chef node's name, preserving all the attributes.
#
# Usage: knife exec rename-node.rb old-name new-name
#
# Script retrieves the Node object, changes its 'name' attribute,
# creates new Node object with updated name and rest of attributes
# untouched. Then it deletes old Node and Client objects from
# database, and logs into the server to update it:
@chowey
chowey / syntax.js
Created February 18, 2012 22:32
Jade Syntax Checker
var jade = require('jade'),
runtime = require('jade/lib/runtime'),
spawn = require('child_process').spawn,
fs = require('fs');
function parse(str, filename){
var options = {filename: filename, compileDebug: true};
try {
// Parse
var parser = new jade.Parser(str, filename, options)
@emk
emk / apache-logs-hive.sql
Created January 3, 2012 18:01
Apache log analysis with Hadoop, Hive and HBase
-- This is a Hive program. Hive is an SQL-like language that compiles
-- into Hadoop Map/Reduce jobs. It's very popular among analysts at
-- Facebook, because it allows them to query enormous Hadoop data
-- stores using a language much like SQL.
-- Our logs are stored on the Hadoop Distributed File System, in the
-- directory /logs/randomhacks.net/access. They're ordinary Apache
-- logs in *.gz format.
--
-- We want to pretend that these gzipped log files are a database table,