Skip to content

Instantly share code, notes, and snippets.

@shanimal
shanimal / js-testing-playground.html
Created November 18, 2016 16:20 — forked from calvinf/js-testing-playground.html
JavaScript Testing Playground (Mocha, Chai, and $script)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript Testing Playground</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.2.5/mocha.min.css" rel="stylesheet" />
<style>
*, *:before, *:after {
@shanimal
shanimal / SecretNumber.js
Last active September 24, 2016 07:48
Pick any number. Add the digits. Repeat until there is only one digit in your number. Multiply that by 5. Multiply that by 2. Subtract 2. Your number is 8.
/**
* Pick any number.
* Add the digits.
* Repeat until there is only one digit in your number.
* Multiply that by 5.
* Multiply that by 2.
* Subtract 2.
* Take the last digit in this number
* Your number is 8.
*/
$('#myParentElement').one('click','a.myClass',function(){
/* this code will execute only once */
$('#myParentElement a.myClass').editable().click();
});
/**
* parseURIData(location.search.substr(1));
* @param search
* @returns {*}
*/
module.exports = function (search) {
var result = {};
if(!search.length){
return result;
}
@shanimal
shanimal / xss_ex
Last active January 2, 2016 01:09
simple xss example
alert('Im a script located on gist.github via rawgithub and I\'ve been injected into this demo @' + document.location.origin)
alert('I have full access to JS to do things like read your cookies... Check this out... ' + document.cookie);
alert('I can also access the websites API to change your password or steal your credit card number');
alert('XSS can be used for Eve-ill');
body {
background-color:#444;
font-family:helvetica, arial
}
.content {
margin:0 auto;
width:950px;
background-color: #EEE;
padding:0;
}
@shanimal
shanimal / config.js
Last active December 11, 2015 16:08
sample requirejs cdn configuration
require.config({
paths:{
'jquery':'//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min',
'lodash':'//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.2/lodash.min',
'foundation':'//cdnjs.cloudflare.com/ajax/libs/foundation/3.2.2/javascripts/foundation.min',
'text':'//cdnjs.cloudflare.com/ajax/libs/require-text/2.0.3/text'
}
});
require([
'jquery',
@shanimal
shanimal / LoanCalculator.hbs
Created November 12, 2015 05:29
Notes for a Generic Component Based Application
{{!
* Keep blocks used by exclusively by ComponentLoanCalculator inside this file and prefix them with ComponentLoanCalculator
* When designing your partials, assume the container will control margins, dimensions and positioning.
* Assume a generic 5-10px padding for components (defined in the theme .component)
* For information on breakpoint see the scss file
* for angular apps use square brackets for binding [[myVar]] (because curly brackets are used by handlebars)
* Document this document vigilantly
}}
{{#partial "ComponentLoanCalculator"}}
<div class="component LoanCalculator [[breakpoint]]">
@shanimal
shanimal / nicknames.json
Created November 9, 2012 19:43
nicknames
define(function(){
return {
"Beth" : "Elizabeth",
"Theo" : "Theodore",
"Drew" : "Andrew",
"Fred" : "Alfred",
"Tony" : "Antony",
"Alex" : "Alexander",
"Ben" : ["Benjamin","Benedict"],
"Eliza" : "Elizabeth",
var system = require('system');
var args = system.args;
var env = system.env;
var os = system.os;
console.log("\nSYSTEM");
console.log(os.architecture); // '64bit/32bit'
console.log('os',os.name); // 'mac/windows'
console.log('version',os.version); // '10.9 (Mavericks)/7'
console.log('pid',system.pid)