Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / dec.cc
Created October 21, 2016 15:56
C++ decimal arithmetic
#include <iostream>
#include <decimal/decimal>
using std::cout;
using std::endl;
template<typename T>
void print(T d)
{
cout << std::decimal::decimal_to_double(d) << endl;
@ozkatz
ozkatz / ec2_ssh_config.py
Created June 21, 2013 00:50
generate an ~/.ssh/config file from your EC2 instances, so that you'd never have to lookup those fugly ec2-xx-xx-xx-xxx.compute-1.amazonaws.com hostnames again. Use your instance name instead!
#!/usr/bin/env python
import os
import sys
import argparse
try:
from boto.ec2.connection import EC2Connection
except ImportError:
sys.stderr.write('Please install boto ( http://docs.pythonboto.org/en/latest/getting_started.html )\n')
sys.exit(1)
@alphapapa
alphapapa / magit.sh
Last active April 5, 2020 10:18
Run a standalone Magit editor!
# Please see the script's new home: https://github.com/alphapapa/magit.sh
@breiter
breiter / Install-Tarsnap.ps1
Last active January 29, 2022 18:41
Unattended installation of tarsnap on Windows
# directory where cygwin will be installed
$cygwinroot="C:\cygwin64"
# choose URL from https://cygwin.com/mirrors.html
$mirror="http://mirrors.kernel.org/sourceware/cygwin/"
# packages to be installed on top of the base. Comma-separated, no spaces
$packages="gcc-core,make,openssl,openssl-devel,zlib-devel,curl,bc"
# version of tarsnap to install
$tarsnapdist=(Invoke-WebRequest -uri https://www.tarsnap.com/download/ -UseBasicParsing).Content -split "`n" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sehe
sehe / Makefile
Last active January 16, 2023 08:29
Boost shared memory lockfree circular buffer queue
all:consumer producer
CPPFLAGS+=-std=c++03 -Wall -pedantic
CPPFLAGS+=-g -O0
CPPFLAGS+=-isystem ~/custom/boost/
LDFLAGS+=-L ~/custom/boost/stage/lib/ -Wl,-rpath,/home/sehe/custom/boost/stage/lib
LDFLAGS+=-lboost_system -lrt -lpthread
%:%.cpp
@haxney
haxney / gist:3055728
Last active February 19, 2023 18:45
List monospace fonts in Emacs
;; Display all the monospace fonts available to Emacs in a dedicated buffer
(defun font-is-mono-p (font-family)
;; with-selected-window
(let ((wind (selected-window))
m-width l-width)
(with-temp-buffer
(set-window-buffer (selected-window) (current-buffer))
(text-scale-set 4)
(insert (propertize "l l l l l" 'face `((:family ,font-family))))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bechu
bechu / boost_tcp_client.cpp
Created April 19, 2012 19:18
simple boost tcp client example
/*
g++ main.cpp -lboost_system -lboost_thread -lpthread -o main
*/
#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <iostream>
void send_something(std::string host, int port, std::string message)
@mathieue
mathieue / udp-multi-socat.sh
Created August 28, 2012 23:57
udp multiplexer with socat
socat - udp4-listen:8125,fork | tee >(socat - udp-sendto:127.0.0.1:8135) >(socat - udp-sendto:127.0.0.1:8140)