Skip to content

Instantly share code, notes, and snippets.

View bravoecho's full-sized avatar

Luca bravoecho

  • UK
  • 08:06 (UTC +01:00)
View GitHub Profile
# Re-write for run by @_ZPH
# OO Ruby
gem = File.open('Gemfile').readlines.reject { |l| l =~ /lame/ }.join
File.write('Gemfile', gem)
# obtuse bash
grep -v "lame" Gemfile > !!3.new && mv !!3{.new,}
# ruby one liner
ruby -i -ne 'print unless /lame/' Gemfile
@rwjblue
rwjblue / readme.md
Last active May 13, 2016 18:10
Guide to using drip with JRuby

#Overview drip is an awesome command line tool that can be used to dramatically lower perceived JVM startup time. It does this by preloading an entirely new JVM process\instance and allowing you to simply use the preloaded environment. This has extraordinary results with jruby.

We reduced time to run rake environment from 13 seconds to a mere 3.5 seconds. This is actually at or near MRI 1.9.3p327 (with falcon patch) speeds!

Adding a few addition jruby options will reduce startup time even further (down to 1.69 seconds).

#Install Drip Install drip if you haven't already (see https://github.com/flatland/drip)

@practicingruby
practicingruby / idea.md
Last active December 10, 2015 22:49
Evidence based software development

I am considering starting up a community-funded project that is aimed at exploring software development methodologies and practices through the lens of evidence-based scientific studies. The purpose of this project would be to design, conduct, and report on real world experiments that attempt to answer questions that are relevant to everyday programmers.

This project would be subscriber-supported, but would follow a completely open publication model.

Subscribers would pay a small fee (maybe $5 to $10/month) and get all of the following benefits:

  • A monthly progress report summarizing all interesting activity on the project
  • Opportunities to read early drafts of articles
  • Opportunities to participate in pilot sessions for studies
  • Access to a members-only mailing list to discuss research activities with other supporters and with the project's maintainers.
@jimweirich
jimweirich / approximately.rb
Last active December 10, 2015 21:29
Evidently I'm rusty on my Ruby coercion rules, because the following surprised me.
class ApproximateNumber
attr_reader :number, :delta
def initialize(number, delta)
@number = number
@delta = delta
end
def ==(value)
(number-value).abs <= delta
# some ./app/helpers/some_helper.rb, in my case actually in an engine gem
module SomeGemHelper
def my_gem_decorate(model)
# Here I'm hard-coding to always decorate with MyDecorator,
# but it could also be passed in as a method arg, or guessed
# from the model.class name, or from a differnet model attribute
# like model.presenter_class, or taken from configuration, or
# some combination -- whatever meets the needs of your design.
decorated = MyDecorator.new(model, self)
yield if block_given?
@jrochkind
jrochkind / gist:4342817
Created December 20, 2012 03:48
Still SimpleDelegator based Decorator, but with an ActionView::Context view_context passed in too
require 'delegate'
class Base
def foo
"foo"
end
def bar
"bar"
end
end
@practicingruby
practicingruby / mrdi.md
Created December 19, 2012 22:29
Models, Roles, Decorators, and Interactions -- A modest proposal for a toned done version of DCI that isn't as janky as Concerns.

Models, Roles, Decorators, and Interactions

A modest alternative to DCI that might be worth further thought

One of the problems with advancing the discussion on DCI is that we lack a comparable alternative pattern that has the same goals, but favors a low ceremony approach. The closest thing we have to that is Rails concerns, but they are more like distant relatives of the DCI concepts rather than first cousins, and that makes comparisions between the two approaches not especially fruitful.

I am considering the idea of experimenting with my own paradigm that captures the intent and purity of DCI, but with the convenience of concerns. Please note that this is just the starting point of a conversation, it is NOT a promise of comercially available cold fusion or a cure for cancer. It's just a gist with an idea on it I'd like to hear your thoughts on.

What if we had a top-level topology that was split into Models, **Rol

@joewalnes
joewalnes / home-yet.py
Created December 14, 2012 03:12
Am I home yet?
#!/usr/bin/env python
"""A tiny script that polls your location on Google Latitude, and updates
the color of a Blink1 LED. http://shop.thingm.com/blink1/
Red = At work
Blue = At home
Green = On my way
Should work on Windows, OS-X and Linux. Requires Python 2.7 or later.
@jimweirich
jimweirich / take_off_and_land.rb
Created November 6, 2012 20:20
Ruby control of an Parrot AR Drone
# See video at: http://www.youtube.com/watch?v=3NlYGn3QY4U&feature=youtu.be
require 'socket'
class ATCommand
def initialize(socket, host=nil)
@host = host || '192.168.1.1'
@socket = socket
@tick = 0
@buffer = ""
@macournoyer
macournoyer / abc.rb
Created November 5, 2012 17:16
First programming lesson w/ my 4yo daughter
alphabet = 'A'..'Z'
`say "#{alphabet.to_a.join(', ')}"`