Skip to content

Instantly share code, notes, and snippets.

View floere's full-sized avatar
😁
Open Sourcing

Florian R. Hanke floere

😁
Open Sourcing
View GitHub Profile
@floere
floere / harakiri.rb
Created July 29, 2010 07:46
Unicorn Harakiri Middleware
# Simple Rack Middleware to kill Unicorns after X requests.
#
# Use as follows in e.g. your rackup File:
#
# Rack::Harakiri.after = 50
# use Rack::Harakiri
#
module Rack
class Harakiri
@alloy
alloy / gist:707398
Created November 19, 2010 23:24
Method implementation
def make_pony_eyes_pink
before, Pony.eye_color = Pony.eye_color, :pink
yield
ensure
Pony.eye_color = before
end

GIT ChangeLOG tool - git clog

Makes pretty changelogs

Installation

chmod +x git-clog
cp git-clog /usr/local/bin  # Or whereever that's in your path

Usage

@ncr
ncr / How I run this
Created April 2, 2011 06:25
The little stress test
~/dev/parslet$ rvm use 1.8.7-p302
Using /Users/ncr/.rvm/gems/ruby-1.8.7-p302
~/dev/parslet$ bundle exec rspec spec/parslet/mem_stress_spec.rb
23.030000 1.290000 24.320000 ( 24.331595)
.
Finished in 24.33 seconds
1 example, 0 failures
~/dev/parslet$ rvm use 1.9.2
Using /Users/ncr/.rvm/gems/ruby-1.9.2-p180
@karmi
karmi / _readme.markdown
Created April 17, 2011 11:06
Simplistic Full-Text Search With Redis

Simplistic Full-Text Search With Redis

Howto

git clone git://gist.github.com/923934.git redisearch

cd redisearch

This week, we'll have some fun with MacRuby. James is a “Voice commanded servant for OSX” you can write dialogs for. Here's a lightning talk by Florian Hanke, James' creator.

For example, you could set up a time dialog to ask James what time it is:

<< James, what time is it?
>> It is currently 10:15.

Of course, that's a pretty simple example. This week's challenge is to write the most useful or fun dialog for James. You can do about anything, like asking James to do API requests, reboot your machine, run your tests, or whatever you can think of. A simple dialog is enough, but please remember to keep the code nice and understandable.

Haven't used MacRuby before? Just really easy to install using the binary installer. Be sure to check out James' README and have a look through its [example directory]

@floere
floere / loader.rb
Created June 29, 2012 01:36
Live Reloading of Code: Presentation at Melbourne Roro
# Version 1: Fails, since this file is not reloaded.
#
module Loader
def self.reload
puts "Loading application."
load File.expand_path "../worker.rb", __FILE__ # Change this to new_worker
load File.expand_path "../signal.rb", __FILE__
end
@floere
floere / hashmemtest1.rb
Last active August 29, 2015 13:56
Quick hash memory test to understand high memory usage when using hashes in Ruby 1.9.3 and 2.1.0 (regarding newly created strings and old hashes).
# We repeatedly fill a hash.
# We use the same keyspace each time after the first time.
#
# My expectation was that the total memory used would not increase significantly after the first iteration.
#
h = {}
10.times do |i|
100000.times do |i|
h[i.to_s] = [1,2,3]
end
@AliSoftware
AliSoftware / GHDiff-HidePods.js
Last active February 13, 2017 11:40
Hide Pods/* related files in a GitHub diff page
// When you are in the diff page of a GitHub PR
// And want to hide all the Pods/* files in that diff page, use this:
// Paste that in your Web Inspector's console
var nodes = document.evaluate("//div[@class='file-header' and starts-with(@data-path,'Pods/')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
for(i=0; i<nodes.snapshotLength; ++i) {
nodes.snapshotItem(i).parentNode.hidden = true
}
// Or even better, create a bookmark with this code for easy quick access:
@MelissaKaulfuss
MelissaKaulfuss / installing_ruby_versions_with_chruby.md
Last active August 4, 2023 19:28
How to install different Ruby versions with chruby

Managing Ruby Versions with chruby

So I'm always forgetting how to do this! I guess I'm only ever updating Ruby versions every now and then.

Checking out which Ruby versions chruby has access to

$ chruby will display your installed rubies and show you the version you're currently using in your shell.

   ruby-2.1.2
   ruby-2.2.1
 ruby-2.3.1