Skip to content

Instantly share code, notes, and snippets.

View pedroaxl's full-sized avatar

Pedro Axelrud pedroaxl

View GitHub Profile
@pedroaxl
pedroaxl / formatters.js.coffee
Last active December 30, 2015 19:09
SirTrevor h1, h2 and h3 formatters. The code isn't 100%, the regular expressions for toHTML methods are a little buggy, but I am working on it.
# Our base formatters
(->
checkElementActive = () ->
selection = window.getSelection()
node = undefined
node = selection.getRangeAt(0).startContainer.parentNode if selection.rangeCount > 0
node and node.nodeName is this.title.toUpperCase()
formatBlockOnClick = () ->
@pedroaxl
pedroaxl / config_controller.rb
Last active February 28, 2016 05:21
Those are my changes to Sir Trevor Editor Uploader, to allow me to upload the files directly to Amazon S3. It's just an experiment, so it's still a little messy, but it's working.
# As we cant make Secret Access Key open, this method generates a signature that will allow the user to upload this
# file specifically
def sign_s3
bucket_name = 'mailee-images'
original_name = params['file_name']
original_extension = original_name.split('.').last
mime_type = params['file_type']
object_name = Time.now.to_f.to_s.gsub('.','') + '.' + original_extension
#TODO return unless mime_type is valid
@pedroaxl
pedroaxl / gist:5131294
Last active December 14, 2015 18:39
robô para ficar acessando o portal do aluno e ver
require 'watir-webdriver'
b = Watir::Browser.new :chrome
busy = true
while busy
puts "sleeping"
sleep 10
puts "accessing page"
b.goto 'http://www.ufrgs.br/ufrgs/aluno'
puts "filling form"
form = b.div(:id => 'login').forms.first
@pedroaxl
pedroaxl / gist:4959584
Created February 15, 2013 10:32
Wal-e Timeout Errors
STRUCTURED: time=2013-02-14T11:17:20.418753-00 pid=2869
wal_e.worker.s3_worker INFO MSG: beginning partition download
DETAIL: The partition being downloaded is part_118.tar.lzo.
HINT: The absolute S3 key is basebackups_005/base_000000040000059500000078_00000032/tar_partitions/part_118.tar.lzo.
STRUCTURED: time=2013-02-14T11:17:23.528361-00 pid=2869
lzop: Invalid argument: <stdin>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent-0.13.8-py2.7-linux-x86_64.egg/gevent/greenlet.py", line 390, in run
result = self._run(*self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/WAL_E-0.6.dev-py2.7.egg/wal_e/worker/s3_worker.py", line 281, in write_and_close_thread

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@pedroaxl
pedroaxl / gist:2653410
Created May 10, 2012 14:29
Links palestra "recapitulando: de métodos ágeis até lean startup"
http://www.extremeprogramming.org/values.html
http://www.planningpoker.com/detail.html
http://en.wikipedia.org/wiki/Test-driven_development
http://en.wikipedia.org/wiki/Refactoring
http://uxdesign.smashingmagazine.com/2011/03/07/lean-ux-getting-out-of-the-deliverables-business/
class SimpleStatusWorker < Resque::JobWithStatus
def perform
60.times do |i|
sleep 1
at(i,60,"At #{num} of #{total}")
end
end
end
# load libraries
require 'rubygems'
require 'wirble'
# start wirble (with color)
Wirble.init
Wirble.colorize