Skip to content

Instantly share code, notes, and snippets.

View rmanalan's full-sized avatar
:octocat:

Rich Manalang rmanalan

:octocat:
View GitHub Profile
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'omniauth'
require 'openid/store/filesystem'
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :open_id, OpenID::Store::Filesystem.new('/tmp')
@rmanalan
rmanalan / sammy.store.js
Created November 21, 2010 04:02
Fix for sammy.store.js
Sammy.Store = function(options) {
var store = this;
this.options = options || {};
this.name = this.options.name || 'store';
this.element = this.options.element || 'body';
//this.$element = $(this.element); // <== *** Don't redefine $element here... do it below...
if ($.isArray(this.options.type)) {
$.each(this.options.type, function(i, type) {
if (Sammy.Store.isAvailable(type)) {
store.type = type;
@rmanalan
rmanalan / sammy.store.js
Created November 21, 2010 03:56
$element is redefined... why?
Sammy.Store = function(options) {
var store = this;
this.options = options || {};
this.name = this.options.name || 'store';
this.element = this.options.element || 'body';
this.$element = $(this.element); // <== *** Why is $element redefined in this plugin? ***
if ($.isArray(this.options.type)) {
$.each(this.options.type, function(i, type) {
@rmanalan
rmanalan / watch_js.rb
Created November 4, 2010 18:24
Watches js/*.js and builds appropriately
#!/usr/bin/env ruby
require 'rubygems'
require 'fssm'
puts "*** Now watching JS files..."
FSSM.monitor(Dir.pwd, ['js/*.js', 'Jimfile']) do
update do |base, relative|
unless relative.include?('bundled.js')
puts "*** #{relative} changed!"
@rmanalan
rmanalan / powertwitter-enhancements.css
Created October 26, 2010 23:40
sets max img size for inlined images and hides the inlined image in the latest tweet area
div.tweet-text a img {
max-width: 430px;
}
div.tweet.latest-tweet div div a img {
display: none;
}
@rmanalan
rmanalan / date.js
Created October 22, 2010 18:23
Nice little date to int sugar
// Here's a nice little shorthand I found recently:
new Date()
// will produce Fri Oct 22 2010 11:19:51 GMT-0700 (PDT), however,
+new Date()
// will produce 1287771628111 which is the number of milliseconds since midnight of January 1, 1970...
// which is equivalent to this:
@rmanalan
rmanalan / jquery.scrollTo.mod-to-support-dyn-offsets.js
Created October 20, 2010 00:15
Replace the both() function with the one below:
function both( val ){
if(typeof val == 'object') {
return val;
} else if(typeof val == 'function') {
var val = val();
return typeof val == 'object' ? val : { top: val, left:val };
} else {
return typeof val == 'object' ? val : { top:val, left:val };
}
};
@rmanalan
rmanalan / $w.js
Created October 5, 2010 23:51
Illustration of a jQuery like object
var $w = function(){
var $w = function(){
return new $w.init;
}
$w.prototype = {
// add all of the methods/props you want accessible as $w().method() or $w().prop here:
init: function(){
console.log('init called');
},
@rmanalan
rmanalan / wc-rest-next.js
Created September 30, 2010 21:53
wc-rest.next.js
/*
* A more dynamic API for WebCenter
* Rich Manalang / @rmanalan
*
* This is an attempt to make a better Javascript wrapper for the WebCenter REST API.
* Goals:
* - Dynamic object creation
* - Callbacks receive proper objects from prior call
* - Concurrent request support
* - Beautiful API
@rmanalan
rmanalan / webcenter-chainable-json-api.js
Created September 30, 2010 16:40
Prototype WebCenter Chainable JSON API
var wc = {};
$.getJSON('http://wc/rest/api/resourceIndex',function(d){
wc = JSON.parse(d);
});
// based on @ded's async method chaining http://www.dustindiaz.com/async-method-queues/
// will initiate an async req to get the current user and lazily populates the currentUser
// object.
> wc.currentUser
[object currentUser]