Skip to content

Instantly share code, notes, and snippets.

View FGRibreau's full-sized avatar
✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com

Francois-Guillaume Ribreau FGRibreau

✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com
View GitHub Profile
@FGRibreau
FGRibreau / uglifyjs-benchmark-results.md
Created December 15, 2012 15:31
Real-world benchmark results of UglifyJS v1 vs UglifyJS v2

Compressing 4 bundles with Pound (npm view pound) with JavaScript production code from https://redsmin.com


UglifyJS v1

  • times: 37720ms 36971ms
  • output size: 533Ko, 479Ko, 120Ko, 538Ko
@FGRibreau
FGRibreau / hash_range.js
Created September 21, 2012 09:28
My yesterday night 1 hour code rush: JavaScript Hash with Range-based keys
/**
* September 20 night: 1 hour code rush
* @FGRibreau
*
* Requirements
* ------------
* The aim of this code rush is to enable developers to define a "range hash map"
* in a very expressive way (without if/then/else).
*
* Data-set
@FGRibreau
FGRibreau / underscore_template_err.js
Last active May 24, 2018 10:37
Add the following code just after UnderscoreJS declaration to find where _.template calls are run against empty templates.
/**
* Add the following code just after UnderscoreJS declaration to find
* where _.template calls are run against empty templates.
*/
(function(old){
_.template = function(str, data) {
if(!str){
console.error("Could not load template", new Error().stack);
if(!function_exists('apc_exists')){
function apc_exists($keys){
$r;
apc_fetch($keys,$r);
return $r;
}
}
@FGRibreau
FGRibreau / GCLOUD_SERVICE_ACCOUNT
Created April 16, 2018 22:16
"cat service_account.json | base64" will give you your GCLOUD_SERVICE_ACCOUNT
ewogICJ0eXBlIjogInNlcnZpY2VfYWNjb3VudCIsCiAgInByb2plY3RfaWQiOiAicHJvamVjdC0xMDAxMTAiLAogICJwcml2YXRlX2tleV9pZCI6ICIxYmQ2MDAwMDAzOTAwMDAwYmEwMDcxMjhiNzcwZDgzMWIyYjAwMDAwIiwKICAicHJpdmF0ZV9rZXkiOiAiLS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tXG5NSUlFdmdJQkFEQU5CZ2txaGtpRzl3MEJBUUVcbmhPbkx4UWE3cVByWkZMUCsyUzNSYVN1ZHNidW9jVm80YnlaSFxuNWU5Z3NEN056c0QvN0VDSkR5SW5iSDgrTUVKeEZCVy95WVVYNlhITS9kXG41T2lqeUlkQTQrTlBvNktwa0phMldWOEkvS1B0b05MU0s3ZDZvUmRFQVpcbjdFQ0pEeUluYkg4K01FSnhGQlcveVlVWDZYSE0vZFxuNU9panlJZEE0K05QbzZLcGtKYTJXVjhJL0tQdG9OTFNLN2Q2b1JkRUFaXG43RUNKRHlJbmJIOCtNRUp4RkJXL3lZVVg2WEhNL2RcbjVPaWp5SWRBNCtOUG82S3BrSmEyV1Y4SS9LUHRvTkxTSzdkNm9SZEVBWlxuN0VDSkR5SW5iSDgrTUVKeEZCVy95WVVYNlhITS9kXG41T2lqeUlkQTQrTlBvNktwa0phMldWOEkvS1B0b05MU0s3ZDZvUmRFQVpcbjdFQ0pEeUluYkg4K01FSnhGQlcveVlVWDZYSE0vZFxuNU9panlJZEE0K05QbzZLcGtKYTJXVjhJL0tQdG9OTFNLN2Q2b1JkRUFaXG43RUNKRHlJbmJIOCtNRUp4RkJXL3lZVVg2WEhNL2RcbjVPaWp5SWRBNCtOUG82S3BrSmEyV1Y4SS9LUHRvTkxTSzdkNm9SZEVBWlxuN0VDSkR5SW5iSDgrTUVKeEZCVy95WVVYNlhITS9kXG41T2lqeUlkQTQrTlBvNktwa0phMldWOEkv
@FGRibreau
FGRibreau / post-commit
Created February 5, 2013 21:11
Keep gh-pages in sync with master on git post-commit hook
#!/bin/sh
git checkout gh-pages
git rebase master
git checkout master
@FGRibreau
FGRibreau / trololol.js
Last active July 22, 2017 17:39
Human Benchmark
// Cleaner approach than setInterval + click.
var t = angular.element(document.querySelector('.reaction-time-test')).scope().test;
t.trials = Array.apply(null, new Array(5)).map(function(a){
var trial = t.nextTrial();
trial.result = 100;
trial.timeWaited = 3000+~~(Math.random() * 1000);
return trial;
});
t.save();
@FGRibreau
FGRibreau / ng-animate1.js
Last active July 21, 2017 12:04
How to configure ng-animate to only work on a specified list of elements
// First configure $animateProvider
angular.module('MyApp', ['ngAnimate']).config(['$animateProvider', function($animateProvider){
// restrict animation to elements with the bi-animate css class with a regexp.
// note: "bi-*" is our css namespace at @Bringr.
$animateProvider.classNameFilter(/bi-animate/);
}]);
@FGRibreau
FGRibreau / jQuery iFrame.js
Created November 30, 2010 07:18
jQuery iFrame
//Find the iframe in the current document
var doc = $('#myIframe').contents()[0];
//Get the iframe's window context
var iFrameWindow = 'defaultView' in doc? doc.defaultView : doc.parentWindow;
//Now we can get jQuery by doing iFrameWindow.$ or iFrameWindow.jQuery
iFrameWindow.$('selector').data('key')
@FGRibreau
FGRibreau / circle.yml
Last active April 5, 2017 09:00
Cargo rust test for CircleCI
machine:
services:
- docker
test:
override:
# don't forget to replace "1.18" with your rust version
- docker run -it --rm -v $(pwd):/source -w /source scorpil/rust:1.18 cargo test