Skip to content

Instantly share code, notes, and snippets.

View dotmh's full-sized avatar

Martin Haynes dotmh

View GitHub Profile
@dotmh
dotmh / design_document.js
Last active August 29, 2015 14:13
design documents issue in pouchdb
function(doc) {
if ( doc.collection === "foobar") {
for(var i = 0; i < doc.belongsTo.length; ++i) {
var belongTo = doc.belongsTo[i];
if ( !!belongTo.length) {
emit(belongTo);
}
}
}
}
@dotmh
dotmh / Loader.php
Created May 25, 2011 16:07
A Name Space Aware PHP Auto Loader
class Loader
{
public function __construct()
{
spl_autoload_register(array($this , 'load'));
}
private function __clone() {}
@dotmh
dotmh / YamlWrapper.rb
Created August 7, 2011 12:40
This is a work in progress of a wrapper for YML files , and an example class using the module
# This builds on the YAML Interface so I need to require it here.
require 'yaml';
# This is my YAML helper it is meant to wrap a YML file and allow you to access
# it has if it was a class, giving you access to the data contained in the hash
# in a OOP way. Still needs a little work especially with the casscade.
module DMH_Yaml_Helper
# This holds the configuration hash file
@hash
# Holds the filename for the config file this is if you need to save later
@filename
@dotmh
dotmh / calander.js
Created August 17, 2011 11:40
A Prototype Calander
/**
* Options
* =======
* Required
* --------
* element : a protoype element / or an DOM Id [Required]
* from : The date to go from can ether be a string or a offest (see below about offests and date string)
* to : The date to go to can ether be string of a offset (see below about offests and date string)
*
* Optional
@dotmh
dotmh / mysql2_db_check.rb
Created August 26, 2011 12:09
Simple Mysql2 gem install checker
require 'mysql2'
client = Mysql2::Client.new(:host => "127.0.0.1", :username => "root" , :password => "root")
results = client.query("show Databases;")
puts "found #{results.count} databases \n"
results.each do | row |
puts row["Database"]
@dotmh
dotmh / placement.jquery.src.js
Created October 12, 2011 15:43
A quick Jquery fallback for form placement
(function($){
$.fn.placement = function() {
var defaults = {};
this.each(function(){
var el = $(this);
var current_id = el.attr('id');
defaults[current_id] = el.val();
@dotmh
dotmh / element.jquery.js
Created November 25, 2011 14:22
A jQuery Element Factory plugin (very simple)
/*
jQuery Simple Element Factory Plugin
====================================
Version 1. By DotMH http://github.com/dotmh
This simply creates a html element , extended in jquery so all jquery's
functionality is there.
@param tag <string> : The tag you want to create , ie div (no < or > )
@param options <object> : an object containing attribute name: value.
@dotmh
dotmh / log.js
Created December 1, 2011 10:04 — forked from penguinbroker/log.js
Paul Irish's logging solution
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console) {
arguments.callee = arguments.callee.caller;
var newarr = [].slice.call(arguments);
(typeof console.log === 'object' ? log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr));
}
@dotmh
dotmh / panes.ion.ui.jquery.src.js
Created December 1, 2011 11:02
A Jquery Pane UI Plugin
(function($){
var IONPANE_ORIENTATIONS_HORZ = 1,
IONPANE_ORIENTATIONS_VERT = 2,
IONPANE_USE_CONTAINER = 'container',
IONPANE_USE_DOCUMENT = 'document';
$.widget('ion.panes' , {
version : '0.0.0',
options : {
orientation : IONPANE_ORIENTATIONS_VERT,
@dotmh
dotmh / server.rb
Created June 6, 2012 09:12
really stupid and simple web server for static content
#!/usr/bin/env ruby
require 'sinatra'
PUBLIC_FOLDER = File.join(File.dirname(__FILE__) , 'site')
set :public_folder , PUBLIC_FOLDER
set :static , true
get '/' do
File.open(File.join(PUBLIC_FOLDER , 'index.html') , 'r').read.to_s