Skip to content

Instantly share code, notes, and snippets.

View s-leroux's full-sized avatar

Sylvain Leroux s-leroux

View GitHub Profile
@s-leroux
s-leroux / QueryParams.js
Last active January 13, 2016 14:55 — forked from andrewjmead/QueryParams.js
Get Query Params By Name
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1].replace(/\+/g, '%20'));
}
}
@s-leroux
s-leroux / recruiting-model.py
Created January 26, 2016 14:28
A quick-and-dirty script modeling the recruiting process
#!/usr/bin/python3
# A quick-and-dirty script modeling the recruiting process.
# by Sylvain Leroux
# Each candidat as a set of skills
# and a "personal fit" with the job offer.
# The skill level is known by the recruiter if >= 0.5
# The "personal fit" in [0,1) range is not know
# All skill values are in the range (0-1]
@s-leroux
s-leroux / Makefile
Last active January 30, 2023 15:56
Running a nested xfce4-session in Xephyr
all: pts grantpt ptsname unlockpt
@s-leroux
s-leroux / capture.sh
Last active November 9, 2016 16:35
Capture X11 display + USB Mic sound using ffmpeg
#!/bin/bash
DISPLAY=:15
X=0
Y=0
shopt -s extglob
while [ ! -z "$1" ]
do
@s-leroux
s-leroux / CustomerTotalExpenses.py
Created February 29, 2016 14:11
A sample code demonstrating how to output advanced datatypes from a map-reduce job using mrjob.py
from mrjob.job import MRJob
import mrjob.protocol
from decimal import Decimal
class MRCustomerTotalExpenses(MRJob):
INTERNAL_PROTOCOL = mrjob.protocol.PickleProtocol
OUTPUT_PROTOCOL = mrjob.protocol.ReprProtocol
def mapper(self, key, line):
@s-leroux
s-leroux / package.json
Last active March 22, 2016 21:29
"Introduction to Server-side Development" course by Jogesh Muppala on Coursera -- sample RESTful test with Mocha + Supertest
{
"name": "node-express",
"version": "1.0.0",
"description": "",
"main": "dishRouter.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "./node_modules/.bin/mocha",
@s-leroux
s-leroux / insert.mongo
Created March 20, 2016 17:38
"Server-side Development with NodeJS" Course -- Mongoose concurrent insert of sub-document test
> db.dishes.create({
... _id: ObjectId("56eedb8b839b02cc2b7954d5"),
... name: 'Uthapizza',
... description: 'Test',
... comments: [
... {
... rating: 3,
... comment: 'This is insane',
... author: 'Matt Daemon'
... }
@s-leroux
s-leroux / test_models.js
Created March 21, 2016 00:18
"Introduction to Server-side Development" course by Jogesh Muppala on Coursera -- test file for assignment 2
var mongoose = require('mongoose');
var url = 'mongodb://localhost:27017/conFusion';
mongoose.connect(url);
var db = mongoose.connection;
var assert = require('assert');
var Dishes = require('../models/dishes');
var Promotions = require('../models/promotions');
var Leaders = require('../models/leadership');
@s-leroux
s-leroux / fixtures_dishes.js
Last active April 2, 2016 21:25
"Introduction to Server-side Development" course by Jogesh Muppala on Coursera -- test files for week 3
/* test/fixtures/fixtures_dishes.js */
module.exports = [
{
"_id" : "000000000000000000001100",
"updatedAt" : "2016-03-21T23:14:53.548Z",
"createdAt" : "2016-03-21T23:14:53.548Z",
"name" : "Uthapizza",
"image" : "images/pizza.png",
@s-leroux
s-leroux / fixtures_promotions.js
Created March 28, 2016 00:04
"Introduction to Server-side Development" course by Jogesh Muppala on Coursera -- test file for assignment 3
/* test/fixtures/fixtures_promotions.js */
module.exports = [
{
"_id" : "000000000000000000001100",
"updatedAt" : "2016-03-21T23:18:37.283Z",
"createdAt" : "2016-03-21T23:14:53.548Z",
"name" : "Grand buffet",
"image" : "images/buffet.png",