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
View gist:599062
gist command didn't work at all without github.user config
@petervojtek
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}"}
end
attr_reader :name
def initialize name
@petervojtek
petervojtek / devices
Last active Oct 25, 2017
shell script to print list of devices( and ip addresses) connected to ZyXEL P-660HW-T3v2 router
View devices
#!/usr/bin/ruby
# zyxel P-660HW-T3v2 router
# purpose of this script: print list of connected devices (ip + device hostname) to shell
# example: peter@peter-laptop:~/$ ./devices
#
# 10.0.0.34 peter-laptop
# 10.0.0.36 android-d8006
# 10.0.0.38 Notebook
# 10.0.0.40 raspberrypi
@petervojtek
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 = PiPiper::Pin.new(:pin => 4, :direction => :out)
green_led = PiPiper::Pin.new(:pin => 11, :direction => :out)
red_led.off
green_led.off
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.new(__FILE__).flock(File::LOCK_EX | File::LOCK_NB)
puts "Water Drop: There is already an instance running, I quit"
exit 1
end
@petervojtek
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);
}
View pcd8544.rb
# Aim of this script is to use 7-segment PDR8544 display (nokia 3110) from Ruby on Raspberry Pi.
# The script is 1:1 rewrite of this Hello World code for Arduino:
# http://playground.arduino.cc/Code/PCD8544
# Now the issue - the code below is not working properly for some reason.
# What works well is settings the contrast of display, but displaying the text itself ends with following screen content:
# http://postimg.org/image/t2ikdzwhz/
# Any help is appreciated.
View shutdown-raspberry-pi.rb
require 'rubygems'
require 'pi_piper'
include PiPiper
press_times = []
after :pin => 25, :goes => :down do
now = Time.now
press_times.each{|t| puts (now - t) }
View wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
Modem = /dev/ttyUSB0
; Baud = 9600
Init4 = AT+CGDCONT=1,"IP","internet"
Stupid Mode = 1
You can’t perform that action at this time.