Setup:
# set CONTRIBUTORS file to mailmap to remove duplicate emails for the same name
# see: https://git-scm.com/docs/git-shortlog#_mapping_authors
$ git config mailmap.file CONTRIBUTORS
Top 10 contributors (all):
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import json | |
import socket | |
import struct | |
import sys | |
import time | |
import concurrent.futures |
mysql -hlocalhost -uroot -p$(cat /etc/contrail/mysql.token) -e " | |
use heat; | |
delete from resource_data where resource_id in (select id from resource where stack_id in (select id from stack where name = \"$project\")); | |
delete from resource where stack_id in (select id from stack where name = \"$project\"); | |
delete from event where stack_id in (select id from stack where name = \"$project\"); | |
delete from stack where name = \"$project\"; |
Don't write in C. |
Setup:
# set CONTRIBUTORS file to mailmap to remove duplicate emails for the same name
# see: https://git-scm.com/docs/git-shortlog#_mapping_authors
$ git config mailmap.file CONTRIBUTORS
Top 10 contributors (all):
[Download Kafka] (https://www.apache.org/dyn/closer.cgi?path=/kafka/0.10.0.0/kafka_2.10-0.10.0.0.tgz)
> tar xzf kafka-<VERSION>.tgz
> cd kafka-<VERSION>
> sbt update
> sbt package
Start single node zookeeper instance
import sys, marshal, functools, subprocess | |
child_script = """ | |
import marshal, sys, types; | |
fn, args, kwargs = marshal.load(sys.stdin) | |
marshal.dump( | |
types.FunctionType(fn, globals())(*args, **kwargs), | |
sys.stdout) | |
""" |
by Bjørn Friese
Beautiful is better than ugly. Explicit is better than implicit.
I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.
# knife cheat | |
## Search Examples | |
knife search "name:ip*" | |
knife search "platform:ubuntu*" | |
knife search "platform:*" -a macaddress | |
knife search "platform:ubuntu*" -a uptime | |
knife search "platform:ubuntu*" -a virtualization.system | |
knife search "platform:ubuntu*" -a network.default_gateway |
#!/usr/bin/python | |
import fcntl | |
import os | |
import struct | |
import array | |
import sys | |
BLKGETSIZE=0x1260 | |
BLKGETSIZE64=0x80081272 | |
BLKSSZGET=0x1268 |
Thanks to this article by Christoph Berg
Directories and files
~/