Skip to content

Instantly share code, notes, and snippets.

View gr33n7007h's full-sized avatar
🌴
On vacation

Li gr33n7007h

🌴
On vacation
View GitHub Profile
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
#!/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}"
#!/usr/bin/env ruby
require 'net/http'
require 'thread'
class GemCalc
ServiceUri = "https://rubygems.org/api/v1/gems/"
def initialize
#!/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"
Abu Dhabi
Abuja
Accra
Adamstown
Addis Ababa
Algiers
Alofi
Amman
Amsterdam
Andorra la Vella
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'uri'
begin
require 'typhoeus'
rescue LoadError => e
e.message.match(/--\s(.+)/)
#!/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')
@gr33n7007h
gr33n7007h / fiddle_examples.rb
Last active April 30, 2016 03:03
fiddle examples
#!/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)
@gr33n7007h
gr33n7007h / iso.txt
Created March 29, 2016 10:56
iso9660
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.
@gr33n7007h
gr33n7007h / 99bob
Created March 29, 2016 17:54
99bob
#!/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]] }