Skip to content

Instantly share code, notes, and snippets.

View HugoDF's full-sized avatar

Hugo HugoDF

View GitHub Profile
@HugoDF
HugoDF / unlockharvardbiz.js
Created November 19, 2015 11:32
Unlock the frontend locking that the Harvard Business Review loves
$('body').css({overflow: ''});
$('.intromercial-handle').remove();
@HugoDF
HugoDF / gulpfile.js
Last active December 19, 2015 18:15
Setup file for Laravel's Elixir asset pipeline, includes scss compilation, image copying, jsx transpilation and concatenation of library assets
process.env.DISABLE_NOTIFIER = true;
var elixir = require('laravel-elixir');
require('laravel-elixir-livereload');
elixir(function(mix) {
mix
.sass('app.scss',
elixir.config.publicPath + '/' + elixir.config.css.outputFolder,
{includePaths : require('node-neat').includePaths})
.styles([
@HugoDF
HugoDF / package.json
Created December 18, 2015 23:20
NPM package.json for Laravel Elixir with Bourbon, Neat, React and livereload
{
"private": true,
"devDependencies": {
"jquery": "^2.1.4",
"laravel-elixir-livereload": "^1.1.3",
"laravel-elixir-react": "^0.1.2",
"node-bourbon": "^4.2.3",
"node-neat": "^1.7.2",
"react": "^0.14.3",
"react-dom": "^0.14.3"
@HugoDF
HugoDF / sass-make.fish
Created December 19, 2015 02:23
For Laravel 5, makes an SCSS file for each of the arguments and add an import statement for it in app.scss
function sass-make
set names $argv
for name in $names
set path ./resources/assets/sass/_{$name}.scss
touch {$path}
echo 'Created' {$path}
echo '\n@import "'{$name}'";' >> ./resources/assets/sass/app.scss
echo 'Added' {$name} 'to app.scss'
end
end⏎
@HugoDF
HugoDF / citations.rb
Last active January 14, 2016 13:58
If you have a citations.txt file with one URL per citation (eg. Word citations) and need to open them up without clicking through the menu
# use like so:
# ruby citations.rb "text_to_match_1" "text_to_match_2"
args = ARGV
counter = 0
File.open('./citations.txt', 'r') do |f|
while line = f.gets
args.each do |a|
if line.downcase.include?a.downcase
starts_with = "http"
system('open ' + starts_with + line.split(starts_with).last)
@HugoDF
HugoDF / miranda_install.sh
Created January 15, 2016 11:17
Install miranda after having downloaded the tarball, run `sh miranda_install.sh` (for El Capitan since writing to `/usr` is restricted)
tar xpzf mira-2044-x86_64-Darwin.tgz;
cd ./usr/bin;
cp * /usr/local/bin;
cd ../lib;
cp -r * /usr/local/lib;
cd ../share;
cp -r * /usr/local/share;
@HugoDF
HugoDF / map.js
Last active October 18, 2016 19:00
ES6 map implementation using recursion and destructuring
function map([ head, ...tail ], fn) {
if (head === undefined && !tail.length) return [];
return tail.length ? [ fn(head), ...(map(tail, fn)) ] : [ fn(head) ];
}
@HugoDF
HugoDF / filter.js
Last active October 14, 2016 14:22
ES6 filter implementation using recursion and destructuring
function filter([ head, ...tail ], fn) {
const newHead = fn(head) ? [ head ] : [];
return tail.length ? [ ...newHead, ...(filter(tail, fn)) ] : newHead;
}
@HugoDF
HugoDF / reduce.js
Last active February 20, 2018 02:11
ES6 reduce implementation using recursion and destructuring
function reduce([ head, ...tail ], fn, initial) {
if(head === undefined && tail.length === 0) return initial;
if(!initial) {
const [ newHead, ...newTail] = tail;
return reduce(newTail, fn, fn(head, newHead));
}
return tail.length ? reduce(tail, fn, fn(initial, head)) : [ fn(initial, head) ];
}
@HugoDF
HugoDF / join.js
Last active October 13, 2016 19:12
ES6 join implementation using recursion and destructuring
function join([ head, ...tail ], separator = ',') {
if (head === undefined && !tail.length) return '';
return tail.length ? head + separator + join(tail, separator) : head;
}