Jared Grippe

JERB- ERB in JavaScript

I needed a more feature rich templating framework in JavaScript. One that was powerful enough to be used server and client side. So I wrote a simple proof of concept of ERB in JavaScript:

http://gist.github.com/253200

I’d love to see this used in a Node.js Anyone?

Ultimately I would like to see more view portions of MVC frameworks dealing with a document as close to the way the browser does.


Comments

Resiglet!

I needed a lightweight erb like templating solution in JavaScript. I googled around and found this post by Jon Resig. A cool idea for sure. I couldn’t seem to find a jQuery plugin that did anything like this so I packaged one up. I even named it after Jon

Resig + Scriptlet == Resiglet.

Check it out http://github.com/deadlyicon/resiglet


Comments

A Better Rename

I was tired of bash’s crapy limited rename so I wrote one in ruby

http://gist.github.com/244768

enjoy.


Comments
More Calendar for your Google Calendar

If you’re like me you rarely use the search feature of google calendar and your a glutton for screen realestate. So why not tuck that once in a while used feature away into a menu item via my new user script


Comments

Element#visible

A way to detect true element visibility using Prototype

http://gist.github.com/237398

this needs some testing and some vetting but i think its a solid technique.


Comments

Javascript like Ruby

After reading Yehuda Katz’s post Metaprogramming in Ruby: It’s All About the Self and I’ve realized you can do some funky javascript like stuff in ruby.

For Example you can define methods that have access to a javascript kind of “private” variable:

http://gist.github.com/236266

You could use this technique to simulate module variables like so:

http://gist.github.com/236430

You can even apply a method onto another object just like Javascript’s Function#apply

http://gist.github.com/236464

The difference being in Ruby you can only bind (and therefore call) a method on an instance of the object it was defined on. For instance if you try and bind Hash#keys onto an array instance you’ll get the `TypeError: bind argument must be an instance of Hash`


Comments

Github gists on tumblr

How I hacked embedding github gists into my tumblr page

http://gist.github.com/234427


Comments

A simpler meta data plugin for jQuery

I needed a simple way to get meta data about an element into a javascript so I started using John Resig’s Metadata plugin for jQuery but found it to be a lot more heavy handed then what I needed. I also wanted the data to be available in jQuery’s standard data hash as apposed to a separate place. So I wrote a simpler meta data plugin.

Example:

<div id="user" data="{username:'loverboy34',age:13,alive:true}">whatever</div>
$(function(){
  console.log('username:', $('#user').data('username'));
  console.dir($.cache[ $.data($('#user').get()[0]) ]);
});

It weighs in at 57 lines and works great. enjoy.


Comments

Function#evalWith

I’ve been exploring ways to avoid having to write with at the top of functions where you want access to methods and attributes without having to write this. or object. all the time and I came up with this:

function evalWith(objects, args, context){
    if (!('length' in objects)) throw new SyntaxError('first argument to evalWith must be an array');
    if (args && !(args instanceof Array)) throw new SyntaxError('second argument to evalWith must be an array');

    var scope = {}; // merge objects into one
    for (var i=0; i < objects.length; i++)
      for (var property in objects[i])
        scope[property] = objects[i][property];
    
    var method = new Function(
      'with(arguments[0]){'+
        'return '+this.toString().replace(/^function (.*?)\(/,'function (')+'.apply(arguments[1],arguments[2]);'+
      '}'
    );
    return method.call(null, scope, context || window, args || []);
  };

more to come…


Comments
11
To Tumblr, Love Metalab