Skip to content

Instantly share code, notes, and snippets.

View basnijholt's full-sized avatar

Bas Nijholt basnijholt

View GitHub Profile
@basnijholt
basnijholt / install-fresh-macOS.md
Last active March 17, 2024 03:59
install fresh macOS
@basnijholt
basnijholt / presentation-hv-h5py-ipython-parallel
Created June 13, 2015 12:57
nbviewer-example-that-doesnt-work-on-slides
This file has been truncated, but you can view the full file.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "skip"
}
@basnijholt
basnijholt / take_notes_ipynb.py
Last active September 17, 2015 18:41
Take only notes from ipynb
def isnote(cell):
try:
return cell['metadata']['slideshow'][u'slide_type'] == 'notes'
except KeyError:
return False
with open('Presentation.ipynb') as json_data:
data = json.load(json_data)
data['cells'] = [cell for cell in data['cells'] if isnote(cell)]
json.dump(data2, open('Presentation-notes.ipynb', 'w'))
@basnijholt
basnijholt / migrate_repo.sh
Last active February 25, 2016 12:04 — forked from mariozig/migrate_repo.sh
Migrate repo from GitLab to GitHub Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror [email protected]:r-j-skolasinski/discretizer.git
# Change into newly created repo directory
$ cd ~/discretizer.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@basnijholt
basnijholt / replace_or_delete_line.py
Created June 17, 2016 13:47
Replace or delete a line in files
# Replace a line
import os
files = [f for f in os.listdir('.') if f.endswith('md')]
for file in files:
with open(file, 'r') as f:
lines = f.readlines()
with open(file, 'w') as f:
import httplib2
import os
from apiclient import discovery
import oauth2client
import argparse
import base64
from email.mime.text import MIMEText
flags = argparse.ArgumentParser(
parents=[oauth2client.tools.argparser]).parse_args()
@basnijholt
basnijholt / stat.py
Last active October 12, 2016 11:21
check cluster usage
#!/usr/bin/env python
from collections import defaultdict, Counter
import subprocess
x = subprocess.check_output('qstat -ea'.split())
out = x.decode('utf-8').split('\n')
cols = ['Job ID', 'Username', 'Queue', 'Jobname', 'SessID', 'NDS', 'TSK',
'Required Memory', 'Required Time', 'S', 'Elapsed Time']
@basnijholt
basnijholt / firewall.user
Created February 14, 2017 14:09 — forked from vsefer/firewall.user
Firewall config for OpenWrt to tunnel all traffic to VPN with OpenVPN
iptables -I OUTPUT -o tun+ -j ACCEPT
iptables -I INPUT -i tun+ -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -o tun+ -j ACCEPT
iptables -I FORWARD -i tun+ -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -I POSTROUTING -o tun+ -j MASQUERADE
@basnijholt
basnijholt / cluster_watcher.py
Last active March 3, 2017 17:46
python cluster_watcher.py --interval=3 --logging=debug --log_file_prefix=watcher.log
from datetime import datetime
import socket
from tornado import ioloop, options
from tornado.log import app_log
from ipyparallel import Client
start_time = datetime.utcnow()
class EngineCuller:
"""An object for culling idle IPython parallel engines."""