Skip to content

Instantly share code, notes, and snippets.

describe "fauxhai" do
before { Fauxhai.mock(platform: "centos", version: "6.4") }
let(:chef_run) { ChefSpec::Runner.new.converge() }
it "sets the platform correctly" do
expect(chef_run.node["platform"]).to eq("centos")
end
end
def fizzbuzz(n):
for i in range(n):
if i % 3 == 0 and i % 5 == 0:
print("fizzbuzz")
elif i % 3 == 0:
print("fizz")
elif i % 5 == 0:
print("buzz")
else:
print(i)
@borntyping
borntyping / python-lint.md
Last active August 29, 2015 13:56
Python checker tools

Conventions

  • pep8: Check code against PEP8 conventions
  • pep257: Check docstrings against PEP257 conventions

Lint and static analysis

  • pylint: Strict lint tool
  • pyflakes: Static analysis
  • frosted: Sucessor to pyflakes
@borntyping
borntyping / log.py
Created February 23, 2014 13:12
Better Python logging
def log(component, message, level='info'):
"Sends a log message with that component."
"If component is not a string, it's __qualname__ (__module__.__name__ + __name__) is used."
def create_log(component=None, level=None, ...):
"Creates a log that will use the given parameters."
for i in range(10):
print(i)
❯ python2 ~/dev/while.py
3.16730904579
2.61067199707
❯ python3 ~/dev/while.py
4.79477457899975
2.070868385999802
❯ npm install bower
npm http GET https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/bower
npm http GET https://registry.npmjs.org/bower/-/bower-1.3.1.tgz
npm http 200 https://registry.npmjs.org/bower/-/bower-1.3.1.tgz
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/archy/0.0.2
npm http GET https://registry.npmjs.org/bower-config
npm http GET https://registry.npmjs.org/bower-endpoint-parser
npm http GET https://registry.npmjs.org/bower-json

Keybase proof

I hereby claim:

  • I am borntyping on github.
  • I am borntyping (https://keybase.io/borntyping) on keybase.
  • I have a public key whose fingerprint is 085A 4ECB 0217 B1F7 C3E5 0212 01D4 6EC1 C419 6A92

To claim this, I am signing this object:

@borntyping
borntyping / supervisor.spec
Created April 9, 2014 10:29
Example blank specfile
Name: supervisor
Version:
Release: 1
Summary:
Group:
License:
URL:
Source0:
@borntyping
borntyping / rm
Last active August 29, 2015 13:59
❯ mkdir test
❯ touch test/{a,b,c}
❯ touch test/.{a,b,c}
❯ ls -la test/.*
-rw-r--r-- 1 sam sam 0 Apr 13 17:10 test/.a
-rw-r--r-- 1 sam sam 0 Apr 13 17:10 test/.b
-rw-r--r-- 1 sam sam 0 Apr 13 17:10 test/.c
❯ rm -v test/.*
removed `test/.a'
removed `test/.b'