Skip to content

Instantly share code, notes, and snippets.

View barnumbirr's full-sized avatar

Martin Simon barnumbirr

View GitHub Profile
@ryancdotorg
ryancdotorg / frag32.py
Created August 20, 2015 16:27
A FAT32 fragmenter, because I am a horrible person.
#!/usr/bin/env python
import random
import struct
import sys
# Most of the Fat32 class was cribbed from https://gist.github.com/jonte/4577833
def ppNum(num):
return "%s (%s)" % (hex(num), num)
@varemenos
varemenos / 1.README.md
Last active April 21, 2024 23:21
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@johnbintz
johnbintz / simple-capistrano-docker-deploy.rb
Last active April 3, 2023 08:23
Simple Capistrano deploy for a Docker-managed app
# be sure to comment out the require 'capistrano/deploy' line in your Capfile!
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'my-cool-application'
# the base docker repo reference
set :name, "johns-stuff/#{fetch(:application)}"
@Ajnasz
Ajnasz / noemoji.pl
Created October 14, 2014 11:53
# Replace annoying emojis. You can see them on slack, for example.
# noemoji.pl
#
# Replace annoying emojis. You can see them on slack, for example.
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '1.0';
@barnumbirr
barnumbirr / viedemerde.py
Last active August 29, 2015 14:00
Parse viedemerde.fr for a random quote.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import urllib
__title__ = 'viedemerde'
__version__ = '0.1'
__author__ = 'Martin Simon <me@martinsimon.me>'
__license__ = 'Apache v2.0 License'
@maliubiao
maliubiao / ezip.py
Created February 6, 2014 16:05
ezip.py, handle encoded filename in a zip file.
import zipfile
import sys
import os.path
import errno
def files_in_zip(this_zip, encoding):
return [x.decode(encoding) for x in zipfile.ZipFile(this_zip).namelist()]
def extract_all_encoding(this_zip, path_prefix, encoding):
z = zipfile.ZipFile(this_zip)
@ksafranski
ksafranski / expecting.md
Last active November 11, 2023 23:00
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@audreyfeldroy
audreyfeldroy / pypi-release-checklist.md
Last active February 23, 2023 15:03
My PyPI Release Checklist
  • Update HISTORY.md
  • Commit the changes:
git add HISTORY.md
git commit -m "Changelog for upcoming release 0.1.1."
  • Update version number (can also be minor or major)
bumpversion patch
@Svenito
Svenito / houchangelog.py
Created April 18, 2013 10:14
Script gets the changes between two build versions of Houdini from the journal and outputs them in a more traditional changelog format. Be sensible with how much data you want to get! Requires the Beautiful soup and requests libraries
#!/usr/bin/env python2.7
from BeautifulSoup import BeautifulSoup
from textwrap import TextWrapper
import requests
import collections
import sys
import re
@mutsuda
mutsuda / mine_time.py
Last active December 15, 2015 15:38
This piece of code will keep track of a user's Minecraft gameplay minutes. Each time it is runed it writes into a log file the difference between the latest minutes with the actual minutes to obtain the total number of minutes played since the last execution.
import re
import os.path
import datetime
import os
import time
# Path to the minecraft statistics file
mine_path = "FULL_PATH_TO_/stats_user_unsent.dat"