Skip to content

Instantly share code, notes, and snippets.

View rbazinet's full-sized avatar

Rob Bazinet rbazinet

View GitHub Profile
@karlseguin
karlseguin / stat.go
Last active August 29, 2015 13:56
Track data points with constant-space via sampling (can be used to calculate percentiles, for example)
const (
MAX_SAMPLE_COUNT = 50
MAX_SAMPLE_COUNT_F = float64(MAX_SAMPLE_COUNT)
)
type Stat struct {
sync.Mutex
hits int64
samples []int
}
@mudphone
mudphone / curry.exs
Last active August 29, 2015 14:20
Elixir Curry... is delicious
defmodule Math do
def add(x, y) do
x + y
end
def add(x, y, z) do
x + y + z
end
ActionController::Routing::Routes.draw do |map|
map.twitter 'twitter', :controller => "twitter", :action => "twitter"
map.root :controller => "twitter"
end
<!-- ui-dialog -->
<div id="dialog-password-forget-form">
<%= form_tag forgot_password_path, :id => "submit-forgot-password" do %>
<fieldset id="user-email">
<p>
<label>Email address<span><%= email_field_tag :email, '', :id => "email" %></span></label>
</p>
</fieldset>
<% end %>
</div>
@mxriverlynn
mxriverlynn / _partial.html.erb
Created June 23, 2011 02:39
render partial to jquery template
this is a partial. <%= model.value %>
@seyhunak
seyhunak / simple_form.rb
Created December 14, 2011 23:17
Using simple_form and integrating Twitter Bootstrap
1. Use latest build
gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git'
2. Create an initializer
# /config/initializers/simple_form.rb
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a complete input.
# You can remove any component from the wrapper, change the order or even
@scottwater
scottwater / email_queue.rb
Created February 17, 2012 17:47
EmailQueue for Sidekiq
class EmailQueue
include Sidekiq::Worker
def perform(options)
mailer = options['mailer'].constantize
method = options['method']
args = options['args']
mailer.send(method, *args).deliver
end
@kajic
kajic / es.sh
Last active October 1, 2015 07:57 — forked from aaronshaf/es.sh
Install ElasticSearch on Ubuntu 10.04/11.04
cd ~
sudo apt-get update
sudo apt-get install curl python-software-properties -y
sudo apt-get install openjdk-6-jre-headless
curl -L http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.tar.gz | tar -xz
sudo mv elasticsearch-* /usr/local/share/elasticsearch
curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
sudo mv *servicewrapper*/service /usr/local/share/elasticsearch/bin/
rm -Rf *servicewrapper*
@zackify
zackify / dropdown-with-toggle.jsx
Last active December 22, 2015 15:26
The simplest react dropdown component ever
import React from 'react'
export default class Dropdown extends React.Component{
constructor(props){
super()
this.state = { show: props.show }
this.onClick = this.onClick.bind(this)
}
onClick(){
class SomeController < ApplicationController
before_action :add_http_preload
private
def add_http_preload
# Always add a Link header to responses to this controller
http_preload script: "application.js", style: "application.css"
http_preload "myfont.woff", as: :font, push: false
# TODO: How should crossorigin work?