Skip to content

Instantly share code, notes, and snippets.

View duduindo's full-sized avatar
🏊‍♀️
beach ❤️

Eduardo Paixão duduindo

🏊‍♀️
beach ❤️
View GitHub Profile
@subimage
subimage / array_chunk.js
Created April 19, 2012 06:50
Javascript array chunk
// Splits an array into equal sized chunks
Array.prototype.chunk = function(pieces) {
pieces = pieces || 2;
var len = this.length;
var mid = (len/pieces);
var chunks = [];
var start = 0;
for(var i=0;i<pieces;i++) {
var last = start+mid;
if (!len%pieces >= i) {
@leobetosouza
leobetosouza / gist:2856498
Created June 2, 2012 04:00
JavaScript Design Patterns Hangout
Links, livros, artigos e etc comentados durante o Hangout 'JavaScript e Design Patterns': http://youtu.be/FkED71eM7s8
@dhavaln
dhavaln / filesystem.js
Created June 8, 2012 08:51
PhoneGap Filesystem Example
/**
* Prepare the App Folder
*/
(function(){
window.appRootDirName = ".myapp";
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("device is ready");
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
@0xjjpa
0xjjpa / communication.js
Created December 26, 2012 19:15
Basic communication between a Background Page and a Content Script inside a Chrome Extension.
// In Background.js
chrome.tabs.sendMessage(tab.id, {content: "message"}, function(response) {
if(response) {
//We do something
}
});
// In ContentScript.js
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
if(request.content) {
@quitschibo
quitschibo / testMocks.js
Last active July 21, 2023 17:25
How to mock jQuery calls with Jasmine. Just some examples ;)
describe('Mock jQuery calls with Jasmine', function() {
it('how to mock $("test").show()', function() {
// mock the call
spyOn($.fn, 'show').andCallFake(function() {
return true;
});
// now we can call the mock
result = $("test").show();
@rxaviers
rxaviers / gist:7360908
Last active May 4, 2025 13:24
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@soheilhy
soheilhy / nginxproxy.md
Last active April 11, 2025 06:29
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@jhartikainen
jhartikainen / commit-msg
Created February 6, 2015 17:46
ESLint git commit hook
#!/bin/bash
files=$(git diff --cached --name-only | grep '\.js$')
# Prevent ESLint help message if no files matched
if [[ $files = "" ]] ; then
exit 0
fi
echo $files | xargs eslint
@bcabanes
bcabanes / cordovaListFileEntries.js
Created December 10, 2015 16:07
Cordova/PhoneGap: List all files entries in directories provided.
/**
* Starter vars.
*/
var index = 0;
var i;
/**
* Need cordova.file plugin.
* $ cordova plugin add org.apache.cordova.file
*
import postcss from 'postcss';
import fs from 'fs';
export default (glyphs) => {
let stylesheet = postcss.root();
glyphs.forEach((glyph) => {