Skip to content

Instantly share code, notes, and snippets.

View w-vi's full-sized avatar

Vilibald w-vi

View GitHub Profile
@w-vi
w-vi / org-export-generic.el
Created January 4, 2014 20:29
Obsolete but still possibly useful org-mode generic exporter ... ox.el is much better but I still want to keep this around at least as reference code.
;; org-export-generic.el --- Export frameworg with custom backends
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
;; Author: Wes Hardaker <hardaker at users dot sourceforge dot net>
;; Keywords: outlines, hypermedia, calendar, wp, export
;; Homepage: http://orgmode.org
;; Version: 6.25trans
;; Acks: Much of this code was stolen form the ascii export from Carsten
;;
@w-vi
w-vi / zlib_gzip.py
Created April 1, 2014 15:15
How to call zlib to get the gzip inflate / deflate ... definitely not sure if it works in general but so far haven't found where it doesn't.
import zlib
"""
zlib.compressobj(...) ⇒ deflateInit(...)
compressobj.compress(...) ⇒ deflate(...)
zlib.decompressobj(...) ⇒ inflateInit(...)
decompressobj.decompress(...) ⇒ inflate(...)
"""
def deflate(data, compresslevel=9):
compress = zlib.compressobj(
compresslevel, # level: 0-9
@w-vi
w-vi / bitset.h
Last active January 7, 2022 12:22
bit vector in C
/**
* Bit set(vector) macros
*/
#ifndef BITSET_H_
#define BITSET_H_
/*
Taken from comp.lang.c FAQ list · Question 20.8
Don't forget to include <limits.h> for CHAR_BIT.
@w-vi
w-vi / debugging-tips.py
Last active August 29, 2015 13:58
python debugging bits and pieces
#print all locals / globals but try to get rid off the builtin clutter
{k: v for k,v in locals().iteritems() if '__' not in k and 'pdb' not in k}
#something better for messy locals
def debug_nice(locals_dict, keys=[]):
globals()['types'] = __import__('types')
exclude_keys = ['copyright', 'credits', 'False',
'True', 'None', 'Ellipsis', 'quit']
exclude_valuetypes = [types.BuiltinFunctionType,
types.BuiltinMethodType,
@w-vi
w-vi / strdup.c
Last active August 29, 2015 13:59
If strdup and strndup is not present
char *
strdup (const char *s)
{
size_t len = strlen (s) + 1;
void *new = malloc (len);
if(NULL == new) return NULL;
return (char *) memcpy (new, s, len);
}
@w-vi
w-vi / strf.c
Created April 18, 2014 19:44
C string replace, string swap
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <wchar.h>
/*
* Swap string
* Returns copy of the given string in the reverse order.
*/
char *
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
@w-vi
w-vi / valgrind-osx10_9.diff
Last active August 29, 2015 14:00
Valgrind - OSX 10.9.2 - Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) - Darwin Kernel Version 13.1.0
Index: Makefile.all.am
===================================================================
--- Makefile.all.am (revision 13905)
+++ Makefile.all.am (working copy)
@@ -100,7 +100,7 @@
# into (and through) the preloads.
if VGCONF_OS_IS_DARWIN
AM_CFLAGS_PIC = -dynamic -O -g -fno-omit-frame-pointer -fno-strict-aliasing \
- -mno-dynamic-no-pic -fpic -fPIC \
+ -fpic -fPIC \
@w-vi
w-vi / base62.c
Created June 25, 2014 12:39
Base62 encoding
// based on: https://github.com/thehunmonkgroup/node-base62-c/blob/master/base62.cc
static const char base62_vals[] = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const int base62_index[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"