Skip to content

Instantly share code, notes, and snippets.

View defeated's full-sized avatar
💭
I may be slow to respond.

eddie cianci defeated

💭
I may be slow to respond.
View GitHub Profile
@amateurhuman
amateurhuman / gist:2005745
Created March 9, 2012 09:03
Installing Rubinius 2.0.0-dev with rbenv

Installing rbx-2.0.0-dev with Ruby 1.9 support using rbenv can be a tad tricky. This is what I did to get up and running, you'll need another version of ruby already installed as well as rake.

The basic outline:

  1. Clone Rubinius HEAD from github
  2. Configure installation for rbenv and 1.9 support
  3. Install Rubinius
  4. Configure your $PATH to use Rubinius gems
  5. Start using Rubinius
@karlseguin
karlseguin / now.go
Created June 9, 2013 07:28
Testable time.Now in GoLang
package t
import (
"time"
)
type NowFunc func() time.Time
var Now = func() time.Time { return time.Now() }
func NowForce(unix int) {
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@rubiojr
rubiojr / mr_status_bar_app.rb
Created November 30, 2009 11:47
MacRuby StatusBar Application
#
# Initialize the stuff
#
# We build the status bar item menu
def setupMenu
menu = NSMenu.new
menu.initWithTitle 'FooApp'
mi = NSMenuItem.new
mi.title = 'Hellow from MacRuby!'
mi.action = 'sayHello:'
@steveklabnik
steveklabnik / ember_template.rb
Last active June 4, 2016 16:57
A template for making Ember apps with Rails.
run "sed --in-place '/turbolinks/d' Gemfile"
run "sed --in-place '/turbolinks/d' app/assets/javascripts/application.js"
run "sed --in-place '/coffee/d' Gemfile"
run "sed --in-place '/jbuilder/d' Gemfile"
run "sed --in-place 's/, \"data-turbolinks-track\" => true//' app/views/layouts/application.html.erb"
gem 'active_model_serializers'
# app/views/posts/new.html.erb
<%= form_for(Post.new) do |form| %>
Title: <%= form.text_field :title %>
Body: <%= form.text_field :body %>
<% end %>
...would produce a signature field that can be used to automatically untaint:
<input type="hidden" name="signature" value="....">
@javan
javan / application_controller.rb
Created November 30, 2013 22:06
Prevent cross-origin js requests
class ApplicationController < ActionController::Base
before_filter :ensure_xhr
private
def ensure_xhr
if request.get? && request.format && (request.format.js? || request.format.json?)
head :forbidden unless request.xhr?
end
end
end
@subelsky
subelsky / puma_rails_heroku.rb
Created October 31, 2012 13:51
Setting up Puma and Rails on Heroku
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this:
@ls-lukebowerman
ls-lukebowerman / sitemap.xml.erb
Created August 7, 2012 17:59
Sitemap (sitemaps.org) generator for Middleman
<% pages = sitemap.resources.find_all{|p| p.source_file.match(/\.html/) } %>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<% pages.each do |p| %>
<url>
<loc>http://youdomain.com/<%=p.destination_path.gsub('/index.html','')%></loc>
<priority>0.7</priority>
</url>
<% end %>
</urlset>
@flomotlik
flomotlik / Gemfile
Last active April 6, 2021 13:17
Puma on Heroku
gem 'foreman'
gem 'puma'