Skip to content

Instantly share code, notes, and snippets.

View vdaubry's full-sized avatar

vincent daubry vdaubry

View GitHub Profile
capital = Money.from_amount("985.13464".to_f, "eu16")
price = Money.from_amount("707.5".to_f, "eu16")
size = Money.from_amount(capital / price, "btc16")
(capital - price * size.to_f).format
=> "€0,0000000000000000"
capital = Money.from_amount("985.13464".to_f, "eu16")
price = Money.from_amount("707.5".to_f, "eu16")
size = Money.from_amount(capital / price, "btc16")
(capital - price * size.to_d).format
@vdaubry
vdaubry / default.rb
Created January 22, 2016 12:26
github-awards chef recipe
#
# Cookbook Name:: github-awards
# Recipe:: default
#
# Copyright 2016, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
apt_repository "ruby" do
@vdaubry
vdaubry / user.json
Last active January 1, 2016 21:21
sample user show response
{
"user": {
"id": 15638312,
"login": "vdaubry",
"gravatar_url": "https://avatars.githubusercontent.com/u/498298?v=3",
"city": "paris",
"country": "france",
"rankings": [{
"language": "ruby",
"repository_count": 28,
@vdaubry
vdaubry / base_controller.rb
Last active September 18, 2015 00:53
Sample token authentication
class Api::V1::BaseController < ActionController::Base
before_filter :allow_cors
def allow_cors
headers["Access-Control-Allow-Origin"] = "*"
headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE}.join(",")
headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token X-API-Auth-Token}.join(",")
end
def options
@vdaubry
vdaubry / gist:98733eb2bbfe3e64b350
Created March 31, 2015 12:19
Github api response for repositories of wesleytodd
$ curl -i https://api.github.com/users/wesleytodd/repos
HTTP/1.1 200 OK
Server: GitHub.com
Date: Tue, 31 Mar 2015 12:13:14 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 158992
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1427807594
@vdaubry
vdaubry / gist:db113605c9f8af37a020
Created March 28, 2015 08:07
sample nginx conf
upstream puma {
server unix:///srv/www/githubawards/shared/tmp/sockets/puma.sock;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /srv/www/githubawards/current/public;
access_log /srv/www/githubawards/shared/log/nginx.access.log;
@vdaubry
vdaubry / gist:2869d85b2e8affdc5a8c
Created February 7, 2015 17:28
proxy drops custom header with https
$ curl -I -x 127.0.0.1:5566 https://www.google.fr
HTTP/1.1 200 Connection established
Proxy-Agent: Privoxy/3.0.23
X-Servedby: 50001
HTTP/1.1 200 OK
Date: Sat, 07 Feb 2015 16:29:25 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
@vdaubry
vdaubry / gist:eafabf211957cbe87563
Created February 7, 2015 17:27
proxy drops custom header with https
$ curl -I -x 127.0.0.1:5566 http://www.google.fr
HTTP/1.1 200 OK
Date: Sat, 07 Feb 2015 16:28:17 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: PREF=ID=5472383c9c9d26f1:FF=0:TM=1423326497:LM=1423326497:S=yu2leDB676aEfg96; expires=Mon, 06-Feb-2017 16:28:17 GMT; path=/; domain=.google.fr
Set-Cookie: NID=67=iPjeDuufTg9UhlCrCuMmA93LSA8LWjBl_H3tliNTWZUsQS2Gtzw36xR2fFz_D9Nz0eWg8Fy_qtTy_cozXTuil7reP_6mwd0_WrH1j1RrSZZlDv3rEXyHOOXnZ1h07qax; expires=Sun, 09-Aug-2015 16:28:17 GMT; path=/; domain=.google.fr; HttpOnly
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Server: gws
@vdaubry
vdaubry / gist:df233106010970ddb237
Created December 2, 2014 07:15
facebook-share-button
<div class="fb-share-button" data-href="{{site.url}}{{page.url}}" data-layout="button_count" style="position: relative; top: -8px; left: 33px;"></div>
@vdaubry
vdaubry / gist:eb98c7d982647bc14cba
Created November 21, 2014 15:38
Jekyll - title tag after
<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>