Skip to content

Instantly share code, notes, and snippets.

View adaedra's full-sized avatar

Thibault “Adædra” Hamel adaedra

View GitHub Profile

$x^2 = \frac{-x^3}{\sqrt{x}}$

#!/bin/sh
if [ "${1}" = '-f' ]; then
cmd='git branch -D'
else
cmd='echo Will delete'
fi
LANG=en_US.UTF-8 \
git branch --list --format '%(upstream:track,nobracket):%(refname:lstrip=2)' | \
@adaedra
adaedra / init.vim
Created March 23, 2018 17:09
Vim basic config
" Plugins
call plug#begin('~/.local/share/nvim/plugged')
Plug 'arcticicestudio/nord-vim'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
call plug#end()
" Basic settings
set number
@adaedra
adaedra / playground.rs
Created September 20, 2016 20:58 — forked from anonymous/playground.rs
Shared via Rust Playground
struct Manager {
callbacks: Vec<Box<FnMut()>>,
}
impl Manager {
fn new() -> Manager {
Manager { callbacks: Vec::new() }
}
fn register(&mut self, callback: Box<FnMut()>) {
adaedra › ll sample
-rw-r--r-- 1 adaedra wheel 1.0G May 18 20:22 sample
adaedra › time shasum -a 512 sample
91db271ec41220b0a608b32e59785b062bb06ca6df87c0750d44c10b17914f23ca87b5a486827a3a5dd34d56786c991ef58ac5c9f7d74b084b1fecec92034cf2 sample
shasum -a 512 sample 3.79s user 0.21s system 99% cpu 3.999 total
adaedra › time ruby -rdigest -e "puts Digest::SHA512.file('sample').hexdigest"
91db271ec41220b0a608b32e59785b062bb06ca6df87c0750d44c10b17914f23ca87b5a486827a3a5dd34d56786c991ef58ac5c9f7d74b084b1fecec92034cf2
ruby -rdigest -e "puts Digest::SHA512.file('sample').hexdigest" 1.76s user 0.25s system 99% cpu 2.015 total
adaedra › touch toto
adaedra › pry
[1] pry(main)> Dir.mkdir 'toto' rescue $!
=> #<Errno::EEXIST: File exists @ dir_s_mkdir - toto>
@adaedra
adaedra / config.ru
Created March 11, 2016 21:04
Rack full example
Application = proc do |env|
names = env['names'] || %w[world]
text = "Hello, #{names.join ', '}!"
[200, {'Content-Type' => 'text/plain'}, [text]]
end
class NameMiddleware
def initialize(app)
@app = app
end
@adaedra
adaedra / gist:7b6121918f64a8eae866
Created December 20, 2015 16:18
Rubinius `Method#parameters`
[1] pry(main)> RUBY_ENGINE
=> "ruby"
[2] pry(main)> def foo(a, b = nil, c:, d: nil); end
=> :foo
[3] pry(main)> method(:foo).parameters
=> [[:req, :a], [:opt, :b], [:keyreq, :c], [:key, :d]]
[4] pry(main)>
use std::io::prelude::*;
use std::fs::File;
fn main() {
let word = get_word();
}
fn get_word() -> String {
let mut file = try!(File::open("wordlist"));
let mut contents = String::new();