Skip to content

Instantly share code, notes, and snippets.

@vfig
vfig / skies.py
Created February 6, 2019 17:17
Sunless Skies qualities/events parser (rough and ready)
# Use Unity Asset Extractor to save the qualities and events assets to "qualities.dat" and "events.dat" respectively.
# Then run this script to explore the data.
#
# Needs Python 3.6
import struct, textwrap
# For indenting a string:
def indent(s):
return '\n'.join((' ' + l) for l in str(s).splitlines())
@vfig
vfig / Graphviz.sublime-build
Created April 11, 2017 09:49
Graphviz build script for Sublime Text 3 on OS X.
{
"cmd": ["dot", "-Tpng", "-o", "${file_name}.png", "$file"],
"file_regex": "^Error: (.+?):",
"line_regex": "line ([0-9]+)",
"selector": "source.dot",
"variants": [
{
"name": "Dot",
"shell_cmd": "dot -Tpng -o '${file_name}.png' '$file' && open -a Preview '${file_name}.png'"
},
@vfig
vfig / filter_through_command.py
Created February 27, 2017 11:51 — forked from trigeorgis/filter_through_command.py
Sublime Text 3: "Filter Through Command" plugin
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## based on https://gist.github.com/1910413 updated for Sublime Text 3
import sublime
import sublime_plugin
import subprocess
class PromptRunExternalCommand(sublime_plugin.WindowCommand):
@vfig
vfig / iosdev.markdown
Last active November 11, 2015 09:56
iOS dev command line operations that I find useful but have trouble remembering

Provisioning profiles

Find UUIDs of provisioning profiles in current directory:

find . -name '*.mobileprovision' -print0 | xargs -0 -t -n 1 security cms -D -i | grep -A1 UUID 2>&1

Convert .mobileprovision to .plist

security cms -D -i foo.mobileprovision -o foo.plist

Extract signing certificate from provisioning profile plist

# Copyright (c) 2015 Andrew Durdin
#
# 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:
#
# The above copyright notice and this permission notice shall be included in
@vfig
vfig / osx_apache2_ssl.md
Last active August 29, 2015 14:21 — forked from jonathantneal/README.md
Local SSL websites on Mac OS X Yosemite

Local SSL websites on Mac OSX

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on Mac OSX Yosemite.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward edit to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@vfig
vfig / find_codesign_profiles.py
Last active August 29, 2015 14:13
Display a list of provisioning profiles with at least one valid code-signing identity.
#!/usr/bin/python2.7
## Display a list of provisioning profiles with at least one valid code-signing identity.
##
## Displays the UUID and app identifier for each such provisioning profile, followed by the
## fingerprint and name of the matching code-signing identities.
import glob, os, plistlib, re, subprocess
PROVISIONING_PROFILES_DIR = os.path.expanduser('~/Library/MobileDevice/Provisioning Profiles')
OPENSSL = '/usr/bin/openssl'
@vfig
vfig / gist:41f25867fc7af6555110
Created July 7, 2014 09:47
Calculate the line height of a CGFontRef
CGFloat CGFontGetLineHeight(CGFontRef font, CGFloat fontSize)
{
if (!font) return 0.0f;
int lineHeightGlyphUnits = CGFontGetAscent(font) - CGFontGetDescent(font) + CGFontGetLeading(font);
CGFloat lineHeightEms = (CGFloat)lineHeightGlyphUnits / CGFontGetUnitsPerEm(font);
return lineHeightEms * fontSize;
}
@vfig
vfig / self-documenting-js.html
Created March 19, 2013 13:13
An experiment with js that adds its source to the page when it runs.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script>
"use strict";
function showme() {
var scripts = document.getElementsByTagName('script'),
ln = scripts.length,
script = scripts[ln - 1],