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 copy | |
import math | |
def box(remaining, capacity): | |
if len(remaining) >= capacity: | |
weights = [b.item_weight for b in remaining[:capacity]] | |
return sum(weights) |
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 Master(SingleWindow): | |
defaults = [ | |
("border_focus", "#ff0000", "Border colour for the focused window."), | |
("border_normal", "#000000", "Border colour for un-focused winows."), | |
("border_width", 2, "Border width."), | |
("name", "xmonad-tall", "Name of this layout."), | |
] | |
_min_ratio = .1 | |
_max_ratio = .9 |
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 sys | |
from select import select | |
import socket | |
import readline | |
# HACK - python doesn't include a binding to rl_callback_read_char | |
import readline | |
import ctypes | |
rl_lib = ctypes.cdll.LoadLibrary("libreadline.so") |
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
#!/usr/bin/env python | |
""" | |
Shlaxfile for shlax itself. | |
""" | |
from shlax.shortcuts import * | |
env = dict( | |
DJANGO_SETTINGS_MODULE='ylserver.settings', | |
UWSGI_MODULE='ylserver.wsgi:application', |
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
aoeu |
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
--- | |
- hosts: all | |
become: true | |
become_method: sudo | |
become_user: root | |
handlers: | |
- name: Restart | |
notify: Restart dnsmasq |
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
14/02 2019 04:39:23 jpic@jpic ~/src/ansible-compose (master) | |
$ ansible-compose jpic@ci.yourlabs.io/home/jpic/bar stop | |
Running ssh jpic@ci.yourlabs.io bash -euxc 'cd /home/jpic/bar; docker-compose stop' | |
+ cd /home/jpic/bar | |
+ docker-compose stop |
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
29/09 2018 06:13:36 jpic@jpic ~/src/playlabs/playlabs/inventory_template (master) | |
$ playlabs | |
Playlabs: the obscene ansible distribution. | |
Init your ssh user with your key and secure sshd and passwordless sudo: | |
playlabs init root@1.2.3.4 | |
# all options are ansible options are proxied | |
playlabs init @somehost --ask-become-pass |
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
""" | |
Currently with django we can only import an attribute from a module, not a sub-attribute. For example | |
import_string('foo.models.YourModel') # works | |
import_string('foo.models.YourModel.objects.update_stats') # doesn't | |
This snippet fixes that, originally for django-call which has tests. |
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
from importlib import import_module | |
import pickle | |
from uuid import uuid4 | |
try: | |
from uwsgi import SPOOL_OK | |
except ImportError: | |
SPOOL_OK = True | |
try: |
NewerOlder