Skip to content

Instantly share code, notes, and snippets.

View StanBoyet's full-sized avatar

Stanislas Boyet StanBoyet

View GitHub Profile
@StanBoyet
StanBoyet / Rakefile
Last active August 29, 2015 14:19 — forked from barrettclark/Rakefile
require 'rake'
# http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html
require 'net/http'
desc "this is a test"
task :testing_rake do
puts "Hello from rake!"
end
namespace :remote_file do

$ psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Solved by :

rm /usr/local/var/postgres/postmaster.pid

DISABLED_TASKS = [
'db:drop',
'db:migrate:reset',
'db:schema:load',
'db:seed',
# ...
]
namespace :db do
desc "Disable a task in production environment"
def generate_random_string(length)
rand(36**length).to_s(36)
end
@StanBoyet
StanBoyet / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@StanBoyet
StanBoyet / sort_with_jquery.md
Created November 18, 2014 18:37
Sort elements with jQuery

from http://trentrichardson.com/2013/12/16/sort-dom-elements-jquery/

I wanted to share a quick snippet that I worked up for a unique scenario. Occasionally you want to sort or display DOM elements in a certain order. For instance, what if you have a list of names. A feature of your site may be that you can sort the list by first name, or last name. There are a few ways you can approach this.

One approach may be using a javascript framework like Backbone or Angular, where you have a model and collection. Then simply sort the collection, magic happens, and your list is essentially regenerated.

The other could be that you’re not using a framework and not want to regenerate the entire list, but to move the nodes. It is actually rather simple. Lets say you have a list like the following:

# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
fr:
devise:
confirmations:
confirmed: 'Votre compte a été validé.'
send_instructions: 'Vous allez recevoir les instructions nécessaires à la confirmation de votre compte dans quelques minutes.'
send_paranoid_instructions: 'Si votre e-mail existe dans notre base de données, vous allez bientôt recevoir un e-mail contenant les instructions de confirmation de votre compte.'
failure:
already_authenticated: "Vous êtes déjà connecté"
# iTerm2, OS X
# 1. change 'your_app_production' to your application name
# 1a. Tune the colors by your taste
# 2. put these functions to your .bashrc, .zshrc
# or anywhere where it gets loaded for your iTerm session
# 3. restart iTerm or 'source ~/.zshrc' and use these functions
set_color() {
local HEX_FG=$1
local HEX_BG=$2