Skip to content

Instantly share code, notes, and snippets.

View temochka's full-sized avatar
🪒
🐃

Artem Chistyakov temochka

🪒
🐃
View GitHub Profile
#!/usr/bin/env ruby
require 'timeout'
abort "Usage: #{$0} <file> [duration] [rps]" unless ARGV.size >= 1
filename, duration, rps = ARGV
duration = (duration || 5).to_i
rps = (rps || 100).to_i
pause = 1.0 / rps
module OptimizedSolution where
import Control.Monad
import Data.List
import Data.Array
import Data.Char
readToken :: IO String
readToken = do
ch <- getChar
lex ch
@temochka
temochka / keybase.md
Created July 7, 2016 14:18
Keybase.io verification

Keybase proof

I hereby claim:

  • I am temochka on github.
  • I am achistyakov (https://keybase.io/achistyakov) on keybase.
  • I have a public key whose fingerprint is 7847 35BD F6BD FFDC 2132 2837 C8A3 DEB2 CE53 62C6

To claim this, I am signing this object:

(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 / generator.rb
Created December 15, 2015 21:46
Generates a directory with X files with name length A spread by Y directories with name length A with depth Z
require 'securerandom'
require 'fileutils'
NUM_FILES = 35000
NUM_DIRECTORIES = 5000
NAME_LENGTH = 100
MAX_DIR_DEPTH = 10
MAX_FILES_PER_DIR = 100
MAX_DIRS_PER_DIR = 100
@temochka
temochka / cloudfront.json
Last active October 7, 2015 20:29
IAM policy to deploy to S3 subdirectory via Beanstalk/Dploy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1422638998000",
"Effect": "Allow",
"Action": [
"cloudfront:CreateInvalidation",
"cloudfront:GetDistribution"
],
@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 = 'sender@mydomain.com'
m.to = 'tema@wildbit.com'
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