Skip to content

Instantly share code, notes, and snippets.

View gingerbeardman's full-sized avatar

Matt Sephton gingerbeardman

View GitHub Profile
@gingerbeardman
gingerbeardman / image_replacer.js
Created March 19, 2012 17:00
Apple.com retina-iPad image replacer JS code de-obfuscated
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@gingerbeardman
gingerbeardman / tweet-translate-json.js
Created August 6, 2014 11:16
JavaScript to show translation of current tweet
var language = window.navigator.userLanguage || window.navigator.language;
language = language.substring(0, 2);
var url = document.location.href;
var tweet = url.split("/")[5];
var translation = "https://twitter.com/i/translations/show.json?dest=" + language + "&id=" + tweet;
document.location.href = translation;
<?php
echo "<pre>";
$subject = "This is a test {pause}3{/pause} for embedded tags. {shake}1.5{/shake} Tada! {wait}keySpace{/wait}\n";
$pattern = "#{([\w]+)}(.*?){/\\1}\s#";
preg_match_all($pattern, $subject, $matches);
$split = preg_split($pattern, $subject);
print_r($subject);
@gingerbeardman
gingerbeardman / circle-to-circle-collision.phaser.js
Last active June 8, 2016 22:17
Circle-to-Circle collision test using Phaser JS framework
circleToCircle: function(obj1, obj2) {
return game.physics.arcade.distanceBetween(obj1, obj2) < (obj1.body.width/2 + obj2.body.width/2);
}
#!/bin/bash
DATE=`date +%Y%m%d%H%M%S`
defaults write "/Users/matt/Projects/Wire Hang/Info.plist" CFBundleVersion -string "$DATE"
cp "Info.plist" "Wire Hang Redux.app/Contents/"
cp "icons/Wire Hang Redux.icns" "Wire Hang Redux.app/Contents/Resources/"
touch "Wire Hang Redux.app"
xattr -cr "Wire Hang Redux.app"
codesign -f -s "3rd Party Mac Developer Application: Matt Sephton (A1B234CD5E)" "Wire Hang Redux.app"
productbuild --component "Wire Hang Redux.app" /Applications --sign "3rd Party Mac Developer Installer: Matt Sephton (A1B234CD5E)" "Wire Hang Redux.pkg"
spctl -a -v --type install "Wire Hang Redux.pkg"
@gingerbeardman
gingerbeardman / css-generate.php
Last active December 8, 2021 13:02
Generates CSS for custom fonts on the Sony Reader PRS series, normalising the size of fonts using the inverse of the Asc+Desc metric
#!/usr/bin/env php
<?php
// requirements: python, pip
// dependencies: font-line
// installation:
// sudo -H python -m ensurepip
// sudo -H pip install font-line
@gingerbeardman
gingerbeardman / macOS-Preview-Crop-PDF.md
Created January 1, 2018 12:04
Cropping the whole of a multi-page PDF using Preview on macOS X
  1. Open multi-page PDF
  2. Select all pages (Cmd+A with focus in thumbnail sidebar)
  3. Tools > Rectangular Selection
  4. On single page drag to select area to crop
  5. Tools > Crop (or Cmd+K)

All pages are cropped identically!

@gingerbeardman
gingerbeardman / scansnap-creator.md
Last active April 30, 2018 15:01
How to make Fujitsu's ScanSnap software recognise a PDF that you haven't scanned
  1. Instal ExifTool: brew install exiftool
  2. Replace the Creator metadata: exiftool -Creator="ScanSnap Manager #S1300i" *.pdf
@gingerbeardman
gingerbeardman / file.io.sh
Last active April 25, 2024 05:49 — forked from devster/file.io.sh
Simple cli tool to use file.io https://www.file.io/#one Install: curl https://gist.githubusercontent.com/gingerbeardman/a7737e4c89fccab8605f8538ddaeec0d/raw/a78f5253b0fcdbd7b893f91627a29498690356ea/file.io.sh | sudo tee /usr/local/bin/file.io && sudo chmod +x /usr/local/bin/file.io
#!/bin/sh
URL="https://file.io"
DEFAULT_EXPIRE="14d" # Default to 14 days
if [ $# -eq 0 ]; then
echo "Usage: file.io FILE [DURATION]\n"
echo "Example: file.io path/to/my/file 1w\n"
exit 1
fi
@gingerbeardman
gingerbeardman / 0x0.sh
Last active October 28, 2022 00:37
Simple cli tool to use https://0x0.st for ephemeral file uploads. Install: curl https://gist.githubusercontent.com/gingerbeardman/5398a5feee9fa1e157b827d245678ae3/raw/9ea5c714b41bdef77a8984bc91ff5d248c48d048/0x0.sh | sudo tee /usr/local/bin/0x0.sh && sudo chmod +x /usr/local/bin/0x0.sh
#!/bin/sh
URL="https://0x0.st"
if [ $# -eq 0 ]; then
echo "Usage: 0x0.st FILE\n"
exit 1
fi
FILE=$1