Skip to content

Instantly share code, notes, and snippets.

# coding: utf-8
# based on http://baguzin.ru/wp/?p=7873
import re
class AssParser:
def __init__(self):
self.dialog_re = re.compile(r'Dialogue:(?:[^,]*,){9}(.*)')
@bradfitz
bradfitz / blast.pl
Created April 16, 2012 04:56
Cognac Hacking
#!/usr/bin/perl
use strict;
my $rockettop = <<'END';
.
/ \
/ \
END
@adeelejaz
adeelejaz / jquery.browser.js
Last active January 9, 2018 18:15
jQuery $.browser as a separate file in case you do not want to include the full migration file
(function( jQuery, window, undefined ) {
"use strict";
var matched, browser;
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
@simurai
simurai / Overlay Grid
Created February 26, 2011 16:54
A flexible grid overlay to test your site's alignment.
/* Grid */
html:before, html:after {
content: "";
position: absolute;
top: 0;
right: 0;
pointer-events: none;
/* change to px if you get a scrollbar */
@rozza
rozza / decorator.py
Created October 18, 2010 09:17
A decorator for django management commands that ensures only one process is running at any one time.
"""
A decorator for management commands (or any class method) to ensure that there is
only ever one process running the method at any one time.
Requires lockfile - (pip install lockfile)
Author: Ross Lawley
"""
import time
@rkfg
rkfg / gifcreate
Last active February 4, 2021 21:01
GIF animation script to cut a piece of video and produce a frame-accurate optimized GIF with a precise framerate.
#!/bin/sh
help () {
log "Usage: `basename $0` [-h] [-n] [-a] [-u] [-s hh:mm:ss] [-d ss] [-w px] [-f n] [-S n] [-b n] [-t subtitle.sub] [-c default | basic | fontsize | fontstyle | full] <filename> [result.gif]
-h show this help
-n turn off subtitles
-a don't open directory with frames in filemanager
-u update this script from gist. Create .gifupd file in the script's directory to automatically check for updates once per day or put the number of seconds in the file to check with that period.
-s start time in seconds or as hours:minutes:seconds, default: 0
@martinsik
martinsik / libwebsockets-webserver.c
Created July 31, 2012 11:34
Simple webserver based on libwebsockets library. Read full description at http://martinsikora.com/libwebsockets-simple-http-server
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libwebsockets.h>
static int callback_http(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
// From http://baagoe.com/en/RandomMusings/javascript/
function Alea() {
return (function(args) {
// Johannes Baagøe <baagoe@baagoe.com>, 2010
var s0 = 0;
var s1 = 0;
var s2 = 0;
var c = 1;
if (args.length == 0) {
@canterberry
canterberry / crypto.ec.pem.js
Created April 26, 2018 23:15
Export PEM-encoded EC key pair (ECDH, ECDSA)
// (Buffer is available in Node.js as a global, but we require it this way for compatibility)
// See: https://nodejs.org/api/buffer.html#buffer_buffer
const { Buffer } = require('buffer');
const crypto = require('crypto');
const keyPair = crypto.createECDH('secp256k1');
keyPair.generateKeys();
// Print the PEM-encoded private key
@domenic
domenic / q-nexttick-times.md
Created May 27, 2012 06:30
Q test suite nextTick results

Comparing Different Implementations of process.nextTick using the Q test suite.

Used: q-spec.js@a1a416.

Implementations compared:

Based on MessageChannel

This is currently in Q: