Skip to content

Instantly share code, notes, and snippets.

View Fire-Dragon-DoL's full-sized avatar

Francesco Belladonna Fire-Dragon-DoL

View GitHub Profile
@evocateur
evocateur / fixconsolas
Created March 15, 2009 00:15
Fix Consolas's line-height on OS X
#!/bin/bash
#
# Requires ftxdumperfuser from http://developer.apple.com/textfonts/download/
#
# Usage: fixconsolas [files ...]
# When called with no arguments, it attempts to operate on every TrueType
# file in the current directory.
#
# References:
# http://bandes-storch.net/blog/2008/12/21/consolas-controlled/#comment-2042
@undees
undees / salesforce_oauth_first.rb
Created February 10, 2010 09:23
Connect Ruby to Salesforce via OAuth
require 'oauth'
consumer_key = '...' # from SalesForce
consumer_secret = '...' # from SalesForce
oauth_options = {
:site => 'https://login.salesforce.com',
:scheme => :body,
:request_token_path => '/_nc_external/system/security/oauth/RequestTokenHandler',
:authorize_path => '/setup/secur/RemoteAccessAuthorizationPage.apexp',
@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' '*';
#
@kaelig
kaelig / Gemfile
Created September 7, 2011 00:20
Sass & CoffeeScript automated compiling and minifying with Guard
source "http://rubygems.org"
group :development do
gem 'rake'
gem 'guard'
gem 'coffee-script'
gem 'rb-fsevent'
gem 'rb-inotify'
gem 'compass', '0.11.5'
gem 'sass', '3.1.5'
gem 'guard-compass'
@tiagoa
tiagoa / Backbone.websocket.js
Created October 13, 2012 23:34
Overwrite Backbone.sync method to persist model via WebSocket
// Inspired by https://github.com/logicalparadox/backbone.iobind/blob/master/lib/sync.js
// Overwrite Backbone.sync method
Backbone.sync = function(method, model, options){
// create a connection to the server
var ws = new WebSocket('ws://127.0.0.1:1234');
// send the command in url only if the connection is opened
// command attribute is used in server-side.
ws.onopen = function(){
@unders
unders / outer_join_with_arel.rb
Created November 1, 2012 13:29
Rails Outer Join with Arel
bt = Brand.arel_table
bft = BrandFollower.arel_table
user = User.first
outer_join = Arel::Nodes::OuterJoin.new(bft, Arel::Nodes::On.new(bft[:brand_id].eq(bt[:id])))
brand_follower = bft[:role].eq(:editor).and(bft[:follower_id].eq(user.id))
Brand.joins(outer_join).where(bt[:published].eq(true).or(brand_follower))
@potch
potch / css-grid-orphans.css
Last active December 15, 2015 05:39
Using CSS to target orphan nodes of a grid.
/* The CSS for targeting trailing nodes in a grid with rows of 4 nodes */
div:nth-last-child(-n+3):nth-child(4n+1),
div:nth-last-child(-n+2):nth-child(4n+2),
div:nth-last-child(-n+1):nth-child(4n+3) {
background: blue;
}
@chrismcg
chrismcg / plantuml.sh
Created April 17, 2013 13:11
PlantUML helper script for OSX. Generates a png and opens it
#!/bin/sh
# You need to download the jar from http://plantuml.sourceforge.net/ and put in ~/plantuml
# or alter the path below
java -jar ~/plantuml/plantuml.jar -tpng $@
open ${@%plantuml}png
@gonzalo-bulnes
gonzalo-bulnes / XXXXXXXXXXXXX_add_authentication_token_to_users.rb
Last active March 6, 2019 15:15
(Update: I've packaged this gist into a gem to make its use easier, see: https://github.com/gonzalo-bulnes/simple_token_authentication.) Add token authentication to your Rails API. Follows the José Valim recomendations and is fully compatible with Devise (tokens are created the first time users sign in). See https://gist.github.com/josevalim/fb7…
# db/migrate/XXXXXXXXXXXXX_add_authentication_token_to_users.rb
class AddAuthenticationTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :authentication_token, :string
add_index :users, :authentication_token, :unique => true
end
end
@skmetz
skmetz / gilded_rose_test.rb
Last active May 30, 2017 18:42
Gilded Rose Test
# This simplest thing is to clone Jim's repo (https://github.com/jimweirich/gilded_rose_kata) and then
# put this file in the root directory.
gem 'minitest', '~> 4.7'
require "minitest/autorun"
require "minitest/reporters"
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
require_relative './gilded_rose'