Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import time | |
from datetime import datetime, date | |
# 今天 | |
datetime.datetime.today().date().isoformat() | |
# 通过日期对象生成时间戳 | |
int(time.mktime(datetime.now().timetuple())) | |
# 通过时间戳生成日期对象,timestamp 的时间戳以秒为单位 |
#!/bin/bash | |
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/ | |
# Install stuff # | |
################# | |
# Install development tools and some misc. necessary packages | |
yum -y groupinstall "Development tools" | |
yum -y install zlib-devel # gen'l reqs |
#!/bin/bash | |
libs=( "/usr/local/lib/libmacfuse_i32.2.dylib" \ | |
"/usr/local/lib/libosxfuse_i32.2.dylib" \ | |
"/usr/local/lib/libosxfuse_i64.2.dylib" \ | |
"/usr/local/lib/libmacfuse_i64.2.dylib" \ | |
"/usr/local/lib/libosxfuse_i32.la" \ | |
"/usr/local/lib/libosxfuse_i64.la" \ | |
"/usr/local/lib/pkgconfig/osxfuse.pc" ) |
#! /usr/env/ruby | |
require "benchmark" | |
require 'digest/md5' | |
# The password hash to crack | |
password_hash = "e1f3ecc31656795a128db19da490c9ec" | |
# Helper for hashing passwords | |
def md5(password) | |
Digest::MD5.hexdigest(password) |
# download latest libevent2 and tmux sources, and extract them somewhere | |
# (thx bluejedi for tip on latest tmux URL) | |
# | |
# at the time of writing: | |
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz | |
# http://sourceforge.net/projects/tmux/files/latest/download?source=files | |
# | |
# install deps | |
yum install gcc kernel-devel make ncurses-devel |
#!/bin/sh | |
### | |
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
### | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
Vagrant::Config.run do |config| | |
# debug default is :headless | |
config.vm.boot_mode = "gui" | |
# the .box file | |
config.vm.box = "afa-chef-server" | |
config.vm.box_url = "/V3/base_debian/with-apt.box" | |
# ssh config | |
config.ssh.private_key_path = "afa_private_key" |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/bin/sh | |
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh | |
set -e | |
# Must be a valid filename | |
NAME=foo | |
PIDFILE=/var/run/$NAME.pid | |
#This is the command to be run, give the full pathname | |
DAEMON=/usr/local/bin/bar |
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# By Uğur Özyılmazel, @vigobronx | @ugurozyilmazel | |
# http://vigodome.com | http://ugur.ozyilmazel.com | http://github.com/vigo | |
def get_paged_memory_usage(match_string, paging=4096) | |
mvar = 3 | |
if match_string.split(/[^\w]/).length > 1 | |
mvar = 4 |