Skip to content

Instantly share code, notes, and snippets.

Avatar

Gabriel Neutzling gneutzling

View GitHub Profile
@erichonorez
erichonorez / rest_api.js
Created Feb 10, 2013
A simple REST API with Node.js and Express
View rest_api.js
/**
* TaskRepository class deals with task persistence
*/
function TaskRepository() {
this.tasks = [];
this.nextId = 1;
}
/**
* Find a task by id
* Param: id of the task to find
@guillaumepiot
guillaumepiot / gist:5585590
Last active Dec 5, 2016
jQuery - YouTube video play/stop on modal open/hide
View gist:5585590
$('.close').click(function(){
$('#video').modal('hide');
})
$('#open-video').click(function(){
$('#video').modal({'show':true}).on('hidden', function () {
toggleVideo('hide');
});
toggleVideo();
})
@vitorbritto
vitorbritto / _toc.md
Last active Aug 1, 2018
Major dependencies that I use on Grunt, Gulp, Bower, Karma and Node/CLI.
@hullen
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);
}()),
@lttlrck
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
@fernandoporazzi
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);
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.
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
@kosamari
kosamari / _ServiceWorker_for_github_pages.md
Last active Jul 16, 2020
ServiceWorker for github pages.
View _ServiceWorker_for_github_pages.md

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.

Notes

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

@ljharb
ljharb / array_iteration_thoughts.md
Last active Aug 1, 2020
Array iteration methods summarized
View array_iteration_thoughts.md

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.

Intro

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

You can’t perform that action at this time.