Skip to content

Instantly share code, notes, and snippets.

var foo = new String(Math.random());
var bar = foo.substring(2, 12);
console.log(bar)
@panicbus
panicbus / slide-drawer.js
Last active January 16, 2018 21:31
plugin that slides in an off-canvas drawer from right or left
/**
* Created by Michael 7/20/15
*/
var FF = FF || {};
/**
* FF - drawers.js
*
* Sets up funcionality necessary to make the left and right slideout drawers work
@panicbus
panicbus / addPulse.js
Created December 4, 2017 17:32
a little css pulse of the heart
$('.selector').on('click', function() {
$(this).addClass('addPulse');
})
Usage
ctrl-alt-l launch live server on port 3000.
ctrl-alt-q stop live server.
ctrl-alt-3 launch live server on port 3000.
ctrl-alt-4 launch live server on port 4000.
@panicbus
panicbus / fibonacci.js
Created February 24, 2017 18:53
Fibonacci sequence
var a, b, temp;
a = 0;
b = 1;
temp = b;
for (i = 0; i < 20; i++) {
console.log(temp);
temp = a + b;
a = b;
@panicbus
panicbus / fizzbuzz.js
Last active November 15, 2017 18:13
Two variations of FizzBuzz
for (var i = 0; i < 101; i++){
console.log(i);
if (i % 3 === 0 && i % 5 === 0)
console.log("fizzbuzz");
else if
(i % 5 === 0)
console.log("buzz");
else if
(i % 3 === 0)
console.log("fizz");
@panicbus
panicbus / isPalindrone.js
Created October 20, 2016 18:42
Find whether a string is a palindrome
function isPalindrome(str){
var nospace = str.split(' ').join('');
var len = nospace.length;
for (var i = 0; i < len/2; i++) {
if (nospace[i] !== nospace[len -1 -i])
return false;
}
return true;
}
isPalindrome('he, a man a plan a canal panama, eh');
@panicbus
panicbus / yeoman-angular-generator.txt
Created October 20, 2016 18:41
Quickly generate an Angular scaffolding with Yeoman
$ npm install -g yo
$ npm install -g generator-angular
$ mkdir myProject && cd $_
$ yo angular myProject
$ yo angular:route main // generate a controller and a view and put them into a route (to main.js)
@panicbus
panicbus / sort.js
Created October 20, 2016 18:40
Neat JS sort function
Array.prototype.nSort = nSort;
// [].prototype.nSort works too
function nSort(){
return this.sort(
function numSort(n1, n2){
if (n1 < n2) return -1;
if (n1 > n2) return 1;
return 0;
}
@panicbus
panicbus / stylus-mixins.styl
Created October 20, 2016 18:40
Stylus mixin syntax
vendor(prop, args)
-webkit-{prop} args
-moz-{prop} args
-ms-{prop} args
-o-{prop} args
{prop} args
border-radius()
vendor('border-radius', arguments)