Skip to content

Instantly share code, notes, and snippets.

View olivoil's full-sized avatar

Olivier Melcher olivoil

View GitHub Profile

Keybase proof

I hereby claim:

  • I am olivoil on github.
  • I am olivoil (https://keybase.io/olivoil) on keybase.
  • I have a public key whose fingerprint is 79F2 96CF 83D2 6992 C19A 14E9 9B0A 8134 3D8E D17D

To claim this, I am signing this object:

@olivoil
olivoil / workingon.fish
Created November 12, 2015 23:26
WorkingOn shell command for fish (place in ~/.config/fish/functions/on.fish)
function prompt_status
set_color green; echo "What are you working on?"; set_color normal; echo "> "
end
function on
if begin; test (count $argv) -gt 0; end
curl -X POST --data-urlencode "task=$argv" "https://api.workingon.co/hooks/incoming?token={{YOUR_TOKEN}}" >/dev/null 2>&1
else
read -l -p prompt_status what
on $what
package main
import (
"errors"
"log"
"os"
"sync"
)
var fmt = log.New(os.Stdout, "", 0)
@olivoil
olivoil / uustats.js
Created October 18, 2013 02:01 — forked from akdubya/uustats.js
(function(uustats){
uustats.sdev = function(series) {
return Math.sqrt(uustats.variance(series));
};
uustats.variance = function(series) {
var t = 0, squares = 0, len = series.length;
for (var i=0; i<len; i++) {
@olivoil
olivoil / vimrc
Last active December 17, 2015 10:09
Toggle between tabs vs. spaces mode
" Return indent (all whitespace at start of a line), converted from
" tabs to spaces if what = 1, or from spaces to tabs otherwise.
" When converting to tabs, result has no redundant spaces.
function! Indenting(indent, what, cols)
let spccol = repeat(' ', a:cols)
let result = substitute(a:indent, spccol, '\t', 'g')
let result = substitute(result, ' \+\ze\t', '', 'g')
if a:what == 1
let result = substitute(result, '\t', spccol, 'g')
endif
// http://www.w3.org/TR/dom/
// http://updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers
// https://developer.mozilla.org/en-US/docs/DOM/MutationObserver
var MutationObserver = (function () {
var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']
for(var i=0; i < prefixes.length; i++) {
if(prefixes[i] + 'MutationObserver' in window) {
return window[prefixes[i] + 'MutationObserver'];
}
}
@olivoil
olivoil / console.log
Created April 10, 2013 15:58
debugging with nodetime
nodetime v0.8.11: sent message(s) to server
nodetime v0.8.11: sent message(s) to server
nodetime v0.8.11 error: [TypeError: Cannot read property '0' of undefined] TypeError: Cannot read property '0' of undefined
at net.js:656:34
at Array.forEach (native)
at Socket.self [as bytesWritten] (net.js:654:16)
at /home/ec2-user/ModelT/node_modules/nodetime/lib/probes/net-probe.js:40:35
at Socket.obj.(anonymous function) [as write] (/home/ec2-user/ModelT/node_modules/nodetime/lib/core/proxy.js:39:9)
at Connection.write (/home/ec2-user/ModelT/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:215:31)
@olivoil
olivoil / Custom.css
Last active December 15, 2015 14:59 — forked from nixpulvis/Custom.css
body { -webkit-transform: rotate(10deg); }
body { -webkit-animation: blur 30s infinite; }
img { -webkit-transform: rotate(180deg); }
body, p, body p, body div p { font-family: 'Comic Sans MS', cursive !important; }
p:before { content: "YOLO "; }
p:nth-child(2) { display:none !important; }
#-webkit-web-inspector { -webkit-transform:rotate(180deg); }
#-webkit-web-inspector .toolbar-item.close-left { display:none !important; }
html { -webkit-animation: rainbow 8s infinite; }
@-webkit-keyframes blur {
<html>
<head>
<script type="text/javascript" charset="utf-8">
var FB = function(){
//defaults and accessors
var initialized = false,
loggedIn = null,
shouldSucceed = true,
uid = '12345';
@olivoil
olivoil / example.rb
Created October 25, 2012 20:48 — forked from joakimk/example.rb
A simple form object built on top of virtus.
class Filter
include FormObject
# Proc because Date.yesterday changes every day :)
attribute :from, Date, default: Proc.new { Date.yesterday }
attribute :to, Date, default: Proc.new { 1.month.from_now - 1.day }
end
# in controller
@filter = Filter.new(params[:filter])