Skip to content

Instantly share code, notes, and snippets.

☎️
call me on my #!/bin/sh phone

Matthew Loberg mloberg

☎️
call me on my #!/bin/sh phone
Block or report user

Report or block mloberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mloberg
mloberg / bot.js
Created Jun 22, 2012
NodeJS - Werebot
View bot.js
var irc = require('irc'),
werewolf = require('./game');
var client = new irc.Client('server', 'Werebot', {
channels: [ '#channel' ],
autoConnect: false
});
client.connect();
client.addListener('registered', function(msg) {
@mloberg
mloberg / gist:2937062
Created Jun 15, 2012
Replace local links in markdown ([[link]]) with normal links ([link](link)).
View gist:2937062
#!/bin/sh
PREFIX=wiki
FILES=$(find . -type f -iname '*.md' -o -iname '*.markdown')
if [[ "$1" == "revert" ]]; then
# To Parse back to normal local [[links]]
for file in $FILES; do
sed -e 's/\[\(.*\)\](\/$PREFIX\/\(.*\))/[[\1]]/g' $file > $file.tmp
mv $file.tmp $file
@mloberg
mloberg / gist:2852153
Created Jun 1, 2012
MySQL Slow Query Log Analyzer
View gist:2852153
#!/usr/bin/php
<?php
/**
* The Analyzer class.
*/
class Analyzer {
private $fp;
@mloberg
mloberg / libcurl.fb-changes.diff
Created Apr 13, 2012
HipHop PHP libcurl Patch for Curl 2.25
View libcurl.fb-changes.diff
Index: include/curl/multi.h
===================================================================
RCS file: /cvsroot/curl/curl/include/curl/multi.h,v
retrieving revision 1.45
diff -u -r1.45 multi.h
--- curl-old/include/curl/multi.h 20 May 2008 10:21:50 -0000 1.45
+++ curl-new/include/curl/multi.h 29 Jan 2010 23:45:18 -0000
@@ -135,6 +135,19 @@
int *max_fd);
View irc.rb
require "socket"
class IRC
def initialize(info)
@server = info[:server]
@port = info[:port] || 6667
@password = info[:password]
@nick = info[:nick]
@channel = info[:channel]
View gist:1663355
// MooTools
var onImagesLoad = function(callback){
var images = 0,
check;
$$("img").each(function(item, key){
images++;
var img = new Image();
img.onload = function(){
images--;
};
@mloberg
mloberg / gist:1628239
Created Jan 17, 2012
Responsive Grid
View gist:1628239
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
@mloberg
mloberg / upload.rb
Created Dec 16, 2011
qq.FileUploader Ruby
View upload.rb
directory = './tmp/'
# ajax upload
if params[:qqfile].class == String
name = params[:qqfile]
string_io = request.body
data_bytes = string_io.read
path = File.join(directory, name)
File.open(path, "w") do |f|
f.write(data_bytes)
end
View aacinfo.rb
##
# Name: AACInfo
# Author: Matthew Loberg
# Author URL: http://twitter.com/mloberg
# Description:
# I couldn't get MP4Info to read the tags of my iTunes music files, so I created this little class.
# It uses faad to get the tag info, so make sure it's installed (brew install faad2)
require 'iconv'
class AACInfo
@mloberg
mloberg / Popcorn.SourceCode.js
Created Nov 14, 2011
Popcorn Source Code Plugin
View Popcorn.SourceCode.js
/**
* Popcorn SourceCode Plugin v0.1
* http://mattwritescode.com/2011/11/popcorn-source-code-plugin/
*
* Copyright 2011 Matthew Loberg (http://mloberg.com)
* Licensed under the MIT license
*
* Description:
* Add source code pre/code element to the page.
* If Google Code Prettify <http://code.google.com/p/google-code-prettify/>
You can’t perform that action at this time.