Skip to content

Instantly share code, notes, and snippets.

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 / 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) {
@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 / 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 / python.vim
Created May 2, 2011 23:17
Pretty math symbols for python
" place it in ~/.vim/after/syntax/python.vim
" we need the conceal feature (vim ≥ 7.3)
if !has('conceal')
finish
endif
" remove the keywords. we'll re-add them below
syntax clear pythonOperator
syntax keyword pythonOperator is