Skip to content

Instantly share code, notes, and snippets.

@robabby
robabby / count-css-rules
Last active August 29, 2015 13:57
Count CSS Rules
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@robabby
robabby / FizzBuzz.js
Last active August 29, 2015 14:16 — forked from jaysonrowe/FizzBuzz.js
// Plain version
for (var i=1; i <= 20; i++)
{
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
@robabby
robabby / spacing.css
Last active August 29, 2015 14:24
Spacing CSS
.ptn,.pvn,.pan{padding-top:0px}
.pts,.pvs,.pas{padding-top:5px}
.ptm,.pvm,.pam{padding-top:10px}
.ptl,.pvl,.pal{padding-top:20px}
.prn,.phn,.pan{padding-right:0px}
.prs,.phs,.pas{padding-right:5px}
.prm,.phm,.pam{padding-right:10px}
.prl,.phl,.pal{padding-right:20px}
.pbn,.pvn,.pan{padding-bottom:0px}
.pbs,.pvs,.pas{padding-bottom:5px}
@robabby
robabby / guid.js
Created August 31, 2015 14:09
Create a GUID in JavaScript using the module pattern
module.exports = function() {
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}

HTML5 Markup Template - Basic

A very basic starter template with fundamental HTML5 markup -- only the basics.

Based on HTML5 Bones | http://html5bones.com

@robabby
robabby / walk-the-dom.js
Created November 6, 2015 13:13
A simple function to start walking the DOM written in vanilla JS
function walkTheDOM(node) {
if (node.nodeType == 1) {
//console.log(node.tagName);
node = node.firstChild;
while (node) {
theDOMElementWalker(node);
node = node.nextSibling;
function LinkedList() {
var Node = function(element) {
this.element = element;
this.next = null;
};
var length = 0;
var head = null;
this.append = function(element) {
function occurences(n, arr) {
var first = -1;
var last = -1;
if (arr === null || arr.length === 0 || arr[0] > n || arr[arr.length - 1] < n) {
return [first, last];
}
for (var i = 0; i < arr.length; i++) {
var num = arr[i];
if (num === n) {
@robabby
robabby / ionic.project
Created January 7, 2016 01:40
A sample ionic.project file
{
"name": "Your App Name",
"app_id": "",
"gulpStartupTasks": [
"sass",
"watch"
],
"watchPatterns": [
"www/**/*",
"!www/lib/**/*"
@robabby
robabby / reducer-boilerplate.js
Created June 4, 2017 23:07
React Native Reducer Boilerplate
import {
SOME_ACTION // to be specified per use case
} from '../actions/types';
const INITIAL_STATE = {
}
export default (state = INITIAL_STATE, action) => {
switch (action.type) {