Skip to content

Instantly share code, notes, and snippets.

View felix-d's full-sized avatar

Felix Descoteaux felix-d

View GitHub Profile
@felix-d
felix-d / sameheight.js
Last active August 29, 2015 14:13
Function for jquery to set divs to the same height, using the max height of those divs.
//Author: Felix Descoteaux
//Usage: $.sameheight($("#element1"), $(".element2"), ... );
(function($) {
var sameHeight = function sameHeight() {
var arrayOfHeights = [],
arr = Array.prototype.slice.call(arguments),
max;
//Clear any height value
@felix-d
felix-d / mixins
Created March 2, 2015 20:24
_mixins.scss
//allow double box shadows
@mixin box-shadow($shadow1, $shadow2:false) {
$params: $shadow1;
@if $shadow2
{ $params: $shadow1, $shadow2; }
-webkit-box-shadow: $params;
-moz-box-shadow: $params;
box-shadow: $params;
}
@felix-d
felix-d / gist:bf0e68a4fa0e9c17d95b
Created March 14, 2015 17:26
Mathieu Bock Cote Scraper
import requests
import threading
from bs4 import BeautifulSoup
from Queue import Queue
import re
import time
max_page = 230
num_workers = 200
sentence_regex = re.compile(r'([^.!?(\n)+]+[.!?]+)')
@felix-d
felix-d / gist:2f6896ad854579df0af0
Created March 24, 2015 03:24
Javascript images preloading by chunks with lodash
//requires lodash
function preload(sources, chunkSize) {
chunkSize = chunkSize || sources.length;
var sourcesChunked = _.chunk(sources, chunkSize);
var steps = sourcesChunked.length;
var current = 0;
var inner = function(_current){
var imagesTemp = [];
var l = sourcesChunked[_current].length;
var counter = 0;
@felix-d
felix-d / Track Emacs position inside terminal
Created July 3, 2015 20:21
Track current position inside emacs term
if [ -n "$INSIDE_EMACS" ]; then
chpwd() { print -P "\033AnSiTc %d" }
print -P "\033AnSiTu %n"
print -P "\033AnSiTc %d"
fi
@felix-d
felix-d / ffi_string.rs
Created July 9, 2017 17:43
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();
str_slice.to_owned()
@felix-d
felix-d / sqllogging.rb
Created October 23, 2017 17:47
SQL logging with trace
class MyLogger < Logger
def add(severity, message = nil, progname = nil)
severity ||= UNKNOWN
if @logdev.nil? or severity < @level
return true
end
if progname.nil?
progname = @progname
end
if message.nil?
#!/bin/bash
# shamelessly stolen from https://github.com/mat/dotfiles/blob/master/bin/curlt
#
# curl wrapper returning timing information.
#
# curl format adapted from
# http://josephscott.org/archives/2011/10/timing-details-with-curl/
#
# Example usage:
# $ curlt http://www.apple.com
@felix-d
felix-d / Dockerfile
Last active April 8, 2019 15:51
Elixir Phoenix Distillery Multi-Stage 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
" vim: set sw=2 ft=vim ts=2 sts=2 et:
"""""""""""""""""""""""""""""""
" => BUNDLES
"""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'