This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Demo | |
def self.a_class_method | |
puts "Running a class method, self is: #{self.inspect}" | |
end | |
def an_instance_method | |
puts "Running an instance method, self is: #{self.inspect}" | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'socket' | |
def random_hostnames | |
loop do | |
begin | |
octets = Array.new(4) { rand(255) } | |
hostname = Socket.gethostbyaddr(octets.pack('C4')).first | |
puts "IP: #{octets.join('.')} -> Hostname: #{hostname}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'thread' | |
class GemCalc | |
ServiceUri = "https://rubygems.org/api/v1/gems/" | |
def initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# man ioctl_list | grep KDSETLED | |
KDSETLED = 0x00004B32 | |
begin | |
# needs root privs | |
loop{ open('/dev/console').ioctl(KDSETLED, rand(0..8)) } | |
rescue Errno::EACCES | |
STDERR.puts "needs root privs to run" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Abu Dhabi | |
Abuja | |
Accra | |
Adamstown | |
Addis Ababa | |
Algiers | |
Alofi | |
Amman | |
Amsterdam | |
Andorra la Vella |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'ostruct' | |
require 'uri' | |
begin | |
require 'typhoeus' | |
rescue LoadError => e | |
e.message.match(/--\s(.+)/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env lua | |
local socket = require('socket') | |
local s = assert(socket.tcp()) | |
s:connect('www.google.co.uk', 80) | |
s:send('GET /robots.txt HTTP/1.1\r\n\r\n') | |
while true do | |
local line = s:receive('*l') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fiddle' | |
require 'fiddle/import' | |
include Fiddle | |
@libc = "/usr/lib64/libc.so.6" # location of shared object file on Arch Linux | |
TC = TrueClass.dup | |
FC = FalseClass.dup | |
PR_SET_NAME = 15 # set process name (from /usr/include/linux/prctl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Creating a multiboot USB-Stick | |
============================== | |
Short notes on how to create a multiboot capable USB-Stick with efi/bios support, | |
a Windows usable data partiton and a System Rescue CD boot entry. | |
Creating the partition table | |
------------------------------ | |
Use gdisk to create a new empty gpt table with protective mbr. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
v = %|%d bottle%s of beer on the wall, %d bottle%s of beer\ntake one down, pass it around, %d bottle%s of beer on the wall.\n\n| | |
s = -> (i) { i != 1 ? ?s : '' } | |
99.step(1, -1).each { |i| puts v % [i, s[i], i, s[i], i-1, s[i-1]] } |
OlderNewer