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
/** | |
* Return inside try/finally | |
*/ | |
// THIS IS JUST A TEST CASE | |
// AVOID USING SUCH CONSTRUCTS IN PRODUCTION CODE | |
// foo is either 0 or 1 | |
var foo = Math.round(Math.random() * 10) % 2; |
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
/** | |
* Searches object in Array by key | |
* | |
* Usage: | |
* | |
* List should be an Array like this | |
* var foo = {}; | |
* var list = [ | |
* { name: {} }, { name: foo }, { 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
function foo() { | |
var s = 4; | |
var t = 1; | |
while(s --> t) { console.log(s) } | |
} | |
// Output | |
// 3 | |
// 2 | |
// 1 |
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
#!/bin/sh | |
# Uses getopts to parse passed arguments | |
# Show usage | |
show_help() { | |
cat << EOF | |
Usage: echoback -m message |
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
#!/bin/sh | |
# The MIT License (MIT) | |
# Copyright (c) 2014 Debjeet Biswas | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
/** | |
* Asynchronously fetches a template & caches it internally | |
* | |
* If a request for a template hasn't completed yet and another | |
* request arrives, then instead of queuing the request resolve | |
* the deffered with the previously cached request | |
*/ | |
function fetchTemplate(path) { | |
/** |
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 isElementInViewport (el) { | |
//special bonus for those using jQuery | |
if (typeof jQuery === "function" && el instanceof jQuery) { | |
el = el[0]; | |
} | |
var rect = el.getBoundingClientRect(); | |
return ( |
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
var keys = ['apple', 'orange', 'grape', 'banana']; | |
function gen(keys, type, def) { | |
var constructor = type.constructor; | |
var obj = {}; | |
keys.forEach(function(key) { | |
obj[key] = typeof constructor === 'function' ? constructor(clone(def)) : undefined; | |
}); | |
return obj; |
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
openssl pkcs12 -export -out server.p12 -inkey server.key -in server.crt -certfile CACert.crt |