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 / 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 / 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 / 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 / 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 / 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