Skip to content

Instantly share code, notes, and snippets.

View gingerbeardman's full-sized avatar

Matt Sephton gingerbeardman

View GitHub Profile
@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 / 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 / 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 / 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
### Keybase proof
I hereby claim:
* I am gingerbeardman on github.
* I am gingerbeardman (https://keybase.io/gingerbeardman) on keybase.
* I have a public key whose fingerprint is 876C A4D0 3068 5B7F 50C1 96DB A399 461C 25D7 0E39
To claim this, I am signing this object:
@gingerbeardman
gingerbeardman / macos-cycle-wireless.sh
Created April 18, 2019 17:49
Cycle Bluetooth & Wi-Fi
DEVICE=$(networksetup -listallhardwareports | grep -A 2 -E "AirPort|Wi-Fi" | grep -m 1 -o -e en[0-9]);
# turn them off...
networksetup -setairportpower $DEVICE Off
./blueutil off
# ...and on again
networksetup -setairportpower $DEVICE On
./blueutil on
<!-- Please do not remove or change this AfD message until the discussion has been closed. -->
{{Article for deletion/dated|page=Electric Brain|timestamp=20190424072107|year=2019|month=April|day=24|substed=yes}}
<!-- Once discussion is closed, please place on talk page: {{Old AfD multi|page=Electric Brain|date=24 April 2019|result='''keep'''}} -->
<!-- End of AfD message, feel free to edit beyond this point -->
{{Infobox magazine
| title = Electric Brain
| logo =
| logo_size = <!-- default is 180px -->
| image_file = Electric_Brain_Issue_34_(May_1993).jpg
| image_alt =