Skip to content

Instantly share code, notes, and snippets.

View listenrightmeow's full-sized avatar
🦍

Mike Dyer listenrightmeow

🦍
View GitHub Profile
@listenrightmeow
listenrightmeow / lodr.js
Last active August 29, 2015 14:25
Fidel Examples
window.Lodr = fidel.define('lodr', {
defaults : {
backgroundString : 'url(\'__\')',
callback : [],
height : window.innerHeight || document.documentElement.clientHeight,
srcsetTimeout : 60,
retina : !!window.hasOwnProperty('devicePixelRatio') && window.devicePixelRatio >= 2,
responsive : {
small : 480,
medium : 768,
@listenrightmeow
listenrightmeow / mofile.rb
Last active August 29, 2015 14:01
Remove dups with MD5 hashing
require 'digest/md5'
h = {}
Dir.glob("**/*", File::FNM_DOTMATCH).each do |f|
next if File.directory?(f)
k = Digest::MD5.hexdigest(IO.read(f)).to_sym
if h.has_key? k
h[k].push f
@listenrightmeow
listenrightmeow / leaflet.js
Created April 3, 2013 22:44
Production leaflet.js example
var Leaflet = Fidel.declare({
defaults : {
imperial : 1609.344,
locations : [],
map : null,
markers : [],
options : {},
pin : {
size : {
w : 48,
@listenrightmeow
listenrightmeow / ssllogo.php
Created March 26, 2013 18:40
Crop and letterbox PHP GD image
<?php
$url = $_REQUEST['image'];
$max_width = 500;
$max_height = 500;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
@listenrightmeow
listenrightmeow / week.php
Created February 26, 2013 23:31
Build array of dates from defined date object
$cols = array();
$date = new DateTime(date('Y-m-d', strtotime('-1 week')));
for ($i = 0; $i < 7; $i++) {
$cols[$date->format('l')] = array(
'label' => $date->format('Y-m-d')
);
$date->modify('+1 day');
x = setInterval(function(){
--w >= 0 ? console.log([w / 86400, (w / 3600) % 24, (w / 60) % 60, w % 60].map(function(n){
return n < 10 ? '0' + ~~n : ~~n
}).join(':')) : clearInterval(x);
}, [1e3, w = 10][0]);
@listenrightmeow
listenrightmeow / assets.rake
Last active February 14, 2017 06:21
Rails 3 asset pipeline deploy task with s3 and cloudfront support
namespace :assets do
desc 'Precompile assets and upload to S3'
task :sync => :environment do
assets = build_asset_dir
raise 'asset directory is empty: aborting' unless assets.size > 1
invalid_files = build_assets assets
delete_old_assets assets
invalidate_files invalid_files unless invalid_files.empty?
Kohana::modules(array(
// 'auth' => MODPATH.'auth', // Basic authentication
// 'cache' => MODPATH.'cache', // Caching with multiple backends
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
// 'database' => MODPATH.'database', // Database access
// 'image' => MODPATH.'image', // Image manipulation
// 'orm' => MODPATH.'orm', // Object Relationship Mapping
// 'unittest' => MODPATH.'unittest', // Unit testing
// 'userguide' => MODPATH.'userguide', // User guide and API documentation
'ui' => MODPATH.'ui', // Load custom UI module
<?php defined('SYSPATH') or die('No direct access allowed.');
/*
* Author : Mike Dyer
* @Anchor.php
*
* @params :
* uri : anchor location
* title : anchor text
* attrs : valid anchor attributes
*
@listenrightmeow
listenrightmeow / remove.js
Created April 20, 2012 01:28
Extend JS natives
Array.prototype.remove = function(member) {
var index = this.indexOf(member);
index > -1 && this.splice(index, 1);
}
return this;
}
['one', 'two', 'three'].remove('two');
['four', 'five', 'six'].remove('three');