Skip to content

Instantly share code, notes, and snippets.

View felixgirault's full-sized avatar
🐱

Félix Girault felixgirault

🐱
View GitHub Profile
@felixgirault
felixgirault / save-deezer-collection.js
Last active November 23, 2018 19:10
To save your Deezer collection to a JSON file, open your favorite tracks (like https://www.deezer.com/en/profile/1725967/loved) and run this script in the console.
(async () => {
const keys = [];
const songs = [];
const index = () => {
const rows = $('.datagrid-row');
rows.each((i, el) => {
const row = $(el);
const key = row.attr('data-key');
@felixgirault
felixgirault / download-audio.sh
Last active April 20, 2016 07:27
Download audio from videos
cclive \
--stream best \
--filename-format "%t" \
--exec 'echo "Converting to audio..."' \
--exec 'ffmpeg -loglevel warning -i "%f" -codec copy -map 0:a "%n.mp4"' \
--exec 'echo "Cleaning temp file..."' \
--exec 'rm "%f"' \
--exec 'echo "You can now listen to %t.mp4' \
"$1" \
/
@felixgirault
felixgirault / after.php
Last active September 26, 2016 15:13
Refactoring 2
<?php
function doSomething() {
// 10 LOC
}
function doSomethingElse() {
// 20 LOC
}
@felixgirault
felixgirault / noUiSliderA11y.js
Last active May 18, 2018 22:34
Accessible noUiSlider
/**
* Adds an accessibility layer to the default noUiSlider.
*
* @see $.fn.noUiSlider()
*/
$.fn.noUiSliderA11y = function(options, rebuild) {
var slider = this;
if (!('noUiSlider' in slider)) {
throw new Error('noUiSlider is not loaded.');
@felixgirault
felixgirault / README.md
Last active September 26, 2016 15:18
Refactoring 1

Separation of concerns

Instead of making huge functions that makes a lot of things given a set of options, prefer splitting them into small atoms.

Bad

<?php

/** 
@felixgirault
felixgirault / zoomify.js
Created February 20, 2014 10:35
Compares Ol3 and Zoomify algorithms for calculating tier sizes.
/**
* Compares Ol3 and Zoomify algorithms for calculating tier sizes.
*/
var DEFAULT_TILE_SIZE = 256;
/**
* Original Ol3 algorithm.
*/
var ol = function(imageWidth, imageHeight) {
@felixgirault
felixgirault / echo
Created August 13, 2013 15:55
A benchmark for different ways of using echo in PHP.
<?php
define( 'ECHO_COUNT', 10000 );
define( 'EXECUTION_COUNT', 100 );
function coma( ) {
for ( $i = 0; $i < ECHO_COUNT; $i++ ) {
echo 'a ', $i, ' b ', $i, ' c';
}
}
@felixgirault
felixgirault / factory.hpp
Last active December 15, 2015 07:29
A generic factory to be used in Qt applications.
#ifndef FACTORY_H
#define FACTORY_H
#include <QList>
#include <QHash>
typedef QHash< QString, QString > Informations;
typedef QHashIterator< QString, QString > InformationsIterator;
@felixgirault
felixgirault / aliases
Last active December 11, 2015 15:09
Bash aliases.
# apt
alias search='apt-cache search'
alias install='sudo apt-get install'
# git
alias gs='git status' # overwrites ghostscript
alias ga='git add .'
alias gc='git commit -m'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>FG</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>