Skip to content

Instantly share code, notes, and snippets.

Simon Prévost simonprev

View GitHub Profile
simonprev / generate_placeholders.exs
Created Jan 22, 2019
Generate placeholder after Accent’s new feature
View generate_placeholders.exs
defmodule GeneratePlaceholders do
import Ecto.Query
alias Accent.Repo
@regex Langue.Formatter.Rails.placeholder_regex()
@document_id "85f15c8e-a5bb-4235-b04f-3ce04e672749"
def update_operations do
simonprev / rate_limiting.ex
Last active Aug 29, 2015
Redis-backed rate limiting API
View rate_limiting.ex
defmodule MyProject.Plugs.RateLimting do
import Plug.Conn
alias Exredis.Api, as: Redis
@ttl 60 # seconds
@limit 5 # requests count
@header_limit "x-rate-limit-limit"
@header_remaining "x-rate-limit-remaining"
@header_reset "x-rate-limit-reset"
simonprev /
Last active Aug 29, 2015
Phoenix - OpenCode XXII

Phoenix - Elixir Web framework


Simon Prévost, Développeur Web chez Mirego

(The slides were made for mdp)

View gist:5594433
#=> nil
simonprev / translatable.rb
Created Mar 5, 2013
R18n translations and go_i18n_field in 25 lines...
View translatable.rb
module Extensions
module Translatable
extend ActiveSupport::Concern
module ClassMethods
def translations(*fields)
fields.each do |field|
define_method field do read_translate(field) end
define_method "#{field}=" do |value| write_translate(field, value) end
View aliases.zsh
# load the macvim version of terminal vim
if which mvim &> /dev/null; then
alias vim='mvim -v'
alias v='vim'
View gist:3044224
1. Open
2. Paste this command: defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
3. Open
4. Right click and show the inspector panel
5. In the console section, paste this line: $("head").append('<link href="" rel="stylesheet" type="text/css">')
simonprev / gist:1462044
Created Dec 11, 2011
Horizontal centered menu
View gist:1462044
#horizontal-centered-menu {
ul {
simonprev / gist:974566
Created May 16, 2011 — forked from ZenCocoon/gist:724366
Handling French date format in Ruby
View gist:974566
## Try 1
# How could I get the following working nicely
Date.strptime("Ven 13 Mai. 2011, 16h00", "%a %d %b %Y, %Hh%M")
# I've tried to update Date::ABBR_DAYNAMES as follow
I18n.locale = :fr
Date::ABBR_DAYNAMES = I18n.t('date.abbr_day_names')
Date::ABBR_MONTHNAMES = I18n.t('date.abbr_month_names')
You can’t perform that action at this time.