Skip to content

Instantly share code, notes, and snippets.

@andrusha
andrusha / fez_decypher.rb
Created May 24, 2014 10:19
Fez game language decypherer
$alphabet =
{
11 => ?i,
12 => ?c,
13 => ?u,
14 => ?o,
21 => ?t,
22 => ?n,
23 => ?h,
@andrusha
andrusha / windows_xp.sh
Created May 31, 2011 16:06
Windows XP QEMU virtual machine startup script with KVM, VDE networking & Samba
#!/bin/sh
TAP_INTERFACE="tap0"
IMAGE_DIR="/media/files/virtual"
ARGS="-enable-kvm -drive file=$IMAGE_DIR/winxp.img,index=0,cache=writeback,media=disk -boot c -net nic,vlan=0,macaddr=52:54:00:00:EE:02,model=rtl8139 -net vde,vlan=0 -m 1024 -localtime -usbdevice tablet -vga std -smb qemu -cpu Nehalem"
if [ "$(lsmod | grep kvm | wc -l)" -eq 0 ]
then
echo "Loading KVM modules..."
sudo modprobe kvm
sudo modprobe kvm-intel
@andrusha
andrusha / inhex.py
Created June 30, 2011 03:49
inheritance example
In [1]: class Ellipse(object):
...: def setSize(self, x, y):
...: pass
...:
...:
In [2]: class Circle(Ellipse):
...: def setSize(self, x):
...: pass
...:
@andrusha
andrusha / inh_ex.php
Created June 30, 2011 04:40
Inheritance example for habrahabr
<?php
class A {
public function setSize($x, $y) {
print('A');
}
}
class B extends A {
public function setSize($x) {
class User < ActiveRecord:Base
ROLE_TYPES = %W[Company Developer]
validates_presence_of :email, :allow_blank => false, :allow_nil => false
validates_uniqueness_of :email
validates_email_format_of :email
attr_accessible :email
end
@andrusha
andrusha / gist:3969506
Created October 28, 2012 19:10
Word document readers benchmark results
❯ /usr/bin/time -l antiword ~/Projects/universiteam/spec/support/files/lorem.complex.doc
0.02 real 0.00 user 0.00 sys
688128 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
157 page reclaims
32 page faults
0 swaps
7 block input operations
@andrusha
andrusha / test_file.rb
Created December 16, 2012 10:54
A support library to abstract usage of files in tests
# As a separate module, because we might want to
# mock some files in the future or use generator
# for the same reason it returns opened instance of file
#
# Each method check if corresponding file exists in
# spec/support/files/file.name.kitten.ext
# if method has `_path` in the end Pathname instance would be returned
# otherwise it will be File instance
module TestFiles
def self.respond_to?(method)
@andrusha
andrusha / gist:4625608
Created January 24, 2013 17:42
God supervisor example config for node.js app
#!/usr/bin/env ruby
God.watch do |w|
w.group = "hubot_group"
w.name = "hubot"
w.interval = 1.seconds
w.env = { 'NODE_ENV' => 'production'}
w.start = "node ..."
w.start_grace = 5.seconds
w.restart_grace = 5.seconds
@andrusha
andrusha / iso_to_usb.sh
Last active October 9, 2016 22:34
Create bootable USB from ISO image on Mac
hdiutil convert -format UDRW -o destination_file.img source_file.iso
# Or re-partition it with Disk Utility with 1 Free Space Partition
diskutil partitionDisk /dev/disk2 1 "Free Space" "unused" "100%"
# Or copy the image through Disk Utility in Restore menu
dd if=destination_file.img.dmg of=/dev/disk2 bs=1m
# Or eject manually
diskutil eject /dev/disk2
@andrusha
andrusha / config.txt
Created August 23, 2013 14:32
Raspberry PI config for PAL RC output with overscan
avoid_safe_mode=1
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border