Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import logging
import multiprocessing as mp
import os
import okaara
import subprocess
import sys
import signal
import textwrap
@CUXIDUMDUM
CUXIDUMDUM / launcher.py
Created October 30, 2014 20:20
use environment variable in launcher.py of pulp-admin to take password so as to prevent passing password in command line prompt in a batch
"""
Entry point for both the admin and consumer clients. The config file location
is passed in and its contents are used to drive the rest of the client execution.
"""
from gettext import gettext as _
import logging
import logging.handlers
from optparse import OptionParser
import os
@CUXIDUMDUM
CUXIDUMDUM / rbac2
Created September 27, 2014 18:54
rbac2
http://www.ac-web.org/forums/showthread.php?176819-How-to-RBAC
::::GROUPS::::
1 = Player
2 = Moderator
3 = GameMaster
4 = Administrator
::::Permissions::::
1 = Instant logout
@CUXIDUMDUM
CUXIDUMDUM / rbac1
Last active September 6, 2020 12:44
rbac1
-- http://www.ac-web.org/forums/showthread.php?176819-How-to-RBAC
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `rbac_account_groups`
-- ----------------------------
DROP TABLE IF EXISTS `rbac_account_groups`;
CREATE TABLE `rbac_account_groups` (
`accountId` int(10) unsigned NOT NULL COMMENT 'Account id',
#a server test that would run a series of client tests based on args from a config file
#here we create a server test names testserver in ~/server/tests directory
#server test python file
####################################################
cat server/tests/testserver/testserver.py
from autotest.server import autotest_remote, hosts, subcommand, test
@CUXIDUMDUM
CUXIDUMDUM / jenkins ci python
Created May 26, 2014 15:52
jenkins ci python
http://www.youtube.com/watch?v=iGtM_OP01FU
@CUXIDUMDUM
CUXIDUMDUM / decorators
Last active August 29, 2015 13:58
python decorators
def wrap(*args, **kwargs):
print "wrap"
def wrap_this_func(func):
print "wrap_this_func"
def this_func_args(*wargs, **wkwargs):
print "this_func_args"
print "before"
print "after"
return func(*wargs, **wkwargs)
return this_func_args
@CUXIDUMDUM
CUXIDUMDUM / dependency resolution algorithm
Created March 22, 2014 18:39
dependency resolution algorithm
http://www.electricmonk.nl/log/2008/08/07/dependency-resolving-algorithm/
Here's a little explanation of a possible dependency resolution algorithm. I've made this as basic as possible, so it's easy to understand. If you're at home in (graph) algorithms, this post is probably not of much interest to you.
Premise
Suppose we have five objects which all depend on some of the other objects. The objects could be anything, but in this case let's say they're very simple software packages (no minimal versions, etc) that depend on other packages which must be installed first. How does one find the right order of installing the packages?
Take, for instance, the following scenario: Software package 'a' depends on 'b' and 'd'. 'b' depends on 'c' and 'e'. 'c' depends on 'd' and 'e'. 'd' depends on nothing, nor does 'e'. When we visualize this, we get something like this:
@CUXIDUMDUM
CUXIDUMDUM / gist:9491955
Created March 11, 2014 18:27
MCE example
#!/usr/bin/env perl
use strict;
use warnings;
use 5.016;
use Data::Dump qw(dump);
use MCE;
my $mapper = {
1 => sub { say join " ", $$, 1; },
# "Understanding Python's closures".
#
# Tested in Python 3.1.2
#
# General points:
#
# 1. Closured lexical environments are stored
# in the property __closure__ of a function
#
# 2. If a function does not use free variables