This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple and Stupid Ruby API for Coderwall.com | |
# Vivien Didelot <vivien@didelot.org> | |
require "open-uri" | |
require "json" | |
module CoderWall | |
class Achievement | |
attr_reader :name, :badge, :description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "mail" | |
require "optparse" | |
imap_opts = { | |
:address => "imap.gmail.com", | |
:port => 993, | |
:enable_ssl => true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insert_into file, lineno, text | |
new_text = File.readlines(file).insert(lineno, text + "\n").join | |
File.open(file, 'w') { |f| f.write new_text } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :first, :arg1, :arg2 do |t, args| | |
puts "first" | |
Rake::Task[:second].invoke(args.arg1, args.arg2) | |
end | |
task :second, :arg1, :arg2 do |t, args| | |
puts "second" | |
puts args.arg1 | |
puts args.arg2 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'coderay' | |
class CodeRay::Tokens | |
def each_token | |
lineno = 1 | |
self.each_slice(2) do |token, kind| | |
yield token, kind, lineno | |
lineno += token.count("\n") if token.is_a?(String) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# An approximative Wikipedia/Mechanize version of: | |
# curl -s http://data.iana.org/TLD/tlds-alpha-by-domain.txt | grep -v XN | sed -e 1d -e 's/\(.*\)/\L\1/' | |
# Vivien Didelot <vivien@didelot.org> | |
require 'mechanize' | |
wikipedia_page = "http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains" | |
agent = Mechanize.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 2ac63f597648408c225ea43a447363f7b913a035 Mon Sep 17 00:00:00 2001 | |
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com> | |
Date: Wed, 6 Jun 2012 12:24:47 -0400 | |
Subject: [PATCH] io: use system() if a command contains a pipe | |
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> | |
--- | |
io.c | 4 ++++ | |
1 file changed, 4 insertions(+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ToHash | |
def to_loaded_hash | |
fields = properties.select { |p| p.loaded?(self) }.map(&:name) | |
hash = {} | |
fields.each { |f| hash[f] = self[f] } | |
hash | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fetch last few tweets, unauthenticated. | |
# | |
# I just want the last few tweets of a user, I really don't want to do this: | |
# http://stackoverflow.com/a/15314662 | |
require 'open-uri' | |
require 'cgi' | |
require 'openssl' | |
module Twitter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
map_num () { | |
tr , '\n' | grep '"num":' | cut -d: -f2 | |
# equivalent to jshon -a -e num | |
echo 11 | |
} | |
next_min () { | |
sort -n | cat -n | awk '{ if ($1 != $2) { print $1; exit } }' |