$ openssl rand -hex 10
f5c50af369ffac1ec902
input = [ | |
{ name: "key1", value: "value1" }, | |
{ name: "key2", value: "value2" } | |
] | |
output = { | |
key1: "value1", | |
key2: "value2" | |
} |
db.allDocs(include_docs:true).then((docs) -> docs.rows.map((doc) -> db.remove(doc.doc))) |
// register event listener with jquery | |
$(document).on("my:foo", function(){alert("ev thru jq api")} ); | |
// register event with dom api | |
document.addEventListener("my:foo", function(){alert("ev thru dom api")}); | |
// trigger event with jquery api | |
$(document).trigger("my:foo", {}); | |
// trigger event with dom api |
# Step 1 | |
[1,2,3].map((x) -> x * 2) | |
# Step 2 | |
double = (x) -> x * 2 | |
[1,2,3].map((x) -> double x) | |
# Step 3 | |
[1,2,3].map(double) |
y = [1,2,[4,5],3] | |
y.reduce(((a,b)-> a.concat b),[]) | |
.map((z)->console.log z) | |
# or | |
y.reduce((a,b) -> [].concat(a,b)) | |
.map((z)->console.log z) |
x = a:b:c:10 | |
ns = "a.b.c" | |
a = ns.split('.').reduce(((z,i) -> z[i]), x) | |
console.log a |
# will not work | |
expect(new MyObject("with invlaid data")).to.throw(Error) | |
# give a function to expect | |
expect( -> new MyObject("with invlaid data")).to.throw(Error) | |
# this should work |
echo "hello" > logs-$(date +"%Y-%m-%d").txt |
$ openssl rand -hex 10
f5c50af369ffac1ec902
import java.util.zip.ZipInputStream | |
import groovy.io.FileType | |
import java.util.zip.ZipEntry | |
def zip = new ZipInputStream(new URL("https://github.com/kdabir/init/archive/master.zip").newInputStream()) | |
def currentDir = new File(System.getProperty("user.dir")) | |
def thisFile = new File(getClass().protectionDomain.codeSource.location.path).name | |
zip.withStream { |