Skip to content

Instantly share code, notes, and snippets.

View mlooney's full-sized avatar

McClain Looney mlooney

View GitHub Profile
require 'csv'
k = CSV.open('report.csv', :headers=>:skip).map do |r|
z = r.to_hash.values
[z.shift, z.map(&:to_i).select{|x| x!=0}.inject(0){|m,_|m+=1}]
end
puts k.select{|_,v| v == 0}.map{|y,_| y}
import util from 'util'
import xml4js from 'xml4js'
let xml = `<?xml version="1.0"?> <Element xmlns:xsi="x" xsi:noNamespaceSchemaLocation="y"> </Element>`
let result = xml4js.parseString(xml, {}, (err, result) => {
if (err) {
console.log("error: "+util.inspect(err))
} else {
console.log("success: "+ util.inspect(result, false, null))
}
filled_rows = :array.foldl(fn _, value, acc ->
case value do
nil -> acc ++ [false]
data -> acc ++ [true]
end
end, [], state.block_data)
### Keybase proof
I hereby claim:
* I am mlooney on github.
* I am mml (https://keybase.io/mml) on keybase.
* I have a public key whose fingerprint is B725 151A 0D28 9389 EA9C 64DB 8C06 BB0D 5692 42CB
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am mlooney on github.
  • I am mml (https://keybase.io/mml) on keybase.
  • I have a public key whose fingerprint is 930B CFB1 0518 29B6 E369 722E 5818 9DD4 443F 16B2

To claim this, I am signing this object:

Build/configure flags
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql --docdir=/usr/local/Cella
r/postgresql/9.1.2/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uui
d --with-python --with-perl ARCHFLAGS='-arch x86_64'
./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql --docdir=/usr/local/Cellar/po
stgresql/9.1.2/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --
with-python --with-perl ARCHFLAGS='-arch x86_64'
Interesting configure output:
@mlooney
mlooney / gist:1761238
Created February 7, 2012 18:57
Netty Discard server ported to jruby
require 'java'
require 'jar/netty-3.3.1.Final.jar'
import 'java.net.InetSocketAddress'
import 'java.util.concurrent.Executors'
import 'org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory'
import 'org.jboss.netty.bootstrap.ServerBootstrap'
import 'org.jboss.netty.channel.SimpleChannelHandler'
import 'org.jboss.netty.channel.ChannelPipelineFactory'
import 'org.jboss.netty.channel.ChannelFactory'
class Bofh
include Purugin::Plugin, Purugin::Colors
description 'Bofh', 0.1
player_command("zap", "zap player with lightning", "/zap") do |me, *args|
player = me.world.players.select {|x| x.name.downcase == args.first.downcase}.pop
if player
me.world.strikeLightning(player.location)
else
me.msg yellow("couldn't find player #{args.first}")
end
@mlooney
mlooney / gist:1653268
Created January 21, 2012 16:52
Extract chat history from skype logs
corpus = Hash.new {|h,k| h[k]=[]}
SQLite3::Database.new( "/Users/username/Library/Application Support/Skype/skypename/main.db", :readonly=>true ) do |db|
db.execute("select timestamp,author, body_xml from messages") do |row|
ts, author, body = row
corpus[author]<<(body) if body
end
end
corpus.each do |k,v|
File.open("corpus_#{k}.txt", 'w') do |f|
<form accept-charset="UTF-8" action="/user_session" class="form-stacked formtastic user_session" id="new_user_session" method="post">
<fieldset class="inputs" name="Login">
<legend><span>Login</span></legend>
<ol>
<li class="string required" id="user_session_email_input">
<label for="user_session_email">Email</label>
<input id="user_session_email" name="user_session[email]" type="text">
</li>
<li class="password required" id="user_session_password_input">
<label for="user_session_password">Password</label>