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 / fastest_mirrors.sh
Created March 7, 2024 23:40
Find the best Arch Linux mirrors (repositories) #arch #mirrors #repo
reflector -c NZ -c AU -c SG -p https -a 12 --sort rate --save /etc/pacman.d/mirrorlist && cat /etc/pacman.d/mirrorlist
@nad2000
nad2000 / create_directories_in_loop.sh
Created June 2, 2020 10:32
create a list of directories in loop
i in {6..20} ; do mkdir $(printf '%02d\n' $i) ; done
@nad2000
nad2000 / queue_and_threading_demo.py
Created November 26, 2018 05:47
queue and threading demo
from time import sleep
from queue import Queue
from threading import Thread
q = Queue(2)
Thread(target=lambda:(sleep(10), q.put(42))).start()
q.get()
./apache-jmeter-4.0/bin/jmeter.sh -n -t ./load_test/simple.jmx
@nad2000
nad2000 / mutable.py
Created July 29, 2018 11:21
Python tricks
visited = [[False] * m] * n
visited
=> [[False, False, False, False], [False, False, False, False], [False, False, False, False]]
visited[0]
=> [False, False, False, False]
visited[0][0]
@nad2000
nad2000 / slowest.sh
Created July 6, 2018 00:27
TOP 12 slowest requests form Apache access_log
# Make sure you are collectin the time it takes to hadle the request
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D" combined_with_response_time
# CustomLog logs/access_log combined_with_response_time
grep -E $(cut -d\ -f 21 access_log | sort -n | tail -12 | tr -d '\r' | tr '\n' '|')99999 orcidhub_log
@nad2000
nad2000 / bash-history-to-zsh-history.py
Created September 5, 2017 07:24
migrate bash history to zsh...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
HOME = os.path.join(home = expanduser("~")
import sys, os
def main():
bash_history = open(os.path.join(HOME, ".bash_history"), 'r')
zsh_history = open(os.path.join(HOME, ".zsh_history"), 'a')
@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)