This file contains hidden or 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
[nlsa] |~ | |
name = Custom Settings |~ | |
x = 4 |~ |
This file contains hidden or 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
"""A settings module based on global variables""" | |
name = "Custom Settings" | |
x = 4 | |
y = 0 |
This file contains hidden or 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
// g++ -o closuretest -std=c++11 closuretest.cpp | |
#include <iostream> | |
#include<functional> | |
int main() { | |
int i = 0; | |
std::function<void()> fns[3]; | |
for(;i < 3; i++) { | |
fns[i] = [&i]() { | |
std::cout << i << std::endl; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 | |
# Restart the network | |
# usage: sudo restartnet [iface] | |
# Requires root | |
# Guess interface for outgoing traffic | |
TARGET=8.8.8.8 # known IP. Could also be 192.168.0.1 or similar for local networks | |
function guess_iface { | |
ip route get $TARGET | grep -Po '(?<=dev\s)\w+' | cut -f1 -d ' ' | |
} |
This file contains hidden or 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 | |
# usage: vcd2mp4 output.mp4 input.dat [input2.dat...] | |
if [[ $# -lt 2 ]]; then | |
echo "usage: $0 output.mp4 input.dat [input2.dat...]" >&2 | |
exit 1 | |
fi | |
output="$1" | |
shift |
This file contains hidden or 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/zsh | |
# A version of the 'timeout' command that works with shell functions | |
# | |
# Usage: | |
# source timeout_fn.sh | |
# timeout_fn DURATION COMMAND [ARG]... | |
timeout_fn () { | |
local timeout=$1 | |
shift |
This file contains hidden or 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
/* Solutions to https://stackoverflow.com/questions/800368/declaring-an-object-before-initializing-it-in-c/62247236#62247236 | |
* | |
* Uses c++17 for some solutions | |
* | |
* Output: | |
* | |
* $ g++ --std=c++17 -o animals animals.cpp && ./animals | |
* Naive Method | |
* ------------ | |
* Default Constructing Animal at 0x7ffee3fc20d0 |
This file contains hidden or 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
"""Test a difficult typing case. | |
Inspired by biopython's Bio.PDB.Entity. | |
https://gist.github.com/sbliven/8fb593f005eeafc0fecef71063f5dc39 | |
""" | |
import sys | |
from typing import TypeVar, Union |
This file contains hidden or 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
"""Create distribution of line lengths over files | |
Example: | |
find . -regextype egrep -regex './(Bio|Tests)/.*\.py' -type f -exec \ | |
python linelength.py --hist linelengths.png \ | |
--cdf linelengthscumulative.png -v '{}' '+' | |
""" | |
import sys |