Skip to content

Instantly share code, notes, and snippets.

View craigrodway's full-sized avatar

Craig A Rodway craigrodway

View GitHub Profile
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}

(a gist based on the old toolmantim article on setting up remote repos)

To collaborate in a distributed development process you’ll need to push code to remotely accessible repositories.

This is somewhat of a follow-up to the previous article setting up a new rails app with git.

For the impatient

Set up the new bare repo on the server:

@zerowidth
zerowidth / paginated_collection.js
Created November 18, 2010 22:04
first whack at pagination with backbone.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
@jchris
jchris / index.html
Created April 27, 2011 16:54
jQuery CouchDB Hello World - to use this script, create the map view in futon and click Save As, then upload index.html as an attachment to _design document created with the view. browse to index.html to run the app.
<!DOCTYPE html>
<html>
<head><title>Tiny CouchApp</title></head>
<body>
<h1>Tiny CouchApp</h1>
<form id="new_message">
<label for="message">Message:</label>
<input type="text" name="message" value="">
<p><input type="submit" value="Save &rarr;"></p>
</form>
@max-mapper
max-mapper / using-couch-with-node.txt
Created July 15, 2011 00:14
using couchdb with node.js
There are three essential components for most flexibly interacting with CouchDB from node:
couch API documentation:
http://jpmens.net/2010/04/20/the-antepenultimate-couchdb-reference-card/
http://www.couchbase.org/sites/default/files/uploads/all/documentation/couchbase-api.pdf
javascript HTTP library:
http://github.com/mikeal/request
javascript _changes feed consuming libaries (pick one):
// an immediate function
(function(){
// code goes here
})();
// a module with a public API returned
var MyModule = (function(){
// this variable is private
var privateVariable = "I'm scoped to the module's internals!";
@neilj
neilj / gist:1532562
Created December 29, 2011 07:22
Sugared DOM: Better Than Templates
var el = ( function () {
var doc = document;
var directProperties = {
'class': 'className',
className: 'className',
defaultValue: 'defaultValue',
'for': 'htmlFor',
html: 'innerHTML',
@sandfox
sandfox / Cat.php
Created May 16, 2012 15:31
Simple Model - Mapper abstract pair for PHP
<?php
namespace Sandfox\Model;
use \Sandfox\Model\ModelAbstract;
class Cat extends ModelAbstract
{
/**
* Define data names and defaults here
@somatonic
somatonic / form-example.php
Last active September 14, 2021 01:46
PW simple form via API
<?php
$out = '';
// create a new form field (also field wrapper)
$form = $modules->get("InputfieldForm");
$form->action = "./";
$form->method = "post";
$form->attr("id+name",'subscribe-form');
@somatonic
somatonic / upload_images_to_page_form.php
Created November 26, 2012 22:08
Upload Images to new created Page Form Example
<?php
// front-end form example with multiple images upload
// add new page created on the fly and adding images
$message = '';
if($input->post->submit){
// tmp upload folder for additional security