Skip to content

Instantly share code, notes, and snippets.


Gabriel Neutzling gneutzling

View GitHub Profile
orther / index.js
Created Jan 27, 2017
A few simple examples of sorting with Ramda's sortBy function.
View index.js
import R from 'ramda';
const items = [
{id: 1, name: 'Al', country: 'AA'},
{id: 2, name: 'Connie', country: 'BB'},
{id: 3, name: 'Doug', country: 'CC'},
{id: 4, name: 'Zen', country: 'BB'},
{id: 5, name: 'DatGGboi', country: 'AA'},
{id: 6, name: 'Connie', country: 'AA'},
ljharb /
Last active Jan 16, 2021
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.


JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

kosamari /
Last active Jan 16, 2021
ServiceWorker for github pages.

ServiceWorker for github pages

This is a ServiceWorker template to turn small github pages into offline ready app.

Why ?

Whenever I make small tools & toys, I create github repo and make a demo page using github pages (like this one).
Often these "apps" are just an index.html file with all the nessesary CSS and JavaScript in it (or maybe 2-3 html/css/js files). I wanted to cache these files so that I can access my tools offline as well.


Make sure your github pages have HTTPS enforced, you can check Settings > GitHub Pages > Enforce HTTPS of your repository.

View .git-commit-template.txt
# [Title] Capitalized, short (50 chars or less) summary, write message in imperative
# [Body] Detailed explanation (72 chars or less), can make usage of markdow, bullet lists...
# [Number/Ticket/Issue] References to issues solved
View javascript-and-drupal.js
* @file
* Always start with a brief, one-line description of the script.
* If more than one line is needed to describe the script, provide more detailed
* comment text following a blank comment line.
// Use an IIFE (immediately invoked function expression) to encapsulate your
// script from other scripts loaded on the page and to prevent pollution of the
// global namespace.
fernandoporazzi / selector.js
Created Mar 24, 2014
A small library to retrieve DOM elements like jQuery.
View selector.js
;(function(w, d, undefined){
'use strict';
var $ = function (e) {
var firstChar = e.charAt(0);
if (firstChar === '#') {
return d.querySelector(e);
} else if (firstChar === '.') {
return d.querySelectorAll(e);
lttlrck / gist:9628955
Created Mar 18, 2014
rename git branch locally and remotely
View gist:9628955
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
hullen / mobileCheck.js
Last active May 30, 2020
Detects mobile devices: phones, tablets. mobileCheck is a lightweight Javascript utils for detecting mobile devices and tablets. Its using User Agent string. Usage: if ( mobileCheck.smarphone ) { // Code }
View mobileCheck.js
var mobileCheck = {
ios: (function(){
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
android: (function(){
return navigator.userAgent.match(/Android/i);
blackBerry: (function(){
return navigator.userAgent.match(/BB10|Tablet|Mobile/i);
vitorbritto /
Last active Aug 1, 2018
Major dependencies that I use on Grunt, Gulp, Bower, Karma and Node/CLI.
guillaumepiot / gist:5585590
Last active Dec 5, 2016
jQuery - YouTube video play/stop on modal open/hide
View gist:5585590
$('#video').modal({'show':true}).on('hidden', function () {
You can’t perform that action at this time.