Skip to content

Instantly share code, notes, and snippets.

View aziraphale's full-sized avatar

Andrew Gillard aziraphale

View GitHub Profile
@aziraphale
aziraphale / example.html
Created March 10, 2012 11:47 — forked from maxsum-corin/example.html
Short plugin that implements a vertical buttonset for radio buttons, checkboxes and button elements with jQuery UI (this fork also introduces correct plugin behaviour, re: collections/chainability)
<html>
<head>
<title>Test</title>
<link rel="stylesheet" media="all" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/themes/start/jquery-ui.css"></link>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js"></script>
<script src="jquery.myplugin.js"></script>
<script>
$(document).ready(function(){
//call plugin
@aziraphale
aziraphale / bcrypt-php-times.txt
Created September 4, 2012 08:04
Bcrypt in PHP Timings
To get an idea of the ideal number of bcrypt "rounds" to use for highest security without requiring
excessive CPU time, I wrote a little PHP script to hash a 9-character password with every possible
number of rounds (from 4 to 31), timing how long it takes to perform each hash.
This test was performed on an Intel Core i5-2500 CPU @ 3.3 GHz, running Windows 7 64-bit and
PHP 5.4.0 (x86; VC9; CLI). The machine was being used for general development work at the same
time, but the script was only single-threaded and the development work wasn't particularly heavy,
so the times should be fairly accurate.
RESULTS (times in seconds):
@aziraphale
aziraphale / gist:5066105
Created March 1, 2013 17:03
Disable touch events on touchscreen devices when using JoelBesada's ScrollPath plugin (https://github.com/JoelBesada/scrollpath)
// Disable panning around the page on touchscreen devices (as this is totally incompatible with ScrollPath)
$(document).one('touchstart', function(){
$(document).on('touchmove', function(ev){
ev.preventDefault();
});
// Also hide the scrollbar
$('.sp-scroll-bar').hide();
});
@aziraphale
aziraphale / gist:7d71b139ed77a30a75ec
Created October 5, 2014 18:45
Get (canonical) URL bookmarklet
javascript:var u; try { u=document.querySelector("link[rel=canonical]").href; } catch (e) {} if(u){ if(prompt("Canonical URL: - Press OK to navigate", u)) { window.location=u; } else { /* Chrome goes silly if I don't do something here */ u=null; } } else { prompt("No canonical URL found. Displaying current URL:", window.location.href); }
@aziraphale
aziraphale / php-scalar-type-hinting.php
Created May 12, 2015 09:39
Curious hack to allow scalar type hinting in PHP 5.2+
<?php
// Definining these four classes is actually optional; the code functions fine
// without them, but IDEs obviously bitch about undefined classes.
// All have final-private constructors to prevent them ever being instantiated
// (or we could pass *actual objects* of these types to our type-hinted
// functions, where we'd have code that expected a string suddenly finding
// itself dealing with an object!
class string { final private function __construct(){} }
class boolean { final private function __construct(){} }
@aziraphale
aziraphale / windowsFixGlobArgv.php
Last active January 11, 2016 16:14
Windows' cmd.exe doesn't expand filename globs passed to PHP (and others). This function expands glob strings in PHP's $argv array.
<?php
/**
* Fixes PHP's $argv array (or, rather, a list of filenames that is assumed to
* come from $argv) to expand glob strings on Windows, where the cmd.exe shell
* doesn't expand globs before passing arguments to called commands/programs.
*
* @link https://gist.github.com/aziraphale/edf8a1b1ad049f4e08ee
* @param array $argv
* @return array
@aziraphale
aziraphale / gz2bz2.php
Created January 11, 2016 16:13
PHP script to convert .gz-compressed files to .bzip2 utilising the system's existing `gunzip` and `bzip2` commands
<?php
/**
* Fixes PHP's $argv array (or, rather, a list of filenames that is assumed to
* come from $argv) to expand glob strings on Windows, where the cmd.exe shell
* doesn't expand globs before passing arguments to called commands/programs.
*
* @link https://gist.github.com/aziraphale/edf8a1b1ad049f4e08ee
* @param array $argv
* @return array
@aziraphale
aziraphale / header-references.md
Last active April 22, 2016 13:18
123D Circuits Header Component References

Dimensions Notes

(Numbers in {} refer to 2.0mm-pitch - vs. 2.54mm elsewhere)

THT Pads

  • Roundness: 1000 µ
  • Width: 1500 {1200} µ
@aziraphale
aziraphale / email.html
Created May 30, 2016 20:13
magic "Confirm Subscription" link in Google Inbox for Mailchimp subscription confirmation email
<!-- Google Inbox displayed a "Confirm Subscription" link button immediately below the subject line, both when the
email was opened and when it was closed. Clicking the button would confirm the subscription without the browser
visibly opening the confirmation link. -->
<span itemscope itemtype="http://schema.org/EmailMessage">
<span itemprop="description" content="We need to confirm your email address."></span>
<span itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Confirm Subscription">
<span itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<meta itemprop="url" content="https://carloop.us6.list-manage.com/subscribe/smartmail-confirm?u=...&id=...&e=...&inline=true">
@aziraphale
aziraphale / config.txt
Created November 2, 2017 10:09
Smoothieboard BL Touch Configuration
gamma_min_endstop nc # Normally 1.28. Change to nc to prevent conflict,
## Z-Probe (BL Touch)
# See http://forum.smoothieware.org/forum/t-1760423/bltouch-support#post-2712545
# And http://smoothieware.org/zprobe#bltouch-or-servo-retractable-touch-probe
zprobe.enable true # set to true to enable a zprobe
zprobe.probe_pin 1.28 # pin probe is attached to if NC remove the !
zprobe.slow_feedrate 5 # mm/sec probe feed rate
zprobe.fast_feedrate 100 # move feedrate mm/sec
zprobe.probe_height 5 # how much above bed to start probe