Skip to content

Instantly share code, notes, and snippets.

View alexdunae's full-sized avatar

Alex Dunae alexdunae

View GitHub Profile
@alexdunae
alexdunae / smushit.sh
Created October 15, 2009 16:45
Image optimization with a home-rolled Smush.it
#!/bin/bash
#
# Home-rolled Smush.it, by Alex Dunae (http://dialect.ca).
#
# N.B. This script works for me; it may not work for you.
# Since it overwrites your images with the optimized version, you should
# backup your files before running this script and do a trial run before
# getting too excited. This is your disclaimer.
#
# Uses jpegtran (http://jpegclub.org/jpegtran/), part of libjpeg,
# /waiters/tables_calling.json
# in the controller
#
# you want an array of table IDs as the output
def tables_calling
calling = []
@tables.where(calling: true).each do |table|
calling << table.id
end
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# from https://github.com/drKreso/guerrilla_patch
class Allocate
attr_accessor :amount
attr_accessor :ratios
def self.evenly(amount, number_of_slices)
Allocate.new.tap do |a|
a.amount = amount
a.ratios = (1..number_of_slices).map { 1.to_d/number_of_slices }
end.divided
Warning: get_browser(): browscap ini directive not set in /home/www/typothequen/new.typotheque.com/wf/web_fonts.php on line 81
Warning: get_browser(): browscap ini directive not set in /home/www/typothequen/new.typotheque.com/wf/web_fonts.php on line 16
Warning: get_browser(): browscap ini directive not set in /home/www/typothequen/new.typotheque.com/wf/web_fonts.php on line 32
Warning: get_browser(): browscap ini directive not set in /home/www/typothequen/new.typotheque.com/wf/web_fonts.php on line 48
Warning: get_browser(): browscap ini directive not set in /home/www/typothequen/new.typotheque.com/includes/classes/webfonts/web_fonts.class.php on line 441
@alexdunae
alexdunae / name_case.php
Created January 24, 2012 17:49
NameCaseConverter
<?php
/**
* Properly capitalize a name.
*
* @package NameCase
* @version 1.0.2
* @author Alex Dunae, Dialect <alex[at]dialect[dot]ca>
* @copyright Copyright (c) 2008, Alex Dunae
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @link http://dialect.ca/code/name-case/
@alexdunae
alexdunae / media_tests.rb
Created September 30, 2011 19:07
Parse embed video URL snippet
test 'getting embed data for youtube urls' do
result = {:youtube => 'dQw4w9WgXcQ'}
['http://youtu.be/dQw4w9WgXcQ',
'http://www.youtube.com/embed/dQw4w9WgXcQ',
'http://www.youtube.com/watch?v=dQw4w9WgXcQ',
'https://www.YOUTUBE.com/?v=dQw4w9WgXcQ',
'http://www.youtube.com/v/dQw4w9WgXcQ',
'http://www.youtube.com/e/dQw4w9WgXcQ',
'http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ',
'http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/dQw4w9WgXcQ',
@alexdunae
alexdunae / simplelogin-secure-sample.php
Created December 1, 2010 19:22
Sample code for Simplelogin-Secure
<?php
// load the library
$this->load->library('SimpleLoginSecure');
// create a new user
$this->simpleloginsecure->create('user@example.com', 'uS$rpass!');
// attempt to login
if($this->simpleloginsecure->login('user@example.com', 'uS$rpass!')) {
// success
cw = ChatWindow.new(user, other_user)
cw.avatar
cw.lasst_update
cw.messages.each do |m|
render m
end
cw.last_updated