Skip to content

Instantly share code, notes, and snippets.


Felix Descoteaux felix-d

View GitHub Profile
felix-d / review.rb
Created Apr 27, 2020
Review git branches
View review.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
require 'ostruct'
require 'net/http'
require 'json'
require 'pathname'
options =
felix-d /
Created Oct 21, 2018
LRU Cache in Rust
use std::collections::HashMap;
use std::hash::Hash;
use std::ptr::NonNull;
use std::cell::RefCell;
felix-d /
Created Apr 16, 2018
Sieve of Erathostene in Rust
extern crate num_iter;
use num_iter::range_step;
pub fn sieve(n: u64) -> Vec<u64> {
let mut prime_identifers: Vec<bool> = vec![true; n as usize + 1];
let primes: Vec<u64> = vec![];
for i in 2..(n as f64).sqrt() as usize + 1 {
if *prime_identifers.get(i).unwrap() {
let video_file_regex = Regex::new(r"https://.*\.ts").unwrap();
let mut result_video_file = File::create("result.ts")?;
let futures: Vec<_> = video_file_regex.find_iter(&hd_playlist_content).map(|capture| {
let video_file_link = capture.as_str();
let response = client.get(video_file_link.parse().unwrap());
View gist:c5defd471c99617343d6a01aef5b8b34
" vim: set sw=2 ft=vim ts=2 sts=2 et:
call plug#begin('~/.vim/plugged')
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
felix-d / Dockerfile
Last active Apr 8, 2019
Elixir Phoenix Distillery Multi-Stage Dockerfile
View Dockerfile
# Assets compilation
FROM aparedes/alpine-node-yarn as node
## Node modules
COPY ./deps /tmp/deps
COPY ./assets/package.json /tmp/deps
COPY ./assets/package-lock.json /tmp/deps
WORKDIR /tmp/deps
RUN yarn
View curlt.bash
# shamelessly stolen from
# curl wrapper returning timing information.
# curl format adapted from
# Example usage:
# $ curlt
felix-d / sqllogging.rb
Created Oct 23, 2017
SQL logging with trace
View sqllogging.rb
class MyLogger < Logger
def add(severity, message = nil, progname = nil)
severity ||= UNKNOWN
if @logdev.nil? or severity < @level
return true
if progname.nil?
progname = @progname
if message.nil?
felix-d /
Created Jul 9, 2017
FFI - Convert C strings to Rust strings
extern crate libc;
use std::ffi::CStr;
use libc::c_char;
pub extern fn to_owned(buf: *const c_char) -> String {
let c_str: &CStr = unsafe { CStr::from_ptr(buf) };
let buf: &[u8] = c_str.to_bytes();
let str_slice: &str = std::str::from_utf8(buf).unwrap();
felix-d / Track Emacs position inside terminal
Created Jul 3, 2015
Track current position inside emacs term
View Track Emacs position inside terminal
if [ -n "$INSIDE_EMACS" ]; then
chpwd() { print -P "\033AnSiTc %d" }
print -P "\033AnSiTu %n"
print -P "\033AnSiTc %d"