A ZSH theme optimized for people who use:
- Solarized
- Git
- Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)
Black: 0, 0, 0 | |
Red: 229, 34, 34 | |
Green: 166, 227, 45 | |
Yellow: 252, 149, 30 | |
Blue: 196, 141, 255 | |
Magenta: 250, 37, 115 | |
Cyan: 103, 217, 240 | |
White: 242, 242, 242 |
my_dict = { foo: 1, bar: 'baz' } | |
my_clone = my_dict.dup #=> making a shallow copy | |
my_clone.object_id == my_dict.object_id #=> false, these are different objects | |
my_clone == my_dict #=> true, they contain the same values | |
my_clone[:qux] = 'wibble' #=> adding a pair to the clone | |
my_clone.has_key? :qux #=> true, the key was added | |
my_dict.has_key? :qux #=> false, the key was never added to this object, neither was its value |
class ServerThing | |
def initialize session | |
@session = session # primary parameters | |
end | |
def for type, session | |
self.class.const_get("#{type.to_s.capitalize}Class").new_with self, ServerThing::Session.new(session) | |
end | |
class SuperClassForObjects |
if defined?(Rubinius) then | |
require_relative 'rbx_caller_binding' | |
else | |
require_relative 'mri_caller_binding' | |
end | |
# starting daemon | |
$ gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg | |
gnome-keyring-daemon: insufficient process capabilities, unsecure memory might get used | |
** Message: couldn't access conrol socket: /home/xybre/.cache/keyring-My42JI/control: No such file or directory | |
$ git fetch | |
WARNING: gnome-keyring:: couldn't connect to: /home/xybre/.cache/keyring-My42JI/pkcs11: No such file or directory | |
$ touch /home/xybre/.cache/keyring-My42JI/control | |
touch: cannot touch `/home/xybre/.cache/keyring-My42JI/control': No such file or directory |
It can be challenging to use Ruby for handling raw binary data, involving a lot of Array#pack
and String#unpack
with the possibility of String#ord
and Numeric#chr
for good measure. Some of these tools might make the job a bit easier, allowing your to define schemas of the binary data and how to parse it, or even just allowing your to specify the format in a more verbose way.
module Stuff | |
def an_instance_method | |
puts "Stuff's instance method!" | |
end | |
def self.an_eigenclass_method | |
puts "Stuff's eigenclass method!" | |
end | |
module_function |
# If DKMS isn't installed then VBox will erroneously complain about missing headers. | |
sudo apt-get install build-essential dkms libglib2.0-0 linux-headers-$(uname -r) | |
# Only needed if the system doesn't automount the image: | |
#sudo mount /dev/cdrom /media/cdrom | |
# Some systems automount on `/media`, others on `/media/cdrom*` which is symlinked to `/media/cdrom`. | |
# Don't `cd` into these directories until you're sure the image is mounted. | |
cd /media ; cd cdrom | |
# Need root privs in order to place and activate kernel modules. | |
sudo sh VBoxLinuxAdditions.run |
module Enumerable | |
# operates like Enumerable#map, but returns a hash | |
def hmap | |
inject Hash.new do |new_hash, (k,v)| | |
new_k, new_v = yield k, v | |
new_hash[new_k] = new_v | |
new_hash | |
end | |
end | |
end |