Skip to content

Instantly share code, notes, and snippets.

Gal Ben-Haim bsphere

Block or report user

Report or block bsphere

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bsphere / timestamp.go
Last active Oct 22, 2019
UNIX timestamps in Golang
View timestamp.go
package timestamp
import (
type Timestamp time.Time
bsphere /
Last active Apr 5, 2019
How to catch exceptions raised by Python worker threads
import Queue
import threading
class WorkerThread(threading.Thread):
def __init__(self, q):
super(WorkerThread, self).__init__()
self q = q
self.exception = None
View errs.go
package main
import (
var (
// ErrNotFound is returned when something isn't found
ErrNotFound = errors.New("not found")
public class MyHTTPClientTest extends AndroidTestCase {
private MockWebServer mServer;
private MyHTTPClient mClient;
public void setUp() throws Exception {
mServer = new MockWebServer();;
mClient = new MyHTTPClient(mServer.getUrl("/"));
public class MyHTTPClient {
private URL mUrl;
public MyHTTPClient(URL url) {
mUrl = url;
public String getString() throws IOException {
HTTPUrlConnection urlConnection = null;
URL url = new URL(mUrl, "/string");
View gist:4700801
node.js (version 0.8.18):
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '');
console.log('Server running at');
View haproxy.cfg
maxconn 4096
mode http
frontend insecure
bind :80
View default.vcl
backend nginx {
.host = "";
.port = "8080";
backend node1 {
.host = "";
.port = "3000";
View post-receive
GIT_WORK_TREE=/home/ubuntu/myapp git checkout -f
echo "Installing dependencies..."
cd /home/ubuntu/myapp
npm install
echo "Restarting node.js..."
sudo restart myapp
bsphere / myapp.conf
Last active Dec 10, 2015
Monit config file for Node.js and Upstart
View myapp.conf
check host localhost with address
start "/sbin/start myapp"
stop "/sbin/stop myapp"
if failed port 3000 protocol HTTP
request /
with timeout 5 seconds
then restart
You can’t perform that action at this time.