Skip to content

Instantly share code, notes, and snippets.

View waynew's full-sized avatar
💭
Making the world a little Saltier - one grain at a time

Wayne Werner waynew

💭
Making the world a little Saltier - one grain at a time
View GitHub Profile
from __future__ import print_function
switch = {"case 1": lambda: print("Hey, case 1"),
42: lambda: print("The answer to life, the universe, and everything"),
"spam": lambda: print("A favourite metasyntactic variable of Pythonistas everywhere"),
"fnord": lambda: print("You can't see the fnords."),
}
val = "spam"
switch[val]()
@waynew
waynew / gist:51fe623397c90096a36f
Created May 6, 2014 03:13
Simplest clock ever
<?doctype html>
<html>
<body>
<meta name="viewport" content="width=100%">
<div id="clock" style="font-size: 18vw;" width="100%"></div>
</body>
<script>
function padTwo(n){
return ("00"+n).slice(-2);
The minion function caused an exception: Traceback (most recent call last):
File "salt/minion.py", line 797, in _thread_return
File "salt/modules/cp.py", line 259, in get_url
File "salt/fileclient.py", line 538, in get_url
File "salt/utils/__init__.py", line 1069, in fopen
IOError: [Errno 13] Permission denied: 'C:/temp'
@waynew
waynew / file.py
Created September 8, 2014 21:39
Naive tail for saltstack
def tail(filename, n=10):
with open(filename, 'r') as f:
return ''.join(f.readlines()[-n:])
#/srv/salt/top.sls
base:
'myminion':
- myminion
#/srv/salt/myminion.sls
nginx:
pkg:
- installed
import thing
import pytest
import hypothesis.strategies as st
from hypothesis import given
from unittest import mock
@pytest.fixture(scope='module')
def something():
return 42
@waynew
waynew / broken.py
Created November 5, 2015 19:42
How do you validate?
from eve import Eve
from eve_sqlalchemy import SQL
from sqlalchemy.ext.declarative import declarative_base
from eve_sqlalchemy.decorators import registerSchema
from eve_sqlalchemy.validation import ValidatorSQL
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, relationship
from sqlalchemy import func
from sqlalchemy import (
x | o | x
---+---+---
o | x | o
---+---+---
o | x | o
Install Postgres Repo:
pkg.installed:
- name: pgdg-centos94
- sources:
- pgdg-centos94: http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-2.noarch.rpm
import sys
import curses
import time
import logging
log = logging.getLogger(__name__)
log.addHandler(logging.FileHandler('test.log'))
log.setLevel(logging.DEBUG)
def menu(window, dims):