Skip to content

Instantly share code, notes, and snippets.

@koenbollen
koenbollen / punch.py
Created July 5, 2010 19:10
Proof of Concept: UDP Hole Punching
#!/usr/bin/env python
#
# Proof of Concept: UDP Hole Punching
# Two client connect to a server and get redirected to each other.
#
# This is the client.
#
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
@lonetwin
lonetwin / print_table.py
Last active May 7, 2021 15:42
print out ascii tables in python using data in the form: [ ('column 0 title', 'column 1 title' ..), ('row 0, column 0 data', 'row 0, column 1 data' ...) ...]
# I needed to print out ascii tables from data in the form:
# [ ('column 0 title', 'column 1 title' ..),
# ('row 0, column 0 data', 'row 0, column 1 data' ...) ...]
#
# and surprisingly it got complicated because of variable lengths of the data.
# I googled for 'standard' ways of doing this and I found suggestions like:
# http://stackoverflow.com/questions/5909873/python-pretty-printing-ascii-tables
# ...which were a bit dated and hard to read or full scale modules like:
#
# http://pypi.python.org/pypi/texttable/
@mislav
mislav / gist:5897126
Last active September 27, 2021 09:34
Low-value pull requests are worse than useless

Why do I feel insulted Re: automated bots making pull requests

An open source project is a lot of work. There are features to be built, bugs to be solved, releases to be made, documentation to be written and the inevitable support you have to provide via GitHub issues, Twitter and mailing lists.

Like anything worth doing, throughout this process there are hard problems that need to be solved. Valued contributors are ones who study the project's philosophy, understand the subject matter and are thinkers who gift their experience and time to the cause.

Therefore a person or a bot who joins in with a pull request that was a result of running a tool against the project's source code—like code linting or stripping of unnecessary whitespace—is a lowest form of contribution there is. It makes the statement: “Here, I didn't bother to see what current problems are in need of discussing/solving, so I ran a widely available script from the command-line t

@chris-allan
chris-allan / server.py
Last active July 19, 2022 15:36
Basic Flask-Security server with principals and MongoDB sessions
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.security import Security, MongoEngineUserDatastore, \
UserMixin, RoleMixin, login_required
from flask.ext.principal import Permission, RoleNeed
# Create app
app = Flask(__name__)
app.config['DEBUG'] = True
@fasterthanlime
fasterthanlime / oh-god-windows.md
Last active December 24, 2022 22:46
Getting rock 0.9.9 to make 32-bit binaries with MSYS2 on Windows

It seems the command-line toolchain of choice changes every fortnight on Windows (except if you're in the MSVC camp, but that's a no-go for ooc at the time of this writing).

The new kid on the block is msys2, which I first had doubts about, but it turns out it's a great way to get a shell, install the packages you need via pacman (!) and get started with ooc on windows.

MSYS2 32-bit

@kkirsche
kkirsche / aes256-gcm.go
Last active February 23, 2024 14:56
AES-256 GCM Encryption Example in Golang
package example_test
import (
"crypto/aes"
"crypto/cipher"
"hex"
"io"
)
// AES-GCM should be used because the operation is an authenticated encryption
@mlocati
mlocati / win10colors.cmd
Last active June 16, 2024 17:49
ANSI Colors in standard Windows 10 shell
@echo off
setlocal
call :setESC
cls
echo %ESC%[101;93m STYLES %ESC%[0m
echo ^<ESC^>[0m %ESC%[0mReset%ESC%[0m
echo ^<ESC^>[1m %ESC%[1mBold%ESC%[0m
echo ^<ESC^>[4m %ESC%[4mUnderline%ESC%[0m
@blixt
blixt / logger_middleware.go
Last active May 11, 2024 05:40
Logger middleware for Go HTTP servers which logs every request with response status code in the Apache format.
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"time"
)
@krlohnes
krlohnes / scalajdb.md
Last active January 27, 2022 18:31
Debugging with jdb in scala

#Debugging Scala with JDB

It seems impossible to find answers on how to debug Scala with jdb on Google. I wanted to consolidate what I've learned in a easy to digest guide. Please feel free to comment with other tips I may have missed, or corrections to what's here.

##Classes Setting a breakpoint in a class is just like debugging java stop at my.package.ClassName:22

@pcan
pcan / README.md
Created April 3, 2017 09:16
Compile Redis with Cygwin

Prerequisites

Install Cygwin with make, gcc & g++. Download Redis tar.gz package, unpack it.

Patch

Edit deps/hiredis/net.c and add the following lines just after the include directives: