Skip to content

Instantly share code, notes, and snippets.

View temochka's full-sized avatar
🪒
🐃

Artem Chistyakov temochka

🪒
🐃
View GitHub Profile
require 'postmark'
client = Postmark::ApiClient.new('API_TOKEN')
puts client.bounces.
first(10).
map { |b| b.values_at(:email, :name, :inactive) }.
unshift(["Email Address", "Bounce Type", "Is inactive?"]).
map(&:to_csv).
join

QueueingRabbit Build Status Code Climate

QueueingRabbit provides a Ruby DSL to interact with RabbitMQ. It is fairly flexible and allows you to integrate with existing infrastructure and naming conventions. It currently offers gems bunny and amqp as supported back-ends.

Example

The following Ruby program publishes an excerpt of Joseph Brodsky’s poem line by line to a RabbitMQ exchange and prints received messages on the screen.

require 'queueing_rabbit'
(defn trie-leaves [& args]
(start-root (map seq args)))
(defn start-root [seqs]
(map
(fn [group]
(if (< 1 (count group))
(start-root (map rest group))
(seq group)))
(vals (group-by first seqs))))
@temochka
temochka / jaccard.clj
Created January 17, 2014 03:35
Jaccard Measure
(defn setify-str [str]
(apply hash-set (seq str)))
(defn jaccard [set1 set2]
(/ (count (clojure.set/intersection set1 set2))
(count (clojure.set/union set1 set2))))
(defn jaccard-str [str1 str2]
(apply jaccard (map setify-str [str1 str2])))
@temochka
temochka / gist:2290387
Created April 3, 2012 08:10
Postmark::HttpClient example
require 'postmark'
require 'mail'
Postmark.api_key = '76bc4c45-5859-4c34-bab7-XXXX'
message = Mail.new do |m|
m.from = '[email protected]'
m.to = '[email protected]'
m.subject = 'Test Message Subject'
m.body = 'Test Message Body'
@temochka
temochka / index.html
Created January 22, 2012 17:47
Continent/Country/City example for Stefan
<!DOCTYPE html>
<html>
<head>
<title>jquery-dependentSelect</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/temochka/jquery-dependentSelect/master/jquery.dependentSelect-0.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('select#single-local-data').dependentSelect({
isMultiple: false,
@temochka
temochka / reply_parser.rb
Created November 23, 2011 17:26
Simple gist for fetching reply without quoted parts and signature from inbound message
module ReplyParser
TEXT_PLAIN_SPLITTER = /^((> )?\/\/ ADD YOUR REPLY ABOVE$)|( *\-\-\-\-\- .+ \-\-\-\-\-)/
class << self
def parse_reply_text(body)
splitter = TEXT_PLAIN_SPLITTER
prepare_reply_text(body.split(splitter).first)
end
private
def self.find_by_email(email)
User.new :email => email
if engine_user = EngineUser.find_by_email(email)
return find_by_engine_user_id(engine_user.id)
end
end
def self.find_by_email!(email)
engine_user = self.find_by_email(email)
raise ActiveRecord::RecordNotFound unless engine_user
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" .vimrc
"
" Artem Chistyakov <[email protected]>
"
" Remember that:
" Reload .vimrc without restarting Vim
" :source %
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
#!/usr/bin/ruby1.9.1
abort "Specify input and output dirs please" if ARGV.length != 2
in_dir, out_dir = ARGV
Dir.chdir in_dir
Dir.foreach(in_dir) do |file|
in_file = File.join(in_dir, file)
`ufraw-batch --wb=camera --exposure=auto --out-type=jpeg #{in_file} --out-path=#{out_dir}`