Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
@tpope
tpope / githubmail.rb
Created March 19, 2014 01:00
Add a gmail label to all closed issues where I the tpope last commented
require 'gmail'
require 'github_api'
require 'netrc'
require 'pry'
netrc = Netrc.read
github = Github.new(basic_auth: netrc['api.github.com'].join(':'))
Gmail.new(*netrc['imap.gmail.com']) do |gmail|
gmail.inbox.emails(from: 'github.com').each do |message|
begin
@macournoyer
macournoyer / ghi.rb
Created December 7, 2009 21:20
CLI for github issues WITH COLORS!
#!/usr/bin/env ruby
require "rubygems"
require "mutter"
require "httparty"
REMOTE = "origin"
REPO = `git config --get remote.#{REMOTE}.url`.chomp[/github\.com[\/\:]([^\/]+\/[^\/]+)\.git/, 1]
USER = `git config --get github.user`.chomp
TOKEN = `git config --get github.token`.chomp
@JackDanger
JackDanger / forgetful.js
Created June 22, 2010 00:28
forgetful.js
// Forgetful.js is what I use on SSDs to prevent disk wear.
// Because each SSD sector can only be written a set # of times
// it's important not to write huge log files for no reason.
// So my test logs (and some others) are all outputted to this
// node.js instance which keeps track of the throughput
// in simply-named channels.
//
// To use this in, e.g., Rails, put this in environments/test.rb:
//
// class NamedChannelSocket < TCPSocket
# Include an anonymous module
#
# Useful for defining a class with a base module. So, instead of:
#
# class Foo
# module Base
# def bar
# # ...
# end
# end
@drnic
drnic / .gitignore
Created October 1, 2010 22:18 — forked from mloughran/README.md
twitter.json
require 'rubygems'
require 'mechanize'
require 'httparty'
# Ugly code, for an ugly hack.
# Hey, if Lighthouse didn't suck then none of this would happen.
# It's been lotsa fun coding it though, so I suppose I should be thankful for the "opportunity"
@tomafro
tomafro / instrumentation.rb
Created February 18, 2011 09:13
Experimental Mongo Instrumentation for Rails 3
module Mongo
module Instrumentation
def self.instrument(clazz, *methods)
clazz.module_eval do
methods.each do |m|
class_eval %{def #{m}_with_instrumentation(*args, &block)
ActiveSupport::Notifications.instrumenter.instrument "mongo.mongo", :name => "#{m}" do
#{m}_without_instrumentation(*args, &block)
end
end
@ryanmcgrath
ryanmcgrath / loader.css
Created September 6, 2011 21:55
HTML and CSS for a CSS3 (mobile-OS hardware accelerated) loading spinner.
#spinnerContainer {
display: none;
position: absolute;
top: 340px;
right: 350px;
width: 54px;
height: 54px;
}
#spinner {
@robertsosinski
robertsosinski / bottom-up.sql
Created June 29, 2012 18:07
Recursive querys in PostgresSQL
with recursive category_ancestors (id, parent_id, name) as (
select id, parent_id, name
from categories where id = 123
union
select parent.id, parent.parent_id, parent.name
from categories parent
inner join category_ancestors on parent.id = category_ancestors.parent_id
)
select * from category_ancestors;
@nelstrom
nelstrom / vim-keystrokes.rb
Created December 5, 2012 16:14
A proof-of-concept parser for making Vim keystrokes more readable.
require 'parslet'
class Mini < Parslet::Parser
rule(:start) { match('[iIaAoOsS]').as(:switch) }
rule(:typing) { match('[^\e]').repeat.as(:typing) }
rule(:terminate) { match('\e').as(:escape) }
rule(:insertion) { start >> typing >> terminate }
root(:insertion)
end