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
import functools | |
class CallableCache(object): | |
def __init__(self, cache=None): | |
self._cache = cache or {} | |
def __call__(self, fn): | |
def w(*args, **kwargs): | |
try: | |
key = hash((fn, args, tuple(kwargs.items()))) |
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 ssh { | |
package { ssh: ensure => installed } | |
file { sshd_config: | |
name => $operatingsystem ? { | |
Darwin => "/etc/sshd_config", | |
Solaris => "/opt/csw/etc/ssh/sshd_config", | |
default => "/etc/ssh/sshd_config" | |
}, | |
source => "puppet://server.domain.com/files/ssh/sshd_config" | |
} |
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
# HOWTO run a virtual machine in ubuntu 9.04 under KVM | |
k@ururu ~ % sudo aptitude install kvm virt-manager | |
k@ururu ~ % sudo modprobe kvm | |
# Now go to Applications -> System Tools -> Virtual Machine Manager | |
# Wasn't that easy? |
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
k@ururu ~ % wget "http://www.google.com/" | |
--2009-05-04 17:56:52-- http://www.google.com/ | |
Resolving www.google.com... 64.233.163.147, 64.233.163.99, 64.233.163.103, ... | |
Connecting to www.google.com|64.233.163.147|:80... connected. | |
HTTP request sent, awaiting response... No data received. | |
Retrying. | |
--2009-05-04 17:57:01-- (try: 2) http://www.google.com/ | |
Connecting to www.google.com|64.233.163.147|:80... connected. | |
HTTP request sent, awaiting response... No data received. |
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
>>> import pynotify | |
>>> pynotify.init(u"My Application") | |
True | |
>>> pynotify.Notification(u"Hello", u"World").show() | |
True |
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
>>> bla = (i for i in 'hello!') | |
>>> for x in bla: | |
... print x | |
... _ = next(bla) | |
... | |
h | |
l | |
o | |
>>> |
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 A(object): | |
... @classmethod | |
... def magic(cls, fn): | |
... def _f(*args, **kwargs): | |
... print "Hello from", cls, "_f", args, kwargs | |
... return fn(*args, **kwargs) | |
... return _f | |
... | |
>>> class B(object): | |
... @A.magic |
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
def utc_datetime_from_twitter_timestamp(s): | |
"""Parses as datetime.datetime in UTC a string formated Twitter timestamp""" | |
# we must parse the date in an english locale (due to %a and %b) | |
prev_loc = locale.getlocale() | |
try: | |
locale.setlocale(locale.LC_ALL, 'C') | |
return datetime.datetime.strptime(s, '%a %b %d %H:%M:%S +0000 %Y') | |
finally: | |
locale.setlocale(locale.LC_ALL, prev_loc) |
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
# cat /etc/puppet/puppet.conf | |
[main] | |
logdir=/var/log/puppet | |
vardir=/var/lib/puppet | |
ssldir=/var/lib/puppet/ssl | |
rundir=/var/run/puppet | |
factpath=$vardir/lib/facter | |
pluginsync=true | |
[puppetmasterd] |
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
(03:36:05 AM) vark: | |
You there? I have a question about *programming* that I think you might be able to answer. | |
(Type 'sure', 'pass', or 'busy'.) | |
(03:37:27 AM) k: sure | |
(03:37:28 AM) vark: (From Semyon S./25/M/St.Petersburg,Russia) | |
What is better git or svn? | |
(Type 'pass' to skip, 'flag' if this question is inappropriate, or 'more' for options.) | |
(03:39:55 AM) k: Semyon: Git is definitely better. Subversion proposal for version control is deprecated. I've written myself an article about some differences between Git and Subversion here: http://kspg.com.ar/blog/posts/8/ |