Skip to content

Instantly share code, notes, and snippets.

@es0m
es0m / show_octopus_data.py
Created September 5, 2022 18:39
small script to visualize user data downloaded from Octopus Energy
# small script to visualize data downloaded from Octopus Energy
import pandas as pd
df = pd.read_csv('consumption.csv')
print(df.head())
tcol = ' Start'
ycol = 'Consumption (kWh)'
df[tcol] = pd.to_datetime(df[tcol], utc=True)
start_date = pd.to_datetime('7/18/2022 00:00', utc= True)
end_date = pd.to_datetime('8/18/2022 00:00', utc= True)
@es0m
es0m / get_datapoints_from_image.m
Created August 30, 2018 10:01
collect points from an image
function p = get_datapoints_from_image(im)
% collect points from an image.
% the first point to click is the offset
% the second point to click is the upper right corner that is to be scaled
% to 1, 1
% all subsequent points are then normalized to this coordinate frame
% \param im the image to be annotated
% \return p the list of points normalized to (0,0)..(1,1)
imshow(im);
p = [];
@es0m
es0m / add_swig_dependency.gradle
Last active July 9, 2018 17:35
adds a dependency on a swig task in gradle
task runSwig(type: Exec) {
def in_path = '../src/inlib'
def wrapper_path = "./src/main/cpp"
def wrapper_file = "${wrapper_path}/inlib_wrap.c"
def out_path = './src/main/java/generated'
inputs.files "${in_path}/java/inApi.i", "${in_path}/src/inlib/api.h"
outputs.dir out_path, wrapper_path
outputs.file wrapper_file
mkdir(out_path)
@es0m
es0m / ansi_color_text.py
Created June 29, 2018 18:35
makes an ansi color interpolation of a string for bash
fff = "(•_•) ( •_•)>⌐■-■ (⌐■_■)"
prompt = ""
for i, f in enumerate(fff):
prompt += "\\033[38;5;0;48;5;{}m{}".format(232+i,f)
print(prompt)
# compares the costs of two consecutive 5 year mortgages with one 10 year mortgage
from matplotlib import pyplot as plt
def installment(rate, principal, terms):
c = rate*principal/(1-pow(1+rate, -terms))
return c
def interest(rate, principal):
c = rate*principal
return c
@es0m
es0m / amex_csv2ofx.py
Last active June 28, 2018 12:13
converts a csv exported from americanexpress (uk) to ofx. requires https://github.com/reubano/csv2ofx and dateparser.
# converts a csv exported from americanexpress (uk) to ofx.
# todo:
# in the first row, you need to add the following labels for the columns:
# date, billed, payee, amount, account
# todo:
# also need to remove the £ sign from input csv.
from __future__ import absolute_import, print_function
from operator import itemgetter
@es0m
es0m / gitlab_docker_runner.md
Last active March 26, 2018 18:41
Gitlab: Add host ip to docker runner

Docker sometimes has issues with DNS resolution This isn't helped by a terrible network infrastructure So sometimes you get

fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@hostname/repo.git/': Couldn't resolve host 'hostname'

So you want to add the host to the /etc/hosts file. First idea to specify your own dns doesn't work.

Instead, you want to add something to /etc/hosts:

@es0m
es0m / git.migrate
Last active August 29, 2015 14:15 — forked from niksumeiko/git.migrate
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.