Skip to content

Instantly share code, notes, and snippets.

obkfjhifkbhimlocpddgamonjihinpak

Keybase proof

I hereby claim:

  • I am mironov on github.
  • I am mironov (https://keybase.io/mironov) on keybase.
  • I have a public key ASBsVT8HY90eEjGcqm8e8fMxCLHyN9Pk5zT9PhkD_BldJQo

To claim this, I am signing this object:

@mironov
mironov / trello-to-kanbanery.rb
Created May 15, 2013 19:03
Import tasks from trello to kanbanery
require "json"
require "csv"
json = File.read("qa.json")
parsed_json = JSON.parse(json)
lists = {}
parsed_json["lists"].each do |list|
lists[list["id"]] = list["name"]
end
@mironov
mironov / ruby-dbi.rb
Created March 13, 2013 13:14
ruby-dbi fix for 1.9.3
module DBI
class Row
#
# See Object#clone.
#
# #clone here, however, is a deep copy via Marshal.
#
def clone
Marshal.load(Marshal.dump(self))
end
module Rack
class Request
def scheme
if @env['HTTPS'] == 'on'
'https'
elsif @env['HTTP_X_FORWARDED_SSL'] == 'on'
'https'
elsif @env['HTTP_X_FORWARDED_PROTO']
@env['HTTP_X_FORWARDED_PROTO'].split(',')[0]
else
<message type='chat' id='purple3475c67' to='jaconda@jaconda.im'>
<active xmlns='http://jabber.org/protocol/chatstates'/>
<body>link text &lt;http://google.com?a=1&amp;amp;b=2&gt;</body>
<html xmlns='http://jabber.org/protocol/xhtml-im'>
<body xmlns='http://www.w3.org/1999/xhtml'><p><a href='http://google.com?a=1&amp;amp;b=2'>link text</a></p></body>
</html>
</message>
<message type='chat' id='purple3475c67' to='jaconda@jaconda.im'>
<active xmlns='http://jabber.org/protocol/chatstates'/>
<body>link text &lt;http://google.com?a=1&amp;amp;b=2&gt;</body>
<html xmlns='http://jabber.org/protocol/xhtml-im'>
<body xmlns='http://www.w3.org/1999/xhtml'><p><a href='http://google.com?a=1&amp;b=2'>link text</a></p></body>
</html>
</message>
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'json'
class Connection
attr_accessor :socket, :user_id
def initialize(socket, user_id)
@socket = socket
class User < ActiveRecord::Base
# gradual engagement is needed, to allow admin creation of users
# users should create authorization data only when they need to
# access some system feature that requires authentication
# So ... our gradual engagement scheme for authlogic:
# 1. admin creates user, setting only name and phone number (required)
# admin may set email address (optional)
# 2. user is sent email invitation with link to activate their account
# admin can re-send email at user's request
# 3. user sets login and password/password_confirmation using activation form
span_trans = lambda do |el|
if el[:node].name == "span"
if el[:node].has_attribute?("style")
rules = el[:node].attribute("style").value.split(";")
new_rules = rules.map do |rule|
rule.match(/text-decoration:\s*(underline|overline|line-through)\b/) ||
rule.match(/font-weight:\s*bold\b/) ||
rule.match(/font-style:\s*italic\b/)
end
new_style = new_rules.compact.map{|r| r.to_s}.join("; ")