Skip to content

Instantly share code, notes, and snippets.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@coffeesnake
coffeesnake / serve.py
Created July 11, 2012 21:19
quick'n'dirty multithreaded wsgiref sample
from wsgiref.simple_server import make_server, WSGIServer
from SocketServer import ThreadingMixIn
from time import sleep
def simple_app(env, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain')]
start_response(status, headers)
@juanje
juanje / gist:3797297
Created September 28, 2012 00:38
Mount apt cache of a Vagrant box in the host to spin up the packages installation

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
 cache_dir
@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@davidvollmar
davidvollmar / AdapterEchoSocket.java
Created March 30, 2015 18:38
Enabling websocket for spark-java
import com.google.gson.Gson;
import model.GameState;
import model.GameStateProvider;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import java.io.IOException;
/**
* Example EchoSocket using Adapter.
*/
@GregoryHlavac
GregoryHlavac / WebSocketExample.java
Created April 11, 2015 22:15
Enabling websockets in spark with @davidvollmar 's socket and servlet adapters combined with an altered way to mount the rest of the handlers.
package spark;
import org.eclipse.jetty.servlet.ServletContextHandler;
public class WebSocketExample
{
public static void main(String[] args)
{
setupSpark();
Spark.get("/", (request, response) -> "Hello");
@bbolli
bbolli / win32_error_category.cpp
Created January 27, 2017 14:54
A C++11 std::error_category for Win32 and Winsock error codes
#include <system_error>
#include <windows.h>
/// Wrap the Win32 error code so we have a distinct type.
struct win32_error_code
{
explicit win32_error_code(DWORD e) noexcept : error(e) {}
DWORD error;
};
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active July 16, 2024 12:41
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@tomfanning
tomfanning / vm-superhub3.txt
Created January 5, 2018 22:25
Virgin Media Super Hub 3 router status research
Status page
curl 'http://192.168.100.1/snmpGet?oids=1.3.6.1.4.1.4115.1.3.4.1.5.9.0;1.3.6.1.4.1.4115.1.3.3.1.1.1.3.1.0;1.3.6.1.4.1.4491.2.1.14.1.5.4.0;1.3.6.1.4.1.4115.1.20.1.1.1.7.1.3.1;1.3.6.1.2.1.10.127.1.1.5.0;1.3.6.1.2.1.126.1.1.1.1.1.2;1.3.6.1.2.1.69.1.4.5.0;&_n=21943&_=1515184469506'
Item Status Comments
Acquired Downstream Channel(Hz) 547000000 Locked
Ranged Upstream Channel(Hz) 39400000 Locked
Provisioning State Online
@mlalkaka
mlalkaka / ue-roll.sh
Last active October 30, 2022 11:31
Power on and off a UE Roll via Bluetooth using GATT and SPP
#!env sh
mac=C0:28:8D:00:2A:A8
function ue_on() {
handle=0x0003
value=b469218dd9e701
gatttool -b $mac --char-write-req --handle=$handle --value $value
}