Skip to content

Instantly share code, notes, and snippets.

@marcroberts
marcroberts / watch.rb
Created October 7, 2016 11:02
something for watching files in the current directory
#!/usr/local/bin/ruby
require 'rubygems'
require 'inotify'
i = Inotify.new
last_events = {}
@marcroberts
marcroberts / sample.json
Last active August 29, 2015 14:14
Twitter Streaming Sample
{ created_at: 'Mon Jan 26 16:21:26 +0000 2015',
id: 559747954651971600,
id_str: '559747954651971584',
text: 'Мосгорсуд оставил под арестом до 16 апреля Александра Кольченко, фигуранта дела ...',
source: '<a href="http://ifttt.com" rel="nofollow">IFTTT</a>',
truncated: false,
in_reply_to_status_id: null,
in_reply_to_status_id_str: null,
in_reply_to_user_id: null,
in_reply_to_user_id_str: null,
@marcroberts
marcroberts / keybase.md
Created April 14, 2014 08:34
Keybase proof

Keybase proof

I hereby claim:

  • I am marcroberts on github.
  • I am marcroberts (https://keybase.io/marcroberts) on keybase.
  • I have a public key whose fingerprint is 7E21 9E89 C787 9017 93DE 609F EF27 7115 F24C 8714

To claim this, I am signing this object:

@marcroberts
marcroberts / marcroberts.zsh-theme
Created January 30, 2014 09:58
my oh-my-zsh theme
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572).
#
@marcroberts
marcroberts / MakeApp.sh
Created September 12, 2013 14:37
Simple shell script to create a stub OS X app with a custom icon to launch Chrome as a single serving browser
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@marcroberts
marcroberts / private.rb
Last active December 17, 2015 22:49
Private methods in ruby aren't that private
class Thing
private
def some_private_method number
print "Success (#{number})\n\n"
end
end
thing = Thing.new
@marcroberts
marcroberts / object.rb
Created May 31, 2013 12:11
object.new now calls initialise if it exists before trying initialize
class Object
alias :old_initialize :initialize
def initialize(*args,&blk)
if respond_to? :initialise
initialise(*args,&blk)
else
old_initialize(*args,&blk)
end
end
end
@marcroberts
marcroberts / iron_cache_metastore.rb
Created October 25, 2012 14:20
Use IronCache as a Rack::Cache metastore with Rails 3.2 on Heroku
require 'rack/cache'
require 'rack/cache/storage'
require 'rack/cache/metastore'
require 'iron_cache'
class IronCache::MetaStore < Rack::Cache::MetaStore
def initialize
@cache = IronCache::Client.new.cache('metastore')
@marcroberts
marcroberts / WP-United diff
Created July 6, 2010 15:17
Modifications needed to phpBB 3.0.7 for WP-United
diff --git a/includes/acp/acp_main.php b/includes/acp/acp_main.php
index b8712b2..cf456db 100644
--- a/includes/acp/acp_main.php
+++ b/includes/acp/acp_main.php
@@ -337,7 +337,12 @@ class acp_main
}
global $cache;
+
$cache->purge();
@marcroberts
marcroberts / simple_format_with_hypenation.rb
Created August 28, 2009 15:35
Add soft hyphens every 6 characters to words longer than 7 characters
module ActionView
module Helpers
module TextHelper
def simple_format_with_hyphenation(text, html_options={})
simple_format_without_hyphenation(text.gsub(/(\w{6})(\w)/,'\1&shy;\2'), html_options)
end
alias_method_chain :simple_format, :hyphenation