Skip to content

Instantly share code, notes, and snippets.

@Ivoz
Ivoz / AddPythonToPath.py
Created July 20, 2020 04:49
If you are able to run python code, use this to add python to your path on windows
import sys
from pathlib import Path
# Get the path to the Scripts directory
scripts_path = Path(sys.base_prefix) / "Tools" / "Scripts"
# Append it to python's import path so we can grab it
sys.path.append(str(scripts_path))
# Import the main function from the win_add2path script
from win_add2path import main
# run the main function to add python to out path
@Ivoz
Ivoz / quine.py
Last active January 31, 2016 18:10
A self-checking python quine, of sorts
#!/usr/bin/env python3
'''
A "self-verifying" quine - `<quine> <source_file>` will only print itself
if `<quine>` has the same output as `cat <source_file>`
'''
source = r'''{foreword}
import sys, subprocess
if len(sys.argv) > 1:
@Ivoz
Ivoz / alias.sh
Last active September 14, 2015 01:21
My aliases
#!/usr/bin/sh
# cd
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# common
alias cls='clear'
alias sctl='sudo systemctl'
@Ivoz
Ivoz / screens.sh
Created May 26, 2014 11:05
Do xrandr stuff
#!/bin/bash
laptop_screen="LVDS1"
external_screen="HDMI1"
position="left"
if [[ ! -z "$1" ]]; then
external_screen="$1"
fi
#!/usr/bin/bash
# Reproduce namespace / editable install problem with pip
# https://github.com/pypa/pip/issues/3
# cleanup from previous invocations
foos=('foo-main' 'foo-client' 'foo-env')
rm -rf -- "${foos[@]}"
#!/usr/bin/bash
# Reset
Reset='\[\e[0m\]'
# Regular Colors
Black='\[\e[0;30m\]'
Red='\[\e[0;31m\]'
Green='\[\e[0;32m\]'
Yellow='\[\e[0;33m\]'

Keybase proof

I hereby claim:

  • I am Ivoz on github.
  • I am ivo (https://keybase.io/ivo) on keybase.
  • I have a public key whose fingerprint is 2F04 3DCC D6E6 D5AC D262 2E0B C046 E8A8 7452 2973

To claim this, I am signing this object:

@Ivoz
Ivoz / dlp.py
Last active December 25, 2017 01:55
Naive way to solve the Discrete Logarithm Problem
#!/usr/bin/env python
from __future__ import print_function
def find_discrete_log(h, g, p):
H = {}
print('Generating table...')
for x1 in range(0, B):
gx1inv = mod_mul_inv(pow(g, x1, p), p)
H[(h * gx1inv) % p] = x1
@Ivoz
Ivoz / CA.crt
Created February 23, 2014 12:38
A random self-signed cert
-----BEGIN CERTIFICATE-----
MIIC0jCCAboCBQDQKZmkMA0GCSqGSIb3DQEBCwUAMC0xKzApBgNVBAMTIkdlbmVy
aWMgUGlwYSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTQwMjIzMTIzNTM1WhcN
MTUwMjIzMTIzNTM1WjAtMSswKQYDVQQDEyJHZW5lcmljIFBpcGEgQ2VydGlmaWNh
dGUgQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2nP8
dYN9P8IFogGy0INayhsafe+LRh3a7Qd6PnyxBZrP3RaRXo+gQ/wswD744cURuSX6
NJgmFt/sgMBclQtnNwkUUXaHzsZIsjQKr3EgUGhepnt7yU6UU0lW2L0yz8n4YLlV
ezSaIH7VMA8YRhgxBJGt/Nv/OnQk4y/tUxQnucKwhB/kax8rMiOuzry8e8FHc3yU
4KZaJYLVF3QJOAIRvicMLe5BybFDue7TaZk9snsFtCBoOnKz4sFgaPdP6hHfTqt7
ZEjHVSoo0tvAmGftfon+kJNtYir9hkXabWS1rVOE2pCui3HRBwMya6+TT9tLhFaJ
@Ivoz
Ivoz / rstlinks.md
Last active January 3, 2016 10:48
How to replicate labelled linking with rst?