Skip to content

Instantly share code, notes, and snippets.

Peter Vojtek petervojtek

Block or report user

Report or block petervojtek

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
petervojtek / HC-SR04.ino
Created Feb 13, 2014
HC-SR04 with power on and off to save power. Not working properly due to unknown reason. discussion here:
View HC-SR04.ino
const int trigPin = 6;
const int echoPin = 7;
const int powerPin = 5;
const int ledPin = 13;
void setup() {
pinMode(powerPin, OUTPUT);
pinMode(trigPin, OUTPUT);
petervojtek / obce.rb
Last active Aug 29, 2015
zhlukovanie obci SR podla podobnosti nazvu (jedno pismenko sa moze lisit v ramci danej skupiny)
View obce.rb
# encoding: utf-8
villages_full_names ='obce.txt').split "\n"
#villages = ["Ďurkovce", "Hrkovce", "Markovce", "Mirkovce", "Širkovce", "Hokovce"]
villages = villages_full_names.collect{|v| v.sub(/ \/ .+/, '')} # Abrahámovce / okres Bardejov -> Abrahámovce
similar_villages = {}
View wma-to-mp3.rb
Dir.chdir ARGV[0]
wmas = Dir.glob("*.wma")
wmas.each do |wma|
wma = File.basename wma
mp3 = "#{wma.gsub(/[[:space:]]/,'').downcase[0..-4]}mp3"
puts "processing #{wma} to #{mp3}"
`avconv -i \"#{wma}\" -acodec libmp3lame -ab 128k #{mp3}`
`rm *.wma`
petervojtek / zrsr.rb
Created Apr 28, 2015
Zivnostnensky register z Ruby (
View zrsr.rb
# kod nizsie vyhlada zivnostnikov ktori maju ako obec uvedene Malinovo
require 'uri'
require 'net/http'
uri = URI('')
res = Net::HTTP.get_response(uri)
require 'nokogiri'
doc = Nokogiri::HTML.parse res.body
View gist:599062
gist command didn't work at all without github.user config
petervojtek / gist:4316754
Created Dec 17, 2012
Ruby Garbage Collector not garbage collecting as expected
View gist:4316754
# Ruby MRI 1.9.2 p136
class Person
def self.destructor name
proc{ puts "I AM DYING: #{name}"}
attr_reader :name
def initialize name
petervojtek / mocp_rpi.rb
Created Jun 14, 2013
BerryClip Raspberry Pi + Music on Console (mocp)
View mocp_rpi.rb
require 'pi_piper'
include PiPiper
`su pi -c \"mocp -S\"`
red_led = => 4, :direction => :out)
green_led = => 11, :direction => :out)
after :pin => 7, :goes => :high do
View stepper_motor.rb
require 'rubygems'
require 'pi_piper'
include PiPiper
motor_sequence = [
[true, false,false,false],
[true, true, false,false],
[false,true, false,false],
[false,true, true, false],
[false,false,true, false],
View water_drop.rb
# sudo crontab -e
# 0 * * * * ruby /home/pi/Repositories/water_drop/src/water_drop.rb
puts "Water Drop: started"
unless | File::LOCK_NB)
puts "Water Drop: There is already an instance running, I quit"
exit 1
petervojtek / air_pump.ino
Last active Dec 21, 2015
arduino air pump aquarium
View air_pump.ino
int motorSpeedPin = 11;
int motorOnPin = 10;
void setup()
pinMode(motorOnPin, OUTPUT);
pinMode(motorSpeedPin, OUTPUT);
digitalWrite(motorOnPin, 1);
You can’t perform that action at this time.