Skip to content

Instantly share code, notes, and snippets.

View Porta's full-sized avatar

Julián Porta Porta

View GitHub Profile
@Porta
Porta / alegria.rb
Created June 3, 2014 20:31
Pura alegría.
require "malone"
require "mote"
load('importer.rb')
mailer = Malone.connect(url: "smtp://foo%40localhost:pistola@localhost:1025",domain: "localhost")
data = File.read('mails.csv').encode("UTF-8", invalid: :replace, undef: :replace, replace: "?")
imported_data = Importer.import(data)
irb(main):006:0> '+10'.to_i
=> 10
irb(main):007:0> '10+'.to_i
=> 10
irb(main):008:0>
irb(main):008:0> '-10'.to_i
=> -10
irb(main):009:0> '10-'.to_i
=> 10
class User < Ohm::Model
set :requests, :Request
end
class Request < Ohm::Model
attribute :path
attribute :processed
@Porta
Porta / out.sh
Created February 25, 2014 19:12
$ rake test
....................test/model.rb:73: warning: assigned but unused variable - foo
...................................................
test: find all
line: assert all.detect {|e| e.name == "Ruby Meetup" }
file: test/model.rb +369
line: to_a.each { |e| yield e }
file: /home/porta/Dropbox/Code/ruby/ohm/lib/ohm.rb +163
line: fetch(ids)
file: /home/porta/Dropbox/Code/ruby/ohm/lib/ohm.rb +159
module Ohm
class List
def [](range)
fetch(redis.call("LRANGE", key, range.begin, range.end))
end
end
end
@Porta
Porta / regexp.js
Last active December 28, 2015 02:49
/([^\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0
@Porta
Porta / hola
Created September 25, 2013 10:03
javascript: $('p.mod-messageList-selector-itemCheck').addClass('checked').attr('check', '1'); alert('muchas gracias, vuelva pronto'); return false;
class Bucket < Ohm::Model
attribute :name
attribute :token
list :unread, :Request
end
@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(
{
"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",