This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isNumber(value) { | |
return typeof value === 'number' && isFinite(value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Thanks to Dmitry Baranovsky for his knowledge sharing: | |
* http://dmitry.baranovskiy.com/post/typeof-and-friends | |
*/ | |
function is (value) { | |
return { | |
aan: function (type) { | |
type = String(type).toLowerCase(); | |
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase() === type; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* portrait phone (< 480px) */ | |
@media screen and (max-width:29.9999em) { | |
} | |
/* landscape phone and portrait tablet (>= 480px < 960px) */ | |
@media screen and (min-width:30em) and (max-width:59.9999em) { | |
} | |
/* landscape tablet and normal monitor (>= 960px < 1440px) */ | |
@media screen and (min-width:60em) and (max-width:89.9999em) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Ubuntu Tweak | |
# | |
sudo add-apt-repository ppa:tualatrix/ppa -y && sudo apt-get update && sudo apt-get install ubuntu-tweak -y | |
# | |
# Git | |
# | |
sudo apt-get update && sudo apt-get install git giggle -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These are colors in our palette | |
availableColors = red #F00, | |
blue #00F, | |
green #0F0 | |
// Function that can find a color by name | |
colourByName(name) | |
return pair[1] if name == pair[0] for pair in availableColors | |
// Now we can find our color by name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sometimes it's needed to get access to body or head elements within an iFrame. | |
// Here is a peace of code that helps to do this without jQuery. | |
var iFrameContent = window.iFrameContent || {}; | |
iFrameContent.withIn = function(iFrameElement) { | |
if (!iFrameElement) { | |
throw 'Please, specify an iFrame to work with'; | |
} | |
if (iFrameElement.nodeName !== 'IFRAME') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/24761145/993216 | |
describe("myDirective", function() -> | |
var el, scope, controller; | |
beforeEach inject(function($compile, $rootScope) { | |
el = angular.element("<my-directive></my-directive>") | |
$compile(el)($rootScope.$new()) | |
$rootScope.$digest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspired by Haskell's `takeWhile (<10000) $ map (^3) [1..]` | |
let nextVal = (x) => x.next().value; | |
function* mList(x = 0) { | |
while(1) yield x++; | |
} | |
function* map(fn, list) { | |
while(1) { | |
yield fn(nextVal(list)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the implmenetation of some of the lamdas from lamda calculus | |
// https://en.wikipedia.org/wiki/Lambda_calculus | |
console.clear(); | |
const log = function(x) { | |
console.log('log: ' + x); | |
return x; | |
} | |
// Boolean: |
OlderNewer