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 | |
color=$(gdbus call --session --dest org.gnome.Shell.Screenshot --object-path /org/gnome/Shell/Screenshot --method org.gnome.Shell.Screenshot.PickColor) | |
echo "COLOR: $color" | |
numbers=$(echo $color | sed 's/[^0-9,.]*//g') | |
echo "FLOAT: $numbers" | |
rgb=$(echo $numbers | awk -F',' '{ print $1 * 255, $2 * 255, $3 * 255 }') | |
echo "RGB: $rgb" |
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
seq 50 | awk 'NR%3!=0 && NR%5!=0 { print } NR%3==0 && NR%5!=0 { print "FIZZ" } NR%5==0 && NR%3!=0 { print "BUZZ" } NR%15==0 { print "FIZZBUZZ" }' |
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
def print_progress_bar (iteration, total, prefix='', suffix='', decimals=1, length=100, fill='█'): | |
""" | |
Call in a loop to create terminal progress bar | |
@params: | |
iteration - Required : current iteration (Int) | |
total - Required : total iterations (Int) | |
prefix - Optional : prefix string (Str) | |
suffix - Optional : suffix string (Str) | |
decimals - Optional : positive number of decimals in percent complete (Int) | |
length - Optional : character length of bar (Int) |
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 numpy as np | |
import h5py | |
def get_fileobj_size(file_obj): | |
""" | |
Gets the size of an open file 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
from random import randrange | |
import re | |
import urllib | |
for i in range(5): | |
sock = urllib.urlopen("http://www.youporn.com/random/video/") | |
htmlSource = sock.read() | |
sock.close() | |
result = re.findall('<p class="message">((?:.|\\n)*?)</p>', htmlSource) |
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 collections import deque as dq | |
class RingBuffer(dq): | |
""" | |
Simple ring buffer. | |
Args: | |
size (int): number of items | |
""" |
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 bin_ndarray(ndarray, new_shape, operation='sum'): | |
""" | |
Bins an ndarray in all axes based on the target shape, by summing or | |
averaging. | |
Number of output dimensions must match number of input dimensions. | |
Example |