Skip to content

Instantly share code, notes, and snippets.

Avatar

Vincent Durand madwork

View GitHub Profile
@madwork
madwork / app.html
Created Sep 9, 2015
Angular 1.3 Bind Once
View app.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bind Once</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.13/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.13/angular.min.js"></script>
</head>
<body ng-app>
<p><input type="text" ng-model="foo"></p>
@madwork
madwork / parse-cookie.coffee
Last active Feb 4, 2016
Node cookie parser for Rails 4.1 json encypted cookies
View parse-cookie.coffee
@madwork
madwork / keybase.md
Created Jul 1, 2015
keybase prove github madwork
View keybase.md

Keybase proof

I hereby claim:

  • I am madwork on github.
  • I am madwork (https://keybase.io/madwork) on keybase.
  • I have a public key whose fingerprint is E0C0 7490 6640 693C 8AEC BD3E 6BF4 9CEC 089D 7137

To claim this, I am signing this object:

@madwork
madwork / decode_session_cookie.rb
Last active Oct 22, 2020 — forked from profh/decode_session_cookie.rb
Rails 4.1+ Decode Session
View decode_session_cookie.rb
@madwork
madwork / caesar_cipher.rb
Created Apr 17, 2015
Caesar Cipher Implementation in Ruby
View caesar_cipher.rb
# CaesarCipher
# Example:
# cipher = CaesarCipher.new "Ruby is a dynamic, open source programming language!"
# cipher.encrypt(13)
# => "ehol vf n qlanzvp, bcra fbhepr cebtenzzvat ynathntr!"
class CaesarCipher
attr_accessor :sentence
def initialize(sentence)
@sentence = sentence
@madwork
madwork / utf8-sanitizer.rb
Last active Aug 29, 2015
Utf8 Sanitizer Middleware
View utf8-sanitizer.rb
# Utf8Sanitizer
# Rack/Ruby on Rails: ArgumentError: invalid byte sequence in UTF-8
# raise 400 error
# http://dev.mensfeld.pl/2014/03/rack-argument-error-invalid-byte-sequence-in-utf-8/
class Utf8Sanitizer
SANITIZE_ENV_KEYS = %w(
HTTP_REFERER
PATH_INFO
REQUEST_URI
REQUEST_PATH
@madwork
madwork / install.sh
Last active Aug 29, 2015
Max OS X 10.9 + chruby + Ruby 2.1.1
View install.sh
brew install wget chruby openssl libyaml libxml2
# https://github.com/sstephenson/ruby-build/issues/550#issuecomment-40863879
cd /usr/local
git checkout 0181c8a Library/Formula/readline.rb
brew install readline
export ARCHFLAGS="-arch x86_64"
export CFLAGS="-g -O2"
export LDFLAGS="-L/usr/local/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib"
@madwork
madwork / install.sh
Last active Jan 1, 2016
Max OS X 10.8 + chruby + Ruby 2.1
View install.sh
brew install chruby readline openssl libyaml
export ARCHFLAGS="-arch x86_64"
export CFLAGS="-g -O2"
export LDFLAGS="-L/usr/local/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include"
mkdir ~/.rubies
# ruby 2.1.0
@madwork
madwork / iptables-stop.sh
Created Dec 3, 2013
My generic iptables rule set
View iptables-stop.sh
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
@madwork
madwork / deploy.rb
Last active Jul 27, 2016
Upstart with Puma and chruby for a single app (single mode).
View deploy.rb
after "deploy:restart", "puma:restart"
namespace :puma do
task :restart, roles: :app do
run "cd #{current_path} && #{bundle_cmd} exec pumactl -S #{shared_path}/pids/puma.state restart"
end
end