Skip to content

Instantly share code, notes, and snippets.

View rmanalan's full-sized avatar
:octocat:

Rich Manalang rmanalan

:octocat:
View GitHub Profile
@ryanbriones
ryanbriones / gist:240942
Created November 23, 2009 07:03
first pass at what my sinatra-like java servlet would look like
import org.sinatraLikeServlet.*;
public class MyApplication extends SinatraLikeHTTPServlet {
@get("/")
public void index(SinatraLikeHTTPServletRequest req
SinatraLikeHTTPServletResponse resp) {
MyResource[] resources = MyResource.findAll();
req.setAttribute("resources", resources);
}
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@rjungemann
rjungemann / 1. restful_service.rb
Created June 2, 2010 01:51 — forked from headius/1. restful_service.rb
Sinatra-like example in JRuby with Jersey
require 'java'
java_import 'javax.ws.rs.Path'
java_import 'javax.ws.rs.GET'
java_import 'javax.ws.rs.Produces'
java_package 'com.headius.demo.jersey'
java_annotation 'Path("/helloworld")'
class HelloWorld
java_annotation 'GET'
java_annotation 'Produces("text/plain")'
// ----------------------------------------------------------
// 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) {}
@rmanalan
rmanalan / packager.js
Created September 27, 2010 18:39
Psuedo code for a JS/CSS packager for static HTML apps
//manifest.js: defines the grouping of js/css
var $packager.assets = {
'app.js': [
{ name:'jquery.js', wait:true },
{ name:'sfasdf.js', wait:true },
{ name:'fasdt.js', wait:true }
],
'app.css': [
'blueprint.css',
'style.css'
@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]
@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 / $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');
},
window.addEventListener "DOMContentLoaded", ->
body = $ "body"
canvas = $ "#canvas"
chalkboard = $ "#chalkboard"
close = $ "#close"
ledge = $ "#ledge"
lightswitch = $ "#lightswitch"
output = $ "#output"
shade = $ "#shade"
share = $ "#share"

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables