Skip to content

Instantly share code, notes, and snippets.

@ringods
ringods / switch_branch_with_subrepo.py
Created September 23, 2011 14:51
Pre-update hook to remove subrepositories for branch switching to work.
'''Removes .hgsub and any subrepos when switching branches in the parent repository
To activate this hook, add this to your ~/.hgrc file:
[extensions]
switch_branch_with_subrepo =
[hooks]
preupdate.switch_branch_with_subrepo = python:switch_branch_with_subrepo.preupdate
'''
@ringods
ringods / client.py
Created November 25, 2011 10:21
rpyc async request: correct behaviour
import rpyc
import logging
import time
class ClientWrapper:
def __init__(self):
logging.info('client - before connect')
self._connection = rpyc.connect('127.0.0.1',39876)
logging.info('client - after connect')
@ringods
ringods / client.py
Created November 25, 2011 10:24
rpyc async request: faulty behaviour
import rpyc
import logging
import time
class ClientWrapper:
def __init__(self):
logging.info('client - before connect')
self._connection = rpyc.connect('127.0.0.1',39876)
logging.info('client - after connect')
@ringods
ringods / client.py
Created November 28, 2011 09:33
rpyc workaround for async request and callback: sync request on separate thread
from threading import Thread
import rpyc
import logging
import time
class ClientWrapper(Thread):
def __init__(self):
Thread.__init__(self)
logging.info('client - before connect')
@ringods
ringods / SConstruct.py
Created December 20, 2011 13:49
SCons snippet
env['LDFLAGS'] = "$_LIBDIRFLAGS $LINKFLAGS -ggdb3"
env.Execute("echo $LDFLAGS")
t = env.Command('$THIRD_PARTY/lib/libcurl.a',
'%s.tar.bz2' % name,
['mkdir -p $THIRD_PARTY/build',
'cd $THIRD_PARTY/build && tar jxf $THIRD_PARTY/%s' % zip_file,
'cd $THIRD_PARTY/build/%s && CFLAGS="$_CPPINCFLAGS $CCFLAGS $CFLAGS -ggdb3" CXXFLAGS="$_CPPINCFLAGS $CCFLAGS $CXXFLAGS -ggdb3" LDFLAGS="$LDFLAGS" ./configure --prefix=$THIRD_PARTY --without-ssl --with-pic --without-libssh2 --without-librtmp --without-libidn --without-axtls --without-ca-bundle --without-libssh2 --without-zlib --enable-static=yes --disable-shared --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-sspi --disable-tls-srp --enable-ares' % name,
@ringods
ringods / SConstruct.py
Created January 30, 2012 15:53
env.Clone doesn't clone the builders and the emitters
# Configure base_env
base_env = Environment()
#...
# The snippet below enforces having different object instances of the builders
# to workaround the shallow copy of env.Clone()
other_env = base_env.Clone()
del other_env['BUILDERS']['StaticObject']
del other_env['BUILDERS']['SharedObject']
other_env.Tool('gcc')
@ringods
ringods / server.log
Created August 30, 2012 14:40
chef-validator: 401 Unauthorized problem
merb : chef-server (api) : worker (port 4000) ~ Started request handling: Thu Aug 30 16:38:43 +0200 2012
merb : chef-server (api) : worker (port 4000) ~ Routed to: {"admin"=>false, "action"=>"create", "controller"=>"clients", "name"=>"builder"}
merb : chef-server (api) : worker (port 4000) ~ Params: {"admin"=>false, "action"=>"create", "controller"=>"clients", "name"=>"builder"}
merb : chef-server (api) : worker (port 4000) ~ Failed to authenticate. Ensure that your client key is valid. - (Merb::ControllerExceptions::Unauthorized)
/usr/lib/ruby/gems/1.8/gems/chef-server-api-10.12.0/app/controllers/application.rb:56:in `authenticate_every'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.1.3/lib/merb-core/controller/abstract_controller.rb:352:in `send'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.1.3/lib/merb-core/controller/abstract_controller.rb:352:in `_call_filters'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.1.3/lib/merb-core/controller/abstract_controller.rb:344:in `each'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.1.3/lib/me
@ringods
ringods / addvirtualboxaccess.sh
Last active December 12, 2015 01:19
Console snippets for VirtualBox and raw disk setup.
root@host:~# usermod --groups disk -a virtualbox
@ringods
ringods / Vagrantfile
Created September 25, 2013 06:38
Vagrantfile for my Windows 2008R2 with WinRM activated, Puppet installed via MSI and failing the run via vagrant-windows.
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "windows2008r2"
config.vm.guest = :windows
# Max time to wait for the guest to shutdown
@ringods
ringods / libraries_s3_file.rb
Created February 5, 2014 20:27
NameError with s3_file as a full fledged resource/provider loaded from the cookbook's libraries folder
class Chef
class Resource
class S3
class File < Chef::Resource
def initialize(name, run_context=nil)
super
@resource_name = :s3_file
@provider = Chef::Provider::S3::File
@action = :create