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 itertools | |
x = range(1, 20) | |
solutions = {} | |
for a, b in itertools.combinations(x, 2): | |
sol = a ** 2 + b ** 2 | |
if sol in solutions: | |
print("Found a solutions: %d^2 + %d^2 = %d^2 + %d^2 = %d " % (a, b, solutions[sol][0], solutions[sol][1], sol)) |
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
if [ "$1" = "--reset" ]; then | |
ip6tables -F INPUT | |
ip6tables -F FORWARD | |
ip6tables -F OUTPUT | |
ip6tables -P INPUT ACCEPT | |
ip6tables -P OUTPUT ACCEPT | |
ip6tables -P FORWARD ACCEPT | |
else | |
# Disable processing of any RH0 packet |
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 logging | |
import logging.handlers | |
def get_logger(name, logfile=""): | |
""" | |
Get a logger with a given name. | |
The logger will be configured to match other loggers. | |
Keyword arguments: |
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
words = ["foo", "bar", "blafoo"] | |
check_list = lambda x, y: map(lambda z: not x.startswith(z), y) | |
if not all(check_list("foobarfoo", words)): | |
print("String starts with one of the substrings") | |
else: | |
print("String does not start with one of the substrings") |
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 | |
# Show the validity of certificate files | |
# If the certificate will run out in less than one month, a warning is shown | |
# If the certificate is not valid anymore, an error message is shown | |
# Valid certificates are not printed out | |
for cert in /etc/nginx/ssl/*.crt; do | |
d1=$(date -d "$(openssl x509 -noout -dates -in $cert | grep notAfter | cut -d '=' -f 2)" +%s) | |
d2=$(date +%s) |
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 time | |
def format_time(time): | |
m, s = divmod(time, 60) | |
h, m = divmod(m, 60) | |
d, h = divmod(h, 24) | |
# could be extended here to weeks, months, years, ... | |
# but the exact calculation of months, weeks and years is a little bit | |
# more difficult... so we leave it as it is. | |
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
""" | |
Display Random Data using matplotlib's animation function | |
forked from: | |
Author: Mahesh Venkitachalam | |
Website: electronut.in | |
""" | |
import sys | |
import numpy as np |
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
G21 ;mm | |
G90 ; absolute coordinates | |
G64 ; continuous mode for corners | |
G0 Z40.000000 | |
F1800 | |
M3 S6000 | |
G54 | |
G17 |
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 | |
# written by reox 2015 | |
# test the read speed of your disk. | |
# this script will test random access, you can remove the shuf command in the for loop to have linear access too. | |
# after you run the script, plot the data with your favourite plotting lib. | |
set +x | |
set +e | |
sectors=$(fdisk -l $1 | egrep -o "[0-9]+ sectors" | cut -f 1 -d " ") |
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/sh | |
# Get jeopardy.mp4 from: | |
# clive https://www.youtube.com/watch?v=0Wi8Fv0AJA4 | |
# ffmpeg -i <file> -vn -acodec copy "jeopardy.mp" | |
mpv -loop $(dirname $0)/jeopardy.mp4 >/dev/null 2>&1 & | |
PID=$! | |
while [ "$(git pull)" = "Already up-to-date." ]; do | |
echo -n "." |
OlderNewer