Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / bom.py
Last active November 18, 2021 15:55
Parsing of bom files in pure python
# Python routines for parsing bom files
#
# Examples so far:
#
# dump_bom(filename) - prints diagnostic structure information about bom file (including path list)
from ctypes import BigEndianStructure, c_char, c_uint8, c_uint16, c_uint32, sizeof, memmove, addressof
class BOMHeader(BigEndianStructure):
_pack_ = 1
@pudquick
pudquick / parse_pbzx.py
Last active September 27, 2021 04:34
Pure python reimplementation of .cpio.xz content extraction from pbzx file payload for OS X packages
# Pure python reimplementation of .cpio.xz content extraction from pbzx file payload originally here:
# http://www.tonymacx86.com/general-help/135458-pbzx-stream-parser.html
#
# Cleaned up C version (as the basis for my code) here, thanks to Pepijn Bruienne / @bruienne
# https://gist.github.com/bruienne/029494bbcfb358098b41
# Example usage:
# parse_pbzx('PayloadJava', 'PayloadJava.cpio.xz')
# Updated for speeeeeeeeeeeeed
@Cr4sh
Cr4sh / gist:fe910f0d1b0559efd43d
Created September 3, 2014 19:55
Dynamically finding sys_call_table on Linux x86_64 systems
void **find_sys_call_table(void *kernel_addr, int kernel_size)
{
/*
Check for the system_call_fastpath() signature, hand-written piece of
assembly code from arch/x86/kernel/entry_64.S:
ja badsys
mov rcx, r10
call sys_call_table[rax * 8]
mov [rsp + 20h], rax
#include "mach_gettime.h"
#include <mach/mach_time.h>
#define MT_NANO (+1.0E-9)
#define MT_GIGA UINT64_C(1000000000)
// TODO create a list of timers,
static double mt_timebase = 0.0;
static uint64_t mt_timestart = 0;
@sneves
sneves / ct32.c
Last active December 28, 2021 19:43
/*
Constant-time integer comparisons
Written in 2014 by Samuel Neves <sneves@dei.uc.pt>
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with
anonymous
anonymous / apns-conf.xml
Created December 15, 2012 01:20
A listing of APNs to be used as the apns-conf.xml file in Android. Hoping to make as complete and accurate of a list as possible.
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2006, Google Inc.
**
** 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
**
** http://www.apache.org/licenses/LICENSE-2.0
@silverkors
silverkors / fileman.py
Created November 27, 2012 20:40
Useful filemanager for Pythonista, move files, delete and create files and directories
# -*- coding: utf-8 -*-
import os, sys, editor, shutil
from glob import glob
from scene import *
from time import time
from copy import deepcopy
from PIL import Image, ImageDraw, ImageFont
# https://gists.github.com/4034526
@rreeger
rreeger / gist:3388024
Created August 18, 2012 16:08
RSS Resources for Slogger

#RSS Feed Resource for Brett Terpstra's Slogger

I hacked this together from numerous places as a resource for those using Slogger (graciously offered by Brett Terpstra).

I have tried to use ALL_CAPS in the feeds to note those areas that will require your specific info.

Feel free to share the list and make additions. And please let me know if there is anything here that needs correcting.

##App.net

  • Feed
@enaeseth
enaeseth / yaml_ordered_dict.py
Created February 25, 2011 19:54
Load YAML mappings as ordered dictionaries
import yaml
import yaml.constructor
try:
# included in standard lib from Python 2.7
from collections import OrderedDict
except ImportError:
# try importing the backported drop-in replacement
# it's available on PyPI
from ordereddict import OrderedDict
@BenWard
BenWard / pinboard-full.js
Created January 29, 2011 07:47
A smarter bookmarklet for Pinboard.in; wraps selected text in <blockquote> tags, keeps variables out of the global scope, supports filling tags from rel="tag" markup in the page, and titles from hAtom entry titles.
(function() {
// Change `silent` to true to invoke the promptless, self-closing
// version of the bookmarklet.
var silent = false;
var url = location.href;
var title = document.title;
// Look for a single hAtom entry on the page, and iff one is found, extract
// the entry-title in place of the document title: