This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is how to fix things if you somehow manage to end up with two | |
| # repositories for the same project, where the last changeset in the | |
| # old repo should be the parent of the first changeset in the new one. | |
| # I needed to do this for Schism Tracker at one point. No idea how I | |
| # mangled it, but here's what I did. | |
| # (A tip of the hat owed to #mercurial on Freenode for helping me.) | |
| # FOREWARNING: this will alter all the changeset IDs in the new repo! | |
| newid=$(hg -R newrepo log -r0 --template '{node}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import struct, os, subprocess | |
| """ | |
| 030200?? - buttons that are currently down | |
| 01 play/pause | |
| 02 increase volume | |
| 04 decrease volume | |
| 08 next |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @namespace url(http://www.w3.org/1999/xhtml); | |
| /* (CC-BY) Storlek - https://twitter.com/SwedishForSize | |
| Drop this into Stylish or similar. */ | |
| @-moz-document domain("twitter.com") { | |
| .context .pretty-link, | |
| .social-context .pretty-link, | |
| .stream-item-activity-line-notification .pretty-link { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| die() { | |
| echo "usage: $0 [http://]somehost[:port][/blah/blah]" >&2 | |
| echo " or $0 somehost [port] /blah/blah" >&2 | |
| exit 1 | |
| } | |
| case "$#" in | |
| 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| tokenizer = re.compile(r""" | |
| (?P<string> " (?: [^\\"] | \\. )* " ) | | |
| (?P<number> 0[Xx][0-9A-Fa-f]+ | [0-9]+ ) | | |
| (?P<comment> \# .*? (?= \n | $ ) ) | | |
| (?P<ident> [A-Za-z_] [A-Za-z0-9_]* ) | | |
| (?P<paren> [()] ) | | |
| (?P<brace> [{}] ) | | |
| (?P<bracket> [][] ) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m = b'black magic' | |
| x = b'\x31\xc0\x40\xc3' # payload: xor eax, eax; inc eax; ret (x86) | |
| from ctypes import * | |
| p = string_at(id(m), 64).index(m) | |
| CDLL(None)._FuncPtr(id(x) + p)() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| int main(int argc, char **argv) | |
| { | |
| int n, diff, fromlen, tolen, leftlen; | |
| const char *name, *from, *to, *pos; | |
| char *buf; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This is a way to make a function with named parameters in standard C99. | |
| Most typical programmer errors (parameter typo, etc.) produce at least | |
| somewhat reasonable compiler messages. | |
| Unlike some other methods of doing this, this supports default parameters | |
| which can be defined to any value, and does not require any cumbersome | |
| syntax such as casts or struct accessors when calling the function. | |
| Originally posted on 4chan /prog/. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import wave | |
| FILENAME = 'tmp.wav' | |
| AFMT_S16_NE = 16 | |
| AFMT_S16_LE = 16 | |
| AFMT_U8 = 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # (works on both 2.x and 3.x) | |
| import math | |
| import struct | |
| import sys | |
| import ossaudiodev as oss | |
| SAMPLE_RATE = 48000 |
NewerOlder