This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(5): | |
for j in range(3): | |
if i == 2 and j == 1: | |
break | |
else: | |
continue | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# const decorator | |
def const(f): | |
def fset(self, value): | |
raise TypeError | |
def fget(self): | |
return f(self) | |
return property(fget, fset) | |
# example with class | |
class Data(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# i3status configuration file. | |
order += "battery 2" | |
battery 2 { | |
integer_battery_capacity = true | |
last_full_capacity = true | |
path = "/home/lab/.uevent" | |
format = "%status %percentage %remaining" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ "${1,,}" = "on" ] || [ "${1,,}" = "enable" ] || [ "${1,,}" = "1" ]; then | |
arg=0 | |
elif [ "${1,,}" = "off" ] || [ "${1,,}" = "disable" ] || [ "${1,,}" = "0" ]; then | |
arg=1 | |
else echo "Unknown argument: $1"; exit 1 | |
fi | |
nmcli r all $arg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# i3 config file (v4) | |
# Disable and re-enable keyboard | |
exec (~/bin/keyboard.sh disable;sleep 1;~/bin/keyboard.sh enable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# As far as I remember only disables sleep until the terminal where this is run is closed. | |
systemd-inhibit --what=handle-lid-switch sleep 1d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# remove http:// etc | |
SUBSTRING=$(cut -d. -f2- <<< "$1") | |
# remove last slash if present | |
if [ "${SUBSTRING: -1}" = "/" ];then | |
SUBSTRING="${SUBSTRING%?}" | |
fi | |
# count subdirectories | |
NCUT=$(grep -o "/" <<< "$SUBSTRING" | wc -l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import * | |
import itertools | |
def M(a, f1, f2, f3, f4): | |
a1, a2, a3, a4 = a.values() | |
M1 = f1 * Matrix([[0,-a3, a2,0],[a3, 0, -a1,0],[-a2, a1, 0,0],[0,0,0,0]]) | |
M2 = f2 * Matrix([[0,0, 0,0],[0, 0, 0,0],[0, 0, 0,0],[a1,a2,a3,0]]) | |
M3 = f3 * Matrix([[0,0, 0,a1],[0, 0, 0,a2],[0, 0, 0,a3],[0,0,0,0]]) | |
M4 = f4 * a4 * eye(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import * | |
import itertools | |
def do_replacement(expr): | |
queue = [expr] | |
permutations = [] | |
while len(queue) > 0: | |
next_queue = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def make_exclusionlist(fragment, capped, max_length, ignore_capping_hydrogens = True): | |
# is this int? - else change | |
frag_serials = np.asarray(fragment.serials, dtype=int) | |
valid_capped_fragments = np.fromiter((frag for frag in capped if capfrag.ignore == False), int) | |
valid_capped_fragment_serials = [[serial for serial, name in zip(capfrag.serials, capfrag.names) if (ignore_capping_hydrogens and name != " H* ")] for capfrag in valid_capped_fragments] | |
# are serials unique? - else change | |
matches = (np.intersect1d(fragment.serials, cap_serials, assume_unique = True) for cap_serials in valid_capped_fragment_serials) |
OlderNewer