Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
"""
"""
from importlib import import_module
from inspect import stack
from inspect import ismethod
@goodwillcoding
goodwillcoding / selfify.html
Created July 18, 2013 06:07
wrapping javascript function calls on an object to pass in object instance as first argument "self"
<html>
<script>
// ......................................................................... //
/*
* Function to wrap every method in the function to have self
*/
function selfify (obj) {
// go over each property in the given object
class ExactRequestParamPredicate(object):
def __init__(self, val, config):
val = _as_sorted_tuple(val)
reqs = []
for p in val:
k = p
v = None
if '=' in p:
k, v = p.split('=', 1)
k, v = k.strip(), v.strip()
class NoRequestParamsPredicate(object):
def __init__(self, val, config):
self.val = bool(val)
def text(self):
return 'no_request_params = %s' % self.val
phash = text
def __call__(self, context, request):
@goodwillcoding
goodwillcoding / compile_patch.diff
Last active January 15, 2019 03:24
Patch to send compile to remote machine if Linux arch does match
diff --git a/nixops/backends/__init__.py b/nixops/backends/__init__.py
index 86ed0f4..c52e9d3 100644
--- a/nixops/backends/__init__.py
+++ b/nixops/backends/__init__.py
@@ -93,6 +93,17 @@ class MachineState(nixops.resources.ResourceState):
except nixops.ssh_util.SSHCommandFailed:
return None
+ def get_os_arch(self):
+ """Get the machine's OS archicture."""
@goodwillcoding
goodwillcoding / default.nix
Created August 25, 2015 00:12
nix custom packages passthru
{ system ? builtins.currentSystem, foo ? "hello" }:
let
pkgs = import <nixpkgs> { inherit system; };
callPackage = pkgs.lib.callPackageWith (pkgs // self // { foo = foo;} );
self = rec {
myPackage = callPackage ./pkgs/my_package {
some_argument = foo;
};
};
class Engine(object):
def __init__(self, size):
self.size = size
def turn_on(self):
print "vrooom"
class BiggerEngine(object):
def __init__(self, size):
Copying src/zope.interface.egg-info to build/bdist.linux-x86_64/wheel/zope.interface-4.1.3-py3.5.egg-info
Installing build/bdist.linux-x86_64/wheel/zope.interface-4.1.3-py3.5-nspkg.pth
running install_scripts
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-ctv9n1fs/zope.interface/setup.py", line 147, in <module>
**extra)
File "/usr/lib64/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.5/distutils/dist.py", line 955, in run_commands
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from rest_toolkit import resource
@resource('/')
class Greeting(object):
def __init__(self, request):
pass
from timeit import Timer
# ........................................................................... #
FORBIDDEN_CHARS = \
('!',
'@',
'#',
'$',
'%',