My Recent Pastes (28 and counting)

Pastes by Sulien (28 and counting)

Pages:

Below are the 15 most recent pasties by Sulien.

August 23, 2007
2:42PM EDT
by Sulien

// Use prototype 1.6 and Content-type: application/json when sending JSON

{foo: 'value1', bar: 'value2'}

var data = response.responseJSON

August 23, 2007
2:37PM EDT
by Sulien

var TravelPlan = Class.create();

TravelPlan.prototype =
{
  initialize: function(name)

August 20, 2007
12:49PM EDT
by Sulien

Animal = Class.create({
  initialize: function() {
!!    this.breeds = [];
  }
});

August 19, 2007
6:35PM EDT
by Sulien

def self.find(value, field = 'id', all = false)
  method = all ? :select : :find
  @@attributes.send(method) {|item| item[field] == value }
end

August 19, 2007
3:28PM EDT
by Sulien

#!/usr/bin/ruby
#
# Upload a patch to Rails trac from command-line. Example:
#
#    firefox `svn di | ticket 1234 patch-name.diff`

July 24, 2007
9:50PM EDT
by Sulien

## Haml and Sass magic generators [plaintext]

Have you ever thought how it sucks that Rails generators make ".html.erb" and ".css" files
in your Haml-powered project? Have you ever caught yourself processing each and every of
these files with `html2haml` and `css2sass`, or -- even worse -- by hand later?

July 24, 2007
6:57PM EDT
by Sulien

## user has a blog, which in turn has posts
ActionController::Routing::Routes.draw do |map|

  # :singular is a life-saver here
  map.resources :users do |user|

July 22, 2007
5:44PM EDT
by Sulien

<?php
/** My awesome file resize class
 * 
 * Usage:
 *

July 22, 2007
4:17PM EDT
by Sulien

Index: test/haml/html2haml_test.rb
===================================================================
--- test/haml/html2haml_test.rb (revision 0)
+++ test/haml/html2haml_test.rb (revision 0)
@@ -0,0 +1,60 @@

July 22, 2007
9:37AM EDT
by Sulien

<?php
function imageTypeToExtension($imagetype, $include_dot = false){
  if(!$imagetype) return null;
  $dot = $include_dot ? '.' : '';
  switch($imagetype){

July 21, 2007
8:20PM EDT
by Sulien

## Experimenting with vim pastie.

This is way cool. Tim Pope rules!

June 23, 2007
2:13PM EDT
by Sulien

Event.observe('link13751', 'click', function(event){
  if (confirm('¿Está seguro?')) {
    var element = Event.findElement(event,'TR');
    new Ajax.Updater('message', '/web/itescam/admin/technical_articles/delete/86',
      { asynchronous:true, evalScripts:true,

June 23, 2007
9:42AM EDT
by Sulien

## better table generation, powered by Prototype trunk
var tbl = new Element("table", { id: "tblExpenses" });
var tblBody = document.createElement("tbody");
var headerRow = document.createElement("tr");
tblBody.appendChild(headerRow);

May 28, 2007
8:18PM EDT
by Sulien

## find "morons" in Rails core who use the for..in syntax

# you can run it (while in framework root dir) like this:
# wget http://pastie.caboo.se/65456.txt -O- | ruby -
# (takes a couple of minutes to finish)

March 06, 2007
7:52AM EDT
by Sulien

## poll template, renders both form and results
<form class="poll" method="post" action="<%= $link('poll/vote') %>">
  <h2>Anketa</h2>
  <p>
    <%= escape(poll['title']) %>

Next page