This file contains hidden or 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 crypto = require("crypto"); | |
| function encrypt(key, data) { | |
| var ciph = crypto.createCipher("aes256", key); | |
| ciph.end(data); | |
| var encBuffer = ciph.read(); | |
| // Convert to base64 | |
| return encBuffer.toString("base64"); |
This file contains hidden or 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 http = require("http"); | |
| var fs = require("fs"); | |
| function getFile(url, saveFile, cb) { | |
| var request = http.get(url, response => { | |
| var write$ = fs.createWriteStream(saveFile); | |
| write$.on("error", cb); | |
| write$.on("finish", () => cb(null)); | |
| response.pipe(write$); |
This file contains hidden or 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
| mongodata: | |
| image: mongo:3.2.6 | |
| volumes: | |
| - /data/mongodb | |
| command: --break-mongo | |
| mongo: | |
| image: mongo:3.2.6 | |
| volumes_from: | |
| - mongodata |
This file contains hidden or 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
| package main | |
| import "fmt" | |
| type Command interface { | |
| Execute() string | |
| } | |
| type PingCommand struct{} | |
| func (p *PingCommand) Execute() string { |
This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| // Function blocks the execution until the heavy execution is done | |
| func heavySum(a, b int) chan int { |
This file contains hidden or 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
| package main | |
| import ( | |
| "bytes" | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" | |
| "os" |
This file contains hidden or 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 | |
| scrot /tmp/screenshot.png | |
| convert /tmp/screenshot.png -blur 0x7 /tmp/screenshotblur.png | |
| i3lock -i /tmp/screenshotblur.png |
This file contains hidden or 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
| "use strict"; | |
| const vo = require("vo"); | |
| function wait(fn, time) { | |
| time = time || 0; | |
| if (typeof fn === "function") { | |
| fn = fn(); |
This file contains hidden or 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
| gulp.task("package-check", function () { | |
| // Output the packages which needs upgrade | |
| var format = function (upgraded) { | |
| var packages = Object.keys(upgraded); | |
| console.log("Following packages needs to be upgraded:"); | |
| packages.forEach(function (packageName) |
This file contains hidden or 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
| // Exponential moving average | |
| function average (alpha) { | |
| var last; | |
| alpha = alpha || 3/4; | |
| return function (input) { | |
| if (!last) { | |
| last = input; |