Skip to content

Instantly share code, notes, and snippets.

@0xa
0xa / pwmgr.sh
Created November 5, 2012 23:29
GPG password manager
#!/bin/bash
# Where to store passwords
DATAFILE="./pwmgr_data.gpg"
# Your GPG key
RECIPIENT="xa@xomg.net"
# Command used to generate passwords
# (pwgen is nice)
class Completer:
def __init__(self, commands):
self.commands = commands
self.completed = None
for name, c in self.commands.items():
c._comp_positionals = len([a for a in c.parser._actions
if not a.option_strings])
def complete_cmd(self, command_name, argv):
@0xa
0xa / ping.js
Created November 19, 2015 00:26
Resource Timing API JavaScript ping
function perf_ping(host, callback, start) {
if (start == undefined) {
var perfEntries = performance.getEntries();
// use the last perf entry to ignore any request preceding
// this ping() call
start = 0;
for (var i = 0; i < perfEntries.length; i++) {
if (start < perfEntries[i].startTime) {
start = perfEntries[i].startTime;
}
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
const char* text = "le avoir savoir nuit leur ton je avant qui pays te se homme chez entrer tout leur encore heure regard "
"jour elle ne au savoir entrer appeler ton revenir fille pied enfant contre ame chambre "
"toujours ce parler coup ne rendre noir pied donc quelque sans peu ciel vie ici mille tres "
@0xa
0xa / check_openvpn.py
Created March 8, 2013 16:44
OpenVPN ping plugin for Nagios
#!/usr/bin/env python
# OpenVPN plugin for Nagios
from optparse import OptionParser
import socket
from datetime import datetime
def main():
senddata= "\x38\x01\x00\x00\x00\x00\x00\x00\x00"
enum Opcodes {
OP_PING = 0x1337
}
class Packet {
public:
Packet(int32_t opcode);
virtual bool encode(std::string& buffer) = 0;
virtual bool decode(const std::string& buffer) = 0;
#ifndef COMMON_SINGLETON_H
#define COMMON_SINGLETON_H
#include <cstdlib>
template<typename T>
class Singleton {
public:
Singleton() {
m_Instance = static_cast<T*>(this);
#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;