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 / 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
@nad2000
nad2000 / fetch_dmoz.py
Created May 6, 2016 10:59
sample with AIO
import aiohttp
async def fetch_dmoz(url):
async with aiohttp.client.get("https://www.dmoz.org/search?q=" + url) as res:
page = await res.text()
return page.find("DMOZ Categories"), page.find("DMOZ Sites")
@nad2000
nad2000 / Zenburn.ini
Created March 16, 2016 14:38
Modified DarkHighlight2.ini to look like "Zenburn" for PyScripter
[PyScripter]
Version=2.6.0.0
[Highlighters\Python]
Name=SynPythonSyn
Tag=0
DefaultFilter=Python Files (*.py;*.pyw)|*.py;*.pyw
Enabled=TRUE
[Highlighters\Python\Options]