Skip to content

Instantly share code, notes, and snippets.

🎯
Elixir/OTP

Jakub Godawa vysogot

🎯
Elixir/OTP
Block or report user

Report or block vysogot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vysogot
vysogot / podcast_generator.rb
Created Sep 16, 2017
Generates RSS file from the files in a folder with subfolders
View podcast_generator.rb
#!/usr/bin/env ruby -wKU
#
# based on a script
# by Kelan Champagne
# http://kelan.io
require 'date'
# Config values
podcast_title = "Title"
@vysogot
vysogot / youtube-transcript-to-srt.rb
Created Mar 16, 2017
YouTube Transcript to SRT - Ruby script
View youtube-transcript-to-srt.rb
# Paste your transcript between the quotes
# and run
# ruby youtube-transcript-to-srt.rb > subtitles.srt
transcript = "0:00 Hello and welcome
0:05 This is a very nice story
0:10 and it needs subtitles"
times = transcript.split("\n").map {|x| x[0..4].strip.rjust(5, '0')}
times << times[-1]
@vysogot
vysogot / MultipleOutputTimeline.ino
Last active Aug 29, 2015
Arduino – multiple output control with timeline
View MultipleOutputTimeline.ino
/* Algorithm based on delay for running different outputs in given LOW/HIGH intervals
This code is meant to control the relay grid behind a washing machine
and it can be used for many other devices. By Jakub Godawa (vysogot) */
/* addresses for Arduino Uno (!setup properly for Arduino Mega or other!) */
const int r1out = A0;
const int r2out = A1;
const int s3out = A2;
const int s4out = A3;
const int s5out = A4;
@vysogot
vysogot / people_matcher.rb
Created Jul 16, 2011
Using FilterMatcher example
View people_matcher.rb
class PeopleMatcher
include FilterMatcher
attr_reader :db
def initialize(db, input)
@db, @input = db, input
end
def match
@vysogot
vysogot / filter_matcher.rb
Created Jul 16, 2011
FilterMatcher module
View filter_matcher.rb
module FilterMatcher
#
# define filter in a class that uses this module
# named like:
# - name_filter
# - age_filter
#
# they should a filtered array
#
@vysogot
vysogot / filter_matcher_test.rb
Created Jul 16, 2011
FilterMatcher test suite
View filter_matcher_test.rb
require 'test/unit'
class PeopleMatcherTest < Test::Unit::TestCase
def setup
@db = [
{ :id => 1, :name => "John", :age => 33, :homepage => "www.johny.com", :matched => false },
{ :id => 2, :name => "Mike", :age => 30, :homepage => "www.mikes.com", :matched => false },
{ :id => 3, :name => "Johny", :age => 25, :homepage => "www.johny.com", :matched => false },
{ :id => 4, :name => "Mike", :age => 30, :homepage => "www.realmike.com", :matched => false },
{ :id => 5, :name => "Dan", :age => 25, :homepage => "www.danny.com", :matched => false },
View fast_cartesian_product.rb
def cartprod(*args)
result = [[]]
while [] != args
t, result = result, []
b, *args = args
t.each do |a|
b.each do |n|
result << a + [n]
end
end
@vysogot
vysogot / fast_permute_sets.rb
Created Jul 7, 2011
Fast, fully iterative permute sets
View fast_permute_sets.rb
def permute(*args)
# filter the arguments
args.reject! {|x| !x.is_a?(Array) || x.empty?}
# get the number of all combinations
total = args.inject(1) {|total, array| total * array.size}
# prepare the small_cycles array to know how many times
# one element should be repeated in a loop
View example_user_story_test.rb
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
include Test::Unit::UserStory
story "Create the thing", %{
As a user
I want to create something
In order to show something
} do
criteria "without js when logged in" do
@vysogot
vysogot / test_user_story.rb
Created Jul 5, 2011
user stories for test unit
View test_user_story.rb
module Test::Unit::UserStory
class UserStoryTestCase < ActionController::IntegrationTest
class << self
attr_accessor :description
alias :it :test
def criteria(name, options = {}, &block)
klass = create_class(name, self, &block)
helper_klass = options[:js] ? CapybaraJavascriptTestHelper : CapybaraTestHelper
You can’t perform that action at this time.