This file contains hidden or 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
# Change this to your base projects path [$WORKON_BASE_DIR/{project1,project2,...}] | |
WORKON_BASE_DIR=/mnt/hgfs | |
# Change this to your relative virtual_env dir (if exists) [$WORKON_BASE_DIR/{project}/$VENV_DIR] | |
VENV_DIR=".env" | |
function workon() { | |
[ -z "$VIRTUAL_ENV" ] || deactivate | |
cd $WORKON_BASE_DIR/$1 && | |
[ -d $VENV_DIR ] && source $VENV_DIR/bin/activate |
This file contains hidden or 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 pytz | |
import pandas as pd | |
series = pd.Series.from_csv('series_crash.csv') | |
# My actual data is already in UTC, but need to localize due to CSV source | |
series = series.tz_localize(pytz.UTC) | |
# Convert from UTC to Local Timezone (PST in this case) | |
local_timezone = pytz.timezone('America/Los_Angeles') |
This file contains hidden or 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 functools import wraps | |
def skip_when_testing(func=None): | |
""" | |
Provides a way to provide functionality that only applies in the real production environment, otherwise stubs out the function. | |
Use this with **care** as this makes testability difficult and can lead to errors/bugs leaking into production. This should really only be used for non-functional (fire-and-forget) components like error logging or analytics. | |
""" | |
def wrapper(func): |
This file contains hidden or 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
{% macro mount_device(app, device, dir) -%} | |
{{ app }}-formatted: | |
cmd.run: | |
- name: "mkfs.ext4 /dev/{{ device }}" | |
- unless: "file -sL /dev/{{ device }} | grep -q ext4" | |
{{ app }}-mounted: | |
mount.mounted: |
This file contains hidden or 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 A(object): | |
y = x + 1 | |
x = 1 | |
a = A() | |
a.y |
This file contains hidden or 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
x = 1 | |
class A(object): | |
y = x + 1 | |
a = A() | |
a.y |
This file contains hidden or 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
# | |
# Author:: Adam Jacob (<[email protected]>) | |
# Author:: Seth Chisamore (<[email protected]>) | |
# Copyright:: Copyright (c) 2010-2011 Opscode, Inc. | |
# License:: Apache License, Version 2.0 | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# |
NewerOlder