This file contains 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
version: "2.3" | |
services: | |
deluge: | |
image: linuxserver/deluge | |
network_mode: host | |
container_name: deluge | |
restart: always | |
environment: | |
- UMASK_SET=022 | |
- PGID=0 |
This file contains 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
#!/bin/sh | |
set -e | |
PACKAGE_JSON="package.json" | |
PACKAGE_JSON_NEW="package.new.json" | |
PACKAGE_LOCK="package-lock.json" # default. when shrinkwrap used, is npm-shrinkwrap.json | |
function usage() { | |
echo "Usage: ${0} -d=<abs-path-to-dir-with-package.json> [-lf=<name-of-the-lock-file>]" |
This file contains 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
# Imagine Model has start_time field and you want to filter all events that | |
# fall into an intersection of two DateTimeRanges (tsrange in PostreSQL). | |
# Doing daterange intersections in Python is tedious, Postgresql is much better at it. | |
# That requires applying operators to a value (not a column) and that is not so | |
# straightforward: | |
query = DB.session.query(Model) | |
range1 = DateTimeRange(datetime(2017, 1, 5, 0), datetime(2017, 1, 5, 10, 5)) |
This file contains 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
require 'spec_helper' | |
# the root folder should contain Dockerfile so build_from_dir can work | |
describe "mycontainer" do | |
before(:all) do | |
image = Docker::Image.build_from_dir('.') | |
@container = image.run() | |
set :os, family: :debian | |
set :backend, :docker |
This file contains 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
SELECT client_addr, pg_xlog_location_diff(pg_stat_replication.sent_location, pg_stat_replication.replay_location) AS byte_lag FROM pg_stat_replication; |
This file contains 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 calendar, datetime | |
import pandas as pd | |
date_str = '2016-01-01T00:00:00+01:00' | |
date = pd.to_datetime(date_str).tz_localize('UTC') | |
print calendar.timegm(date.timetuple()) # 1451602800 | |
# Using strftime('%s') is not recommended as it depends on the timezone of the machine |
This file contains 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
# Taken from https://solidgeargroup.com/mocking-the-time | |
# (unlike many answers on StackOverflow, this one actually works and is easy to use) | |
import datetime | |
import mock | |
def mock_datetime(target, datetime_module): | |
real_datetime_class = datetime.datetime |