Skip to content

Instantly share code, notes, and snippets.

View maccman's full-sized avatar
🦜
gpu poor

Alex MacCaw maccman

🦜
gpu poor
View GitHub Profile
@maccman
maccman / why_oh_why.md
Last active December 31, 2015 03:49
Worst recruiting email ever?

Hwody,

"Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteers be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe."

Wihch I thuoghtis was graet nwes as I’ve alwyas been ruisbbh at sepllnig!!

I hvae a nubmer of aewsmoe clinets form Lodnon’s tech satrt ups throguh to laeidng hsouehlod naems that are lokoing for both cotrnact and peramnent deveolpers gonig into 2014. I have icnluedd a breif description of jsut a few of the crurent opoprtunities I am recruiting for and wuold love to hree form you if you are availbale for new cotnarct projects or lokoing to mkae a move into a new premnaent psotiion.

· CTO / Lead developer (ruby on rails) / Financial client / Greenfield project / Permanent paying up to £90k.

$ = jQuery
$.activeTransforms = 0
$(document).ajaxSend (e, xhr, settings) ->
return unless settings.warn
$.activeTransforms += 1
$(document).ajaxComplete (e, xhr, settings) ->
return unless settings.warn
$ = jQuery
$.fn.lineHeight or= ->
if height = @data('lineHeight')
return height
# Create a hidden div with the same font
# properties, then measure its height
$shadow = $('<span />')
$shadow.css({
$ = jQuery
TIMEOUT = 20000
lastTime = (new Date()).getTime()
setInterval ->
currentTime = (new Date()).getTime()
# If timeout was paused (ignoring small
# variations) then trigger the 'wake' event
if currentTime > (lastTime + TIMEOUT + 2000)
@maccman
maccman / counter.sql
Created July 7, 2013 03:11
Postgres counter cache using triggers.
--
-- Name: c_posts_voted(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION c_posts_voted() RETURNS trigger
LANGUAGE plpgsql
AS $$ BEGIN
UPDATE "posts" SET voted_user_ids = array_append(voted_user_ids, NEW.user_id) WHERE "id" = NEW.post_id;
RETURN NEW;
END;
@maccman
maccman / jquery.ajax.queue.coffee
Last active January 13, 2018 12:03
Queueing jQuery Ajax requests. Usage $.ajax({queue: true})
$ = jQuery
queues = {}
running = false
queue = (name) ->
name = 'default' if name is true
queues[name] or= []
next = (name) ->
$ = jQuery
$.support.touch or= ('ontouchstart' of window)
# Helper functions
parentIfText = (node) ->
if 'tagName' of node then node else node.parentNode
swipeDirection = (x1, x2, y1, y2) ->
xDelta = Math.abs(x1 - x2)
@maccman
maccman / jquery.activearea.coffee
Created May 31, 2013 23:58
Active areas in JS web apps.
$ = jQuery
current = null
activeArea = (e) ->
current?.data('active-area', false)
current = $(e.currentTarget)
current.data('active-area', true)
$.fn.isActiveArea = ->
require 'dalli'
require 'memcachier'
module Sprockets
module Cache
# A simple Memcache cache store.
#
# environment.cache = Sprockets::Cache::MemcacheStore.new
#
class MemcacheStore
@maccman
maccman / jquery.onclose.coffee
Last active August 15, 2024 15:14
jQuery plugin to notify users if they close the page, and there are still some Ajax requests pending.
$ = jQuery
TRANSFORM_TYPES = ['PUT', 'POST', 'DELETE']
$.activeTransforms = 0
$(document).ajaxSend (e, xhr, settings) ->
return unless settings.type in TRANSFORM_TYPES
$.activeTransforms += 1