using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
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 url = require("url"); | |
| var multipart = require("./multipart/multipart"); | |
| var sys = require("sys"); | |
| var fs = require("fs"); | |
| var server = http.createServer(function(req, res) { | |
| // Simple path-based request dispatcher | |
| switch (url.parse(req.url).pathname) { | |
| case '/': |
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
| private Boolean firstTime = null; | |
| /** | |
| * Checks if the user is opening the app for the first time. | |
| * Note that this method should be placed inside an activity and it can be called multiple times. | |
| * @return boolean | |
| */ | |
| private boolean isFirstTime() { | |
| if (firstTime == null) { | |
| SharedPreferences mPreferences = this.getSharedPreferences("first_time", Context.MODE_PRIVATE); | |
| firstTime = mPreferences.getBoolean("firstTime", true); |
This file has been truncated, but you can view the full file.
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
| ZIP,LAT,LNG | |
| 00601,18.180555, -66.749961 | |
| 00602,18.361945, -67.175597 | |
| 00603,18.455183, -67.119887 | |
| 00606,18.158345, -66.932911 | |
| 00610,18.295366, -67.125135 | |
| 00612,18.402253, -66.711397 | |
| 00616,18.420412, -66.671979 | |
| 00617,18.445147, -66.559696 | |
| 00622,17.991245, -67.153993 |
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 singleton | |
| import ( | |
| "sync" | |
| ) | |
| type singleton struct { | |
| } | |
| var instance *singleton |
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
| Install HAProxy from Homebre: | |
| `brew install haproxy` | |
| For full reference: | |
| https://serversforhackers.com/load-balancing-with-haproxy |
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
| import io | |
| import scp | |
| import paramiko | |
| import boto3 | |
| import logging | |
| logging.basicConfig(level=logging.DEBUG, format='%(asctime)s :: %(levelname)s :: %(message)s') | |
| boto_logger = logging.getLogger('boto_logger') | |
| ###################### Private Stuff |
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
| from threading import Timer | |
| from functools import partial | |
| class Interval(object): | |
| def __init__(self, interval, function, args=[], kwargs={}): | |
| """ | |
| Runs the function at a specified interval with given arguments. | |
| """ | |
| self.interval = interval |
$ cd /tmp/
$ wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz
$ sha256sum go1.13.linux-amd64.tar.gz # should end with "c48e856"
$ sudo tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz