Skip to content

Instantly share code, notes, and snippets.

View asaaki's full-sized avatar
🦀
Oh crab!

Christoph Grabo asaaki

🦀
Oh crab!
View GitHub Profile
# baseline REE environment settings for server environments
# http://www.rubyenterpriseedition.com/documentation.html#_garbage_collector_performance_tuning
## ruby defaults
# RUBY_HEAP_MIN_SLOTS=10000
# RUBY_HEAP_SLOTS_INCREMENT=10000
# RUBY_HEAP_SLOTS_GROWTH_FACTOR=1.8
# RUBY_GC_MALLOC_LIMIT=8000000
# RUBY_HEAP_FREE_MIN=4096
@jed
jed / LICENSE.txt
Created May 17, 2011 06:33 — forked from 140bytes/LICENSE.txt
publish/subscribe, or pubsub
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@asaaki
asaaki / pygments-monokai.css
Created June 4, 2011 00:57
Jekyll module for github like source code highlighting
.highlight { background-color: #49483e }
.c { color: #75715e } /* Comment */
.err { color: #960050; background-color: #1e0010 } /* Error */
.k { color: #66d9ef } /* Keyword */
.l { color: #ae81ff } /* Literal */
.n { color: #f8f8f2 } /* Name */
.o { color: #f92672 } /* Operator */
.p { color: #f8f8f2 } /* Punctuation */
.cm { color: #75715e } /* Comment.Multiline */
.cp { color: #75715e } /* Comment.Preproc */
@tute
tute / sortable_controller_methods.rb
Created June 17, 2011 03:31
Rails SortableMethods
# lib/sortable_controller_methods.rb (must then load lib files manually)
# Add in "sortable" controllers:
# include SortableControllerMethods
#
# As in http://railscasts.com/episodes/147-sortable-lists
module SortableControllerMethods
def sort
klass.all.each do |object|
object.position = params[object.class.to_s.downcase].index(object.id.to_s) + 1
object.save
@iain
iain / README.markdown
Created June 25, 2011 10:19
RSpec Formatter to load SimpleCov

SpecCoverage formatter

This formatter loads SimpleCov a code coverage reporting tool for Ruby 1.9. SimpleCov already does a good job in making it really easy to configure and load itself, but even good efforts can be improved upon.

The only problem is that you'll need to have something like a spec_helper to load it. You might not have this or you might find it ugly having to resort to environment variables to turn it off or on.

With this formatter, SimpleCov will start, and it will load a .coverage file in which you can add ruby code to configure SimpleCov in a non-obtrusive way. Configuration for a typical Rails app will look like this:

SimpleCov.start 'rails'
@jemminger
jemminger / async.rb
Created July 2, 2011 14:25
Make any Ruby method asynchronous
# from http://stackoverflow.com/questions/6499654/is-there-an-asynchronous-logging-library-for-ruby/6527134#6527134
require 'thread'
require 'singleton'
require 'delegate'
require 'monitor'
class Async
include Singleton

Detective

What is it?

Simply put, this is a ruby testing library which asks questions in order to determine compliance.

That is, you ask the user questions with "ask", and test results with "expect". You can also give instructions with "instruct".

The entire testing suite is evaluated using the command-line. e.g.

@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@peterc
peterc / README
Created July 11, 2011 12:29
testrocket: My entry to the CodeBrawl.com "Ruby testing libraries" contest
TestRocket is a simple, tiny testing library for Ruby 1.9.
If => in a hash is a "hash rocket", then +-> and --> for tests should be
"test rockets"!
Simple syntax:
+-> { block that should succeed }
--> { block that should fail }
@martinciu
martinciu / README.markdown
Created July 23, 2011 19:46
me.rb - My entry to the CodeBrawl.com "Terminal admin" contes

me.rb

In almost every my project there is a model that refers to myself. It can be an instance of User, Staff, Admin, Dude, etc. I use it for logging in and testing staff. I use it many times in rails console as well. Because typing User.where(:email => '[email protected]').first can by annoying so I've put together little snippet that work in Mongoid and AcitveRecord as well.

$ rails console
Loading development environment (Rails 3.1.0.rc4)
>> load 'me.rb'
=&gt; nil