Skip to content

Instantly share code, notes, and snippets.

View nad2000's full-sized avatar
🇳🇿
Working from New Zealand

Radomirs Cirskis nad2000

🇳🇿
Working from New Zealand
View GitHub Profile
@nad2000
nad2000 / NZ items in ORCID's public data files.py
Created July 7, 2017 06:07
NZ items in ORCID's public data files
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 05 11:53:20 2017
Can we get json to do the same tricks as xml, and then pull into mongodb for reporting
ORCID public data files are tar.gz with all json serially before xml, so can speed the process a wee bit by using the json
The real question is whether the json library is quicker with json, than ETree is with xml
NB: version 2.0 of ORCID schema
@author: Jason
@nad2000
nad2000 / post-update.sh
Created June 13, 2017 00:20
git post update hook that switches over to the pushed branch, updates the working directory and restarts the docker. It should be copied to .git/hooks/post-update
#!/bin/sh
## post-update hook recieves a list of all updated refs
for r in "$@"; do
case $r in
refs/heads/*) git --work-tree=$HOME --git-dir=$HOME/repo.git checkout -f $(git rev-parse --symbolic --abbrev-ref $r)
esac
done
cd $HOME
docker-compose restart
@nad2000
nad2000 / docker.sh
Created May 4, 2017 07:19
Docker notes
# removed dangling imagese:
docker rmi -f $(docker images -qf dangling=true)
import http.cookiejar
import getpass
import html.parser
import re
import sys
import urllib.request, urllib.parse, urllib.error
import urllib.request, urllib.error, urllib.parse
class Client:
sudo mv ORIGINAL o
sudo socat -t100 -x -v UNIX-LISTEN:./ORIGIAL,mode=777,reuseaddr,fork UNIX-CONNECT:./o
@nad2000
nad2000 / template.py
Created July 12, 2016 08:26
Spyder (the Scientific PYthon Development EnviRonment) new module template with the hashbang, source encoding line, and VIM modeline
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
"""
Created on %(date)s
@author: %(username)s
"""
"""Softmax."""
scores = [3.0, 1.0, 0.2]
import numpy as np
def softmax(x):
"""Compute softmax values for each sets of scores in x."""
exp_x = np.exp(x)
return exp_x / exp_x.sum(axis=0)
@nad2000
nad2000 / set_cp.bat
Created May 11, 2016 15:07
Set-up code page for Windows so that it stays permanently
@ECHO off
SET ROOT_KEY="HKEY_CURRENT_USER"
FOR /f "skip=2 tokens=3" %%i in ('reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage /v OEMCP') do set OEMCP=%%i
ECHO System default values:
ECHO.
@nad2000
nad2000 / 00_prepare.sh
Last active October 16, 2018 02:55
Scripts for "sft.addo.io" migration
## ON THE OLD SERVER:
# DB dump (PostgreSQL should be running):
sudo -u postgres pg_dump securetrans | bzip2 >securetrans.sql.bz2
# application and apache configuration backup
tar -C / -cjf ~/archive.tar.bz2 ./opt/sft_web ./etc/apache2 ~/
## archive static content:
tar -C /var -cjf ~/www.tar.bz2 ./www
## Keys:
sudo tar cjf ssh_keys.tar.bz2 /etc/ssl/certs/server.crt /etc/ssl/private/server.key
sed '0,/\<pre\>/d; /<\/pre>/,$d; s/ *//g; s/\t\t*/\n/g' -i archive.txt
# or together with the retrieving
curl https://web.archive.org/web/20111005152029/http://registro.br/dominio/proclib-l.html | sed '0,/\<pre\>/d; /<\/pre>/,$d; s/ *//g; s/\t\t*/\n/g' >archive.txt
# useful tihg
sort -R archive.txt > random_archive.txt