Skip to content

Instantly share code, notes, and snippets.

View warmwaffles's full-sized avatar
🛠️
Code Wrestling

Matthew Johnston warmwaffles

🛠️
Code Wrestling
View GitHub Profile
#!/usr/bin/env bash
# Colours picked from https://robinpowered.com/blog/best-practice-system-for-organizing-and-tagging-github-issues/
###
# Label definitions
###
declare -A LABELS
# Platform
We couldn’t find that file to show.
@sj26
sj26 / chargify.rb
Created December 14, 2011 13:39
Yet Another Chargify HTTParty-based API gem for Ruby
require 'httparty'
# This may go away:
require 'active_support/all'
# (doesn't *require* Rails, but adds some niceties)
module Chargify
VERSION = "0.0.1".freeze
# Create a default `Client`, attempting to use Rails application config.
def self.client options=nil
@warmwaffles
warmwaffles / widget.rb
Created June 23, 2012 17:00
Have you wanted to ever fuzzy search on your model without actually running Solr or Sphinx? Well this little function can help ease you in
class Widget < ActiveRecord::Base
#
# ..... extra crap here .....
#
scope :active, where(:status => [:active])
#
# This will fuzzy search the model for the provided query. It will split your
@phoet
phoet / menu.rb
Created October 15, 2013 07:52
curses example drawing a menu
require "curses"
include Curses
init_screen
start_color
noecho
def draw_menu(menu, active_index=nil)
4.times do |i|
menu.setpos(i + 1, 1)
@ers35
ers35 / json2sqlite.lua
Last active July 13, 2016 20:01
Convert http://redd.it/3bxlg7 to an SQLite database
-- The author disclaims copyright to this source code.
-- Convert http://redd.it/3bxlg7 to an SQLite database
-- Convert the whole dataset at once like so:
-- find reddit_data -type f -exec time lua json2sqlite.lua {} \;
local cjson = require"cjson"
local sqlite = require"lsqlite3"
local db = sqlite.open("reddit_data.db")
db:exec[[
@jimeh
jimeh / jquery.myplugin.coffee
Created April 7, 2011 23:44
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
@skeeto
skeeto / README.md
Last active December 20, 2021 14:00
AI driving simulation
@troy
troy / send_remote_syslog.php
Last active April 6, 2023 18:19
Send UDP remote syslog message from PHP (RFC 3164)
# replace PAPERTRAIL_HOSTNAME and PAPERTRAIL_PORT
# see http://help.papertrailapp.com/ for additional PHP syslog options
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
foreach(explode("\n", $message) as $line) {
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT);
}
socket_close($sock);
@klange
klange / _.md
Last active December 2, 2023 20:36
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le