Skip to content

Instantly share code, notes, and snippets.

View pedromcunha's full-sized avatar
🤘
Hello! Olá!

Pedro Cunha pedromcunha

🤘
Hello! Olá!
View GitHub Profile
var list = document.getElementById('friendsList'),
friends = ["Andre",
"Pedro",
"Johnny",
"Fer",
"Tiago",
"Danny"],
fragment = document.createDocumentFragment(),
element;
for(var i = 0, l = friends.length; i<l; i++) {
var passengers = [ ["Thomas", "Meeks"],
["Gregg", "Pollack"],
["Christine", "Wong"],
["Dan", "McGaw"] ];
var modifiedNames = passengers.map(
function (cell) {
return cell[0] + ' ' + cell[1];
}
);
@pedromcunha
pedromcunha / gist:64b9dee5ca71be4326ac
Created August 9, 2014 03:30
Namespaces : Modularity Design Pattern
var TARRYTOWN = {
knights: 100,
citizens: 500,
stapleFood: "mutton chops",
alertTheLord: function() {
alert("We need help my lord, please send reinforcements!")
},
KINGSKEEP: {
calvary: 25,
knights: 200,
var CLASSLIST = function (){
var maleStudents = 15,
femaleStudents = 20;
return {
amountOfStudents: function () {
return maleStudents + femaleStudents;
},
CURRICULUM: {
classStart: "September 15th 2014",
@pedromcunha
pedromcunha / gist:b6a1b6dc20b04fdbde94
Created August 9, 2014 04:28
Modular Pattern - Importing Global Variables when using closures.
var year = 2014;
var CLASSLIST = function (classYear){
var maleStudents = 15,
femaleStudents = 20;
return {
yearBookTitle: function () {
return "Congradulations year of " +
classYear +
@pedromcunha
pedromcunha / gist:c420b5b22b7d655569ac
Created August 9, 2014 05:27
Modular Design Pattern : Augmenting your module
CAVESOFCLARITY = function (caves) {
var sandScript = "";
caves.setSandScript = function (message) {
sandScript = message;
};
return caves;
}(CAVESOFCLARITY);
//Notice how we are passing the CAVESOFCLARITY module, which was recently created in another code sample.
@pedromcunha
pedromcunha / gist:bb51d9e255ac855556f9
Created August 27, 2014 05:41
Directive for add and delete pills
module.directive('addPill', ['$compile', '$rootScope', function($compile, $rootScope) {
return {
link: function(scope, elem, attrs){
elem.bind('click', function(){
var filter = elem[0]['innerText'],
id = filter.replace(/[^\w\s]/gi, '').split(' ').join('');
$rootScope.dropdownFilters.push(filter);
angular.element(document.getElementById('filters-applied')).append($compile('<div id="'+id+'" class="btn-group btn-group-xs"><button type="button" class="btn btn-gray btn-xs disabled filter-label ng-binding">'+filter+'</button><button type="button" class="btn btn-gray btn-xs delete" remove-pill><i class="fa fa-times"></i></button></div>')(scope));
});
}
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
git branch --merged >/tmp/merged-branches && vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches
@pedromcunha
pedromcunha / aoc-1.js
Last active December 6, 2019 18:39
Advent of Code Day 1
let modules = ["109506", "140405", "139135", "110950", "84296", "123991", "59438", "85647", "81214", "100517", "100910", "57704", "83368", "50777", "85523", "95788", "127699", "138908", "95502", "81703", "67317", "108468", "58394", "72202", "121580", "86908", "72705", "86578", "83714", "114900", "142915", "51332", "69054", "97039", "143539", "61143", "113534", "98335", "58533", "83893", "127138", "50844", "88397", "133591", "83563", "52435", "96342", "109491", "81148", "127397", "86200", "92418", "144842", "120142", "97531", "54449", "91004", "129115", "142487", "68513", "140405", "80111", "139359", "57486", "116973", "135102", "59737", "144040", "95483", "134470", "60473", "113142", "78189", "53845", "124139", "78055", "63791", "99879", "58630", "111233", "80544", "76932", "79644", "116247", "54646", "85217", "110795", "142095", "74492", "93318", "122300", "82755", "147407", "98697", "98105", "132055", "67856", "109731", "75747", "135700"]
let total = modules.map((module) => {
let totalFuelCost = 0
let c