Skip to content

Instantly share code, notes, and snippets.

@Tatsh
Tatsh / bitly.py
Last active December 14, 2015 10:39 — forked from mmueller/bitly.py
Modified to read `~/.bitly` file. PEP8 conformance.
#!/usr/bin/env python2
#
# Copyright 2009 Empeeric LTD. All Rights Reserved.
#
# Modified 2013 by Andrew Udvare
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@Tatsh
Tatsh / get_perm_string.c
Last active December 15, 2015 13:48
Just messing around
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *get_perm_string(unsigned int perm) {
unsigned int perms_str_size = 17 + 1;
char *perms = malloc(perms_str_size);
unsigned int *flags = malloc(sizeof(int) * 6);
unsigned int shift, offset, i, f, letter, new_size, j;
char *ret;
@Tatsh
Tatsh / random.sh
Last active December 16, 2015 12:58
Weird, ugly Bash stuff
IFS=$'\n'; for i in $(find -iname '*.mp3'); do
fn=$(echo "$i" | cut -b 3- | cut -d '/' -f 1,2 | sed -e 's#/#-#g').zip
dir=$(echo "$i" | cut -b 3- | cut -d '/' -f 1,2)
top=$(echo "$i" | cut -b 3- | cut -d '/' -f 1)
in=$(echo "$i" | cut -b 3- | cut -d '/' -f 2)
pushd "$top"
zip -r "$PWD/../$fn" "$in"
popd
done
@Tatsh
Tatsh / extract-pngs.c
Created April 28, 2013 06:25
PNG extractor in C
/**
* Copyright (c) 2013 Tatsh. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
import glob
import subprocess as sp
from os import remove as rm
DIVX2PASS_GLOB = '*2pass*.log*'
def clean_up():
files = glob.glob(DIVX2PASS_GLOB)
files.extend(['audio.aac', 'output.x264'])
@Tatsh
Tatsh / parse-xchat-logs.py
Created June 16, 2013 23:13
Parses X-Chat 2 and HexChat logs and converts to usable JSON.
#!/usr/bin/env python
import argparse
import datetime
import glob
import json as JSON
import os
import re
import sys
from dateutil import parser as date_parser, tz
@Tatsh
Tatsh / fix-all-linkshare-itunes.php
Created September 29, 2013 00:49
For Drupal 6: Fix all iTunes affiliate links using LinkShare to use the new PHG format in blog posts and a custom content type I have 'song'
#!/usr/bin/env php
<?php
$_SERVER['REMOTE_ADDR'] = '99.293.39.39';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['SERVER_SOFTWARE'] = 'nginx/0';
const HREF_SEARCH = 'click.linksynergy';
$regex = '/href="(https?\:\/\/click\.linksynergy[^"]+)"/';
$add = 'at=10l4D3';
@Tatsh
Tatsh / pushd.py
Created October 24, 2013 05:26
pushd for Python
from os import chdir, getcwd
from os.path import realpath
class PushdContext:
cwd = None
original_dir = None
def __init__(self, dirname):
self.cwd = realpath(dirname)
# extract Unity3D engine *.assets files
# (c) 2012-10-15 by AlphaTwentyThree of XeNTaX
get EXT extension
if EXT == "resS" # no TOC -> scan
cleanexit
endif
endian big
get FSIZE asize

iTunes 11

iTunes/11.1.3 (Macintosh; OS X 10.9) AppleWebKit/537.71