Skip to content

Instantly share code, notes, and snippets.

@calind
calind / agent_type.conf
Created October 12, 2011 17:44
nginx user agent type detection (requires nginx >= 1.0.4)
# agent type detection, based on idea from from http://notnotmobile.appspot.com/
map $http_user_agent $agent_type_phase1 {
default 'mobile';
'' 'unknown';
~*iphone|ipod|blackberry|palm|windows\s+ce 'mobile';
~*windows|linux|os\s+[x9]|solaris|bsd 'desktop';
~*spider|crawl|slurp|bot|feedburner 'bot';
}
map $http_x_skyfire_phone $agent_type_phase2 {
default 'mobile';
@mloskot
mloskot / boost_property_tree_json_array.cpp
Created December 22, 2011 11:11
Simple example of parsing and consuming JSON array with boost::property_tree
#ifdef _MSC_VER
#include <boost/config/compiler/visualc.hpp>
#endif
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <cassert>
#include <exception>
#include <iostream>
#include <sstream>
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@karlgluck
karlgluck / Hash Ladders for Shorter Lamport Signatures.md
Last active March 31, 2024 17:53
I describe a method for making Lamport signatures take up less space. I haven't seen anyone use hash chains this way before, so I think it's pretty cool.

What's this all about?

Digital cryptography! This is a subject I've been interested in since taking a class with Prof. Fred Schneider back in college. Articles pop up on Hacker News fairly often that pique my interest and this technique is the result of one of them.

Specifically, this is about Lamport signatures. There are many signature algorithms (ECDSA and RSA are the most commonly used) but Lamport signatures are unique because they are formed using a hash function. Many cryptographers believe that this makes them resistant to attacks made possible by quantum computers.

How does a Lamport Signature work?

@1aN0rmus
1aN0rmus / KippoUsers.txt
Created July 21, 2014 14:31
List of unique usernames attempted against my Kippo instance
root
a
b
user1
oracle
postgres
test
kippo
nagios
zabbix
@Yawning
Yawning / orhttp_example.go
Created April 29, 2015 14:41
How to dispatch HTTP requests via Tor in Go.
// To the extent possible under law, the Yawning Angel has waived all copyright
// and related or neighboring rights to orhttp_example, using the creative
// commons "cc0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package main
import (
// Things needed by the actual interface.
"golang.org/x/net/proxy"
@ferrouswheel
ferrouswheel / move_to_github.sh
Created November 8, 2015 06:30
Move a launchpad repository to github
#!/bin/bash
# Destination must exist as empty repo on github
GIT_REPO="git@github.com:opencog/opencog.git"
TEMP_PATH=~/src/opencog_bzr_to_git
echo "Using $TEMP_PATH as working dir"
BRANCHES=(trunk UnityEmbodiment)
mkdir -p ${TEMP_PATH}
cd ${TEMP_PATH}
@starius
starius / count_chars.c
Created December 14, 2015 16:53
Print chars' counts as C array of ints
/* Print chars' counts as C array of ints */
#include <stdio.h>
// https://en.wikipedia.org/wiki/C_preprocessor#Token_stringification
#define xstr(s) str(s)
#define str(s) #s
#define NLETTERS 256
#define BUFSIZE (1024 * 1024)
local function sample(it, count, random)
local answer = {}
do
-- first element
local element = it()
if element == nil then
return answer
end
answer[1] = element