Skip to content

Instantly share code, notes, and snippets.

View tamewhale's full-sized avatar

Gavin Logan tamewhale

View GitHub Profile
@tamewhale
tamewhale / flush.bookmarklet.js
Last active December 13, 2015 22:29
A bookmarklet for flushing pages in Silverstripe.
javascript:(function(){var l=window.location,q="?flush=1";l+="";if(-1!==l.indexOf("?")){q="&flush=1";if(-1!==l.indexOf("flush=1")){q="";}}window.location+=q;})();
@tamewhale
tamewhale / git-files-changed
Last active December 12, 2015 03:29
Get a list of unique file names that have been changed in the last 2 days' commits in Git.
git log --pretty=format: --name-only --since="2 days ago" | sort | uniq
@tamewhale
tamewhale / style.css
Created May 4, 2012 11:36
Bicubic scaling for images in IE
img { -ms-interpolation-mode: bicubic; }
@tamewhale
tamewhale / working_days.php
Created January 11, 2012 10:36
Calculate date X working days from now
<?php
// accepts a DateTime object which is now by default
// and returns a DateTime object x working days from now
// where x defaults to 1
function get_next_working_day($date = new DateTime, $no_of_days = 1) {
// add the number of days passed but skip weekends
for ($i = 0; $i < $no_of_days; $i++) {
do {
@tamewhale
tamewhale / test.html
Created November 30, 2011 16:03
Changing the data attribute of an object
<div id="scrollee" style="height:75%;" >
<object id="object" height="90%" width="100%" type="text/html" data="http://en.wikipedia.org/"></object>
</div>
<a id="change-link" href="http://yahoo.com">link</a>
<script type="text/javascript">
window.onload = function() {
var el = document.getElementById("change-link");
el.onclick = function() {
var target = this.getAttribute("href");
var el = document.getElementById("object");
@tamewhale
tamewhale / about.md
Created August 10, 2011 13:07 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@tamewhale
tamewhale / Bcrypt.php
Created August 9, 2011 15:29
Simple PHP 5.3+ Bcrypt class and functions
<?php
/*
By Marco Arment <me@marco.org>.
This code is released in the public domain.
THERE IS ABSOLUTELY NO WARRANTY.
Usage example:
// In a registration or password-change form:
@tamewhale
tamewhale / daft.php
Created February 11, 2011 14:23 — forked from StuartFeldt/daft.php
Harder, Better, Faster, Stronger
<?php
//
// So that servers can understand Daft Punk's song 'Harder, Better, Faster, Stronger',
// that is, if the server in question has PHP installed..
//
for($k=0; $k<16; $k++)
{
for($j=0; $j<4; $j++)
@tamewhale
tamewhale / word-count.js
Created September 15, 2010 20:07
A word count and limit for tinyMCE
// this assumes an existing html tag containing the upper limit
// of the word count, with an id of #word-count- + the id of the tinymce instance
// e.g. <p>Words left: <span id="word-count-textarea-1">200</span></p>
// add as a parameter to the tinyMCE.init({}); function
setup: function(ed) {
var text = '';
var span = document.getElementById('word-count-' + ed.id);
if(span) {
var wordlimit = span.innerHTML;