Skip to content

Instantly share code, notes, and snippets.

@webcoyote
webcoyote / rollbar.rb
Created July 7, 2014 22:40
Rollbar provisioning - create teams and projects for Rollbar.com
#!/usr/bin/env ruby
# by Patrick Wyatt
require 'json'
require 'net/http'
require 'openssl'
require 'uri'
class Rollbar
def initialize (read_token, write_token)
#!/bin/bash
echo testing "$@"
@webcoyote
webcoyote / .kitchen.yml
Created September 10, 2014 23:12
Test kitchen configuration initialized by discovering the values from Chef-server
# test-kitchen YAML configuration file which discovers values from Chef environment
#
# Manual configuration got you down?
# Don't want to pollute your shell environment with a bunch of secrets?
# Why not load those values from Chef?!?
#
<%
require 'yaml'
using UnityEngine;
using System;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
public class Main : MonoBehaviour {
private class TimeFunc {
public TimeFunc (string name, Func<float> time, bool applyDelta = true) {
@webcoyote
webcoyote / WalkDir.rb
Created September 13, 2011 22:21
Log file iterator pattern
require 'pathname'
require 'date'
class WalkDir
def initialize (opts = {})
# Set default handlers
@file_pattern = opts[:file_pattern] || /^[^.]/ # no hidden files
@dir_pattern = opts[:dir_pattern] || /^[^.]/ # no hidden directories
@result = opts[:result] || lambda { |pathname, match| return pathname, match }
@webcoyote
webcoyote / PlatformTime.cpp
Created December 11, 2012 19:06
Transaction rate-limiting
unsigned PlatformTimeMs () {
#if defined(_WINDOWS_)
return GetTickCount();
#else
#error Your implementation here
// something like clock_gettime(CLOCK_MONOTONIC, ...) for Unix/Linux
#endif
}
@webcoyote
webcoyote / create-or-update.sql
Created December 11, 2012 19:15
Update SQL stored procedure
-- if the stored procedure does not exist then create a placeholder
if not exists (
select * from sys.objects where object_id = OBJECT_ID(N' p_MyProc')
and type = N'P'
) then
create procedure p_MyProc as RAISERROR ('MyProc not defined', 16, 1);
grant execute on p_MyProc to SomeRole
end
-- update stored proc
@webcoyote
webcoyote / dirglob.rb
Created February 5, 2013 21:13
Ruby directory globbing
Dir.glob(
'**/*', File::FNM_DOTMATCH
).reject { |a| a =~ /\.{1,2}$/ }.each do |f|
puts f
end
@webcoyote
webcoyote / KEYBOARD.md
Created February 10, 2013 06:25
Notes for fixing Windows key to be usable by xmonad desktop manager in Linux virtual machine

XMonad keyboard fix

remapping the #$#$ Windows key so it can be used in Linux VM

  1. Compile xmonad.hs to use modMask = mod3Mask ("mod3")

  2. Use SharpKeys.exe on Windows host to remap "Left Windows" key to "F15", which is unused on modern keyboards. Reboot.

  3. In Linux guest, type the "Left Windows" key. Then dmesg|tail -5 should produce output like this:

@webcoyote
webcoyote / SearchConfigFile.rb
Created May 1, 2013 22:03
Search for a configuration file in current directory upwards towards root directory the way that .gitignore and .p4config work
#!/usr/bin/env ruby
class SearchConfigFile
def self.search (filename, directory)
# Use current directory if directory not specified
directory ||= Dir.getwd
# Use expand_path to get absolute path; 1.8.7 compatible
search_up filename, File.expand_path(directory)