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 / 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 / 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 / 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 / package.json
Created October 6, 2016 12:33
Frontend React/Mocha/Babel/Browserify setup with npm scripts and browser-sync. Requires a `./src` folder containing a react.js and an app.scss as well as a `./index.html` file.
{
"name": "frontend-starter",
"version": "1.0.0",
"description": "React, browserify and babel. With npm scripts and browser-sync",
"main": "index.js",
"config": {
"ut": "{,!(node_modules)/**/}*.test.js"
},
"scripts": {
"start": "npm run dev",
@HugoDF
HugoDF / map-arrow.js
Last active October 11, 2016 23:04
ES6 map implementation using arrow function, recursion and destructuring
var map = ([ head, ... tail ], fn) =>
( (head !== undefined && tail.length) ? ( tail.length ? [ fn(head), ...(map(tail, fn)) ] : [ fn(head) ] ) : []);
@HugoDF
HugoDF / es5-map.js
Last active October 13, 2016 18:01
Recursive implementation of map in ES5.
function map(arr, fn) {
var head = arr[0];
var tail = arr.slice(1);
if(head === undefined && tail.length === 0) return [];
if(tail.length === 0) {
return [ fn(head) ];
}
return [].concat(fn(head), map(tail, fn));
}
@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;
}