Skip to content

Instantly share code, notes, and snippets.

View tomkooij's full-sized avatar

Tom Kooij tomkooij

View GitHub Profile
# coding: utf-8
from publicdb.histograms.models import DailyHistogram
from publicdb.histograms.models import Summary
import datetime
first = datetime.date(2019, 3, 1)
last = datetime.date.today()
sums = Summary.objects.filter(date__gte=first, date__lte=last)
for summary in sums:
#print(summary)
try:
@tomkooij
tomkooij / no_user_site.txt
Created January 16, 2019 06:55
Python 2.7.15 into the HiSPARC station-software repo (installer)
D:\>cd Python27
D:\Python27>python lib\site.py
sys.path = [
'D:\\Python27\\lib',
'D:\\github\\station-software\\user\\pythonshared',
'D:\\Python27\\python27.zip',
'D:\\Python27\\DLLs',
'D:\\Python27\\lib\\plat-win',
'D:\\Python27\\lib\\lib-tk',
@tomkooij
tomkooij / test_multipool.py
Created January 9, 2019 09:09
Reproduce a python multiprocessing.Pool() deadlock on Linux
#https://bugs.python.org/issue29759
#https://github.com/HiSPARC/publicdb/issues/242
import logging
import multiprocessing.pool
import signal
import time
def foo(num):
return num * num
@tomkooij
tomkooij / local.yml
Created January 8, 2019 21:36
ansible playbook to run roles on the localhost (probably a dev VM)
- hosts: localhost
connection: local
become: yes
become_user: root
roles:
- nagios
@tomkooij
tomkooij / new-admin-CA.md
Last active March 26, 2018 10:37
new PKI for the HiSPARC admin VPN

on tietar

Backup

backup /etc/openvpn folder:

$ sudo tar ctzf openvpn-backup.tar.gz /etc/openvpn
@tomkooij
tomkooij / Update CA.md
Last active March 5, 2018 14:03
Update the ca.crt on HiSPARC stations

Update ca.crt

This is a windows batchfile (.BAT) that updates ca.crt on a HiSPARC station computer through the HiSPARC Updater service that is running on all/most stations.

How does this work?

cert = open('ca.crt').read()
with open('create_cert.bat', 'w') as batchfile:
batchfile.write("@echo off\n(")
for line in cert.split('\n'):
if line:
batchfile.write("echo %s\n" % line)
batchfile.write(")>new_cert.crt")
@tomkooij
tomkooij / hisparc-vpn.md
Last active February 1, 2019 06:36
HiSPARC VPN documentatie

HiSPARC VPN

Er zijn twee VPNs:

  • een stations VPN. Hierin zitten alle stations. Station kunnen elkaar niet benaderen.
  • een admin VPN. In dit VPN loggen beheerders/coordinator in. Vanuit dit VPN kunnen alle stations (die in verbinding gemaakt hebben met het stations VPN) benaderd worden. (VNC e.d.)

OpenVPN configs staan op tietar in /etc/openvpn

@tomkooij
tomkooij / pusher.py
Created May 10, 2017 08:17
upload pickles to datastore
from __future__ import print_function
import datetime
import hashlib
import requests
import glob
import os
import pickle
@tomkooij
tomkooij / delete_configs.py
Created April 21, 2017 18:32
delete_configs.py
from __future__ import print_function
import os
import sys
from datetime import date
from sapphire.utils import pbar
PUBLICDB_PATH = '/srv/publicdb/www'
sys.path.append(PUBLICDB_PATH)