Skip to content

Instantly share code, notes, and snippets.

View bindzus's full-sized avatar

Thomas Bindzus bindzus

View GitHub Profile
<!-- File: app/views/layouts/application.html.erb -->
<%= yield %>
@iboard
iboard / ruby-destructor-example.rb
Last active March 21, 2025 09:32
Ruby 'Destructor' example.
class Foo
attr_reader :bar
def initialize
@bar = 123
ObjectSpace.define_finalizer( self, self.class.finalize(bar) )
end
def self.finalize(bar)
proc { puts "DESTROY OBJECT #{bar}" }
end
@alejandro-isaza
alejandro-isaza / gist:5717438
Last active June 22, 2017 09:51
UIImage category to normalize image orientation by rotating an image so that it's orientation is UIImageOrientationUp. Based on http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload/5427890#10611036
@interface UIImage (Orientation)
- (UIImage*)imageByNormalizingOrientation;
@end
@implementation UIImage (Orientation)
- (UIImage*)imageByNormalizingOrientation {
@jbenet
jbenet / simple-git-branching-model.md
Last active March 19, 2025 16:09
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

var printMap = function(map) {
map.setOptions({
mapTypeControl: false,
zoomControl: false,
streetViewControl: false,
panControl: false
});
var popUpAndPrint = function() {
dataUrl = [];
@Stanback
Stanback / nginx.conf
Last active March 30, 2025 03:57 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
**TODO: make gem for this**
This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.
# Bower
1. Set the install directory for Bower components:
```js
// .bowerrc
@magnetikonline
magnetikonline / README.md
Last active February 18, 2025 08:11
Setting Nginx FastCGI response buffer sizes.
@blairanderson
blairanderson / DependencyInjectionInRuby.md
Last active December 18, 2024 23:08
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

#!/bin/bash
# Thu Nov 7 18:43:39 IST 2013, [email protected] (ramonrails)
# Borrowed from gitflow & bumpversion (URLs referenced below) and enhanced further
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically