Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
michaelficarra / tame.js
Created July 19, 2011 03:28
possible coffeescript implementation of a TameJS example from http://tamejs.org/
huntMen = (buffy) ->
soulmates = []
while soulmates.length < 10
# get 10 candidates for Buffy
(userids) <- getMatches buffy, 10, *
for u, i in userids
@michaelficarra
michaelficarra / tame.js
Created July 19, 2011 03:51
another TameJS example rewritten in imaginary-coffeescript-with-defer
{resolve} = require "dns"
do_one = (host, cb) ->
(err, ip) <- resolve host, "A", *
console.log if err then "ERROR! #{err}" else "#{host} -> #{ip}"
cb() if typeof cb is 'function'
do_all = (hosts) ->
defer
for host, i in hosts
@michaelficarra
michaelficarra / Datalog.hs
Created August 9, 2011 10:13
simple POC datalog to relational algebra conversion in haskell
module Datalog where
import Data.List
type Predicate = String
type Variable = String
data Rule
= Rule [Atom]
deriving (Eq)
@michaelficarra
michaelficarra / LICENSE
Created September 3, 2011 18:47
bootstrapping a shim library with safe calls
Copyright (c) 2011, Michael Ficarra
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
@michaelficarra
michaelficarra / access.conf
Created September 4, 2011 06:29
/etc/security/access.conf
# Login access control table.
#
# Comment line must start with "#", no space at front.
# Order of lines is important.
#
# When someone logs in, the table is scanned for the first entry that
# matches the (user, host) combination, or, in case of non-networked
# logins, the first entry that matches the (user, tty) combination. The
# permissions field of that table entry determines whether the login will
# be accepted or refused.
@michaelficarra
michaelficarra / yum-update.sh
Created September 4, 2011 06:37
/etc/cron.daily/yum-update.sh
#!/bin/bash
yum=/usr/bin/yum
"$yum" check-update &> /dev/null
[ 0 -eq $? ] && exit 0
"$yum" -y -e 0 -R 10 update yum &> /dev/null
updated=`"$yum" -y -e 0 -R 120 --skip-broken update 2>&1`
num_updated=`echo "$updated" \
| grep -ix "Upgrade\\s\+[0-9]\+\\s\+Package(s)" \
| sed -e 's/Upgrade\s\+\([0-9]\+\)\s\+Package(s)/\1/'`
packages=packages
@michaelficarra
michaelficarra / kernel-check.sh
Created September 4, 2011 06:38
/etc/cron.daily/kernel-check.sh
#!/bin/bash
running_kernel=`uname -r`
latest_kernel=`rpm -q kernel | tail -n1 | sed -e 's/kernel-//'`
[ "$running_kernel" = "$latest_kernel" ] && exit 0
echo "Running Kernel is $running_kernel but latest installed kernel\
is $latest_kernel. This machine should be rebooted." \
| mail -s "$(hostname): reboot required" root
@michaelficarra
michaelficarra / gist:1205551
Created September 9, 2011 05:38
build and install transmission-daemon from source
LIBEVENT_CFLAGS="-I/usr/local/include" LIBEVENT_LIBS="-L/usr/local/lib -levent" ./configure && make && sudo make install && sudo service transmission-daemon restart
@michaelficarra
michaelficarra / etsy-scrape.rb
Created September 13, 2011 05:31
download all the listing images from a given etsy shop
require 'etsy'
Etsy.api_key = '<api-key>'
shop = Etsy::Shop.find '<shop-name>'
out_dir = '<output-directory>'
Etsy.environment = :production
Dir.mkdir out_dir unless File.exists? out_dir
listings = []
@michaelficarra
michaelficarra / gravatar.js
Created October 1, 2011 05:27
firesheep handler for gravatar.com
// Authors:
// Michael Ficarra <github.com/michaelficarra>
register({
name: 'Gravatar',
url: 'http://gravatar.com/emails',
domains: [ 'gravatar.com' ],
sessionCookieNames: [ 'gravatar' ],
identifyUser: function() {