Skip to content

Instantly share code, notes, and snippets.

Simon Prévost simonprev

View GitHub Profile
@simonprev
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
operations()
@simonprev
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
simonprev / phoenix-web-framework.md
Last active Aug 29, 2015
Phoenix - OpenCode XXII
View phoenix-web-framework.md

Phoenix - Elixir Web framework

by

Simon Prévost, Développeur Web chez Mirego

(The slides were made for mdp)


View gist:5594433
'test_string'.upcase
#=> "TEST_STRING"
'test_string'.upcase!
#=> "TEST_STRING"
'TEST_STRING'.upcase
#=> "TEST_STRING"
'TEST_STRING'.upcase!
#=> nil
@simonprev
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'
fi
alias v='vim'
View gist:3044224
1. Open terminal.app
2. Paste this command: defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
(credit: https://twitter.com/defaultswrite/status/220164244954554368)
3. Open Rdio.app
4. Right click and show the inspector panel
5. In the console section, paste this line: $("head").append('<link href="https://s3.amazonaws.com/simon-dev/css/rdio.css" rel="stylesheet" type="text/css">')
@simonprev
simonprev / gist:1462044
Created Dec 11, 2011
Horizontal centered menu
View gist:1462044
#horizontal-centered-menu {
float:left;
width:100%;
overflow:hidden;
position:relative;
ul {
clear:left;
float:left;
list-style:none;
position:relative;
@simonprev
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.