Skip to content

Instantly share code, notes, and snippets.

View Porta's full-sized avatar

Julián Porta Porta

View GitHub Profile
@Porta
Porta / application.js
Created March 1, 2012 14:27
Array to Hash
Array.prototype.to_hash = function(id){
id = typeof(id) != 'undefined' ? id : "id";
var self = this;
var out = {};
$.each(this, function(index, element){
out[element[id]] = element;
});
return out;
};
@Porta
Porta / exercise.rb
Created March 8, 2012 21:22
blindcat
class Modifier < Ohm::Model
include Ohm::Typecast
attribute :name, String
attribute :multiplier, Float
end
############################
@Porta
Porta / ErrorLog.pm
Created April 12, 2012 13:27
Perl error logger to remote server.
package ErrorLog;
use vars qw/@ISA @EXPORT $AUTOLOAD/;
our $App = shift || "empty";
use Exporter;
#export methods. can add more, they will be catch'd by AUTOLOAD
@EXPORT = qw /die warn notify/;
@ISA = 'Exporter';
@Porta
Porta / states.rb
Created May 15, 2012 20:44
Concern
module States
extend ActiveSupport::Concern
included do
state_machine :status, :initial => :new do
event :confirm do
transition :new => :confirmed #, :if => lambda {|order| order.email.present?}
end
# >-----------------------------[ Run 'Bundle Install' ]-------------------------------<
say_wizard "Installing gems. This will take a while."
if prefs.has_key? :bundle_path
run "bundle install --without production --path #{prefs[:bundle_path]} --standalone"
else
run 'bundle install --without production --standalone'
end
# >-----------------------------[ Run 'After Bundler' Callbacks ]-------------------------------<
<!DOCTYPE html>
<html>
<head>
<title>La llama que llama</title>
</head>
<body>
<h1>La llama que habla</h1>
<p>
<img title="OLA K ASE" src="http://www.oyemexico.com/wp-content/uploads/2012/12/TUku4-380x285.jpg" alt="Una Llama que habla" />
</p>
<?php
if ( has_post_thumbnail( $post_id ) ) {
// check if to show lightbox desc and title
if ( get_option_max( 'pretty_title_show' ) == 'true' ){
$title = ' title="' . get_the_excerpt() . '"';
}
$cat_list = array();
{
"method": "POST",
"source": null,
"params": {
"id": "1392",
"form_id": "52",
"date_created": "2013-05-29 16:38:53",
"is_starred": "0",
"is_read": "0",
"ip": "190.192.7.129",
@Porta
Porta / antes.rb
Last active December 21, 2015 00:58
class Poxy
class RequestFactory
def initialize(target, rack_request)
@rp = Poxy::RequestProcessor.new(rack_request)
method, headers, query_string, params, body = @rp.parsed
url = fix_url(target, query_string)
headers = fix_headers(headers)
HTTPI.adapter = :curb
@request = HTTPI::Request.new(
class Bucket < Ohm::Model
attribute :name
attribute :token
list :unread, :Request
end