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
| [filter "strip_ipynb"] | |
| clean = python3 strip_ipynb.py |
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
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <ctype.h> | |
| #include <openssl/rsa.h> | |
| #include <openssl/engine.h> | |
| #include <openssl/pem.h> | |
| // I'm not using BIO for base64 encoding/decoding. It is difficult to use. | |
| // Using superwills' Nibble And A Half instead |
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
| Taken from https://stackoverflow.com/questions/27582001/how-to-use-128-bit-integers-in-cython | |
| Basically, we make cython believe we will use 64 bit int to generate the .c file, | |
| but by using a C header we will, in fact, define a 128 bit int (the definition | |
| in the .h file does not match what we put into the pyx file). | |
| Once Cython has generated the .c file, we can compile it with GCC without further trouble, | |
| as GCC does support 128 bit ints |
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
| import sys | |
| def get_size(obj, seen=None): | |
| """Recursively finds size of objects""" | |
| size = sys.getsizeof(obj) | |
| if seen is None: | |
| seen = set() | |
| obj_id = id(obj) | |
| if obj_id in seen: | |
| return 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
| # seen here: https://unix.stackexchange.com/questions/58304/is-there-a-way-to-call-a-command-with-a-set-time-limit-and-kill-it-when-that-tim | |
| timeout() { | |
| time=$1 | |
| # start the command in a subshell to avoid problem with pipes | |
| # (spawn accepts one command) | |
| command="/bin/sh -c \"$2\"" |
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
| # Adapted from here: https://groups.google.com/forum/#!msg/comp.lang.python/dUOqrbnpKeI/LYzGiO0M8fEJ | |
| def smaller_primes(n): | |
| """Given an integer n, compute a list of the primes <= n""" | |
| if n < 2: | |
| return [] | |
| sieve = list(range(3, n + 1, 2)) | |
| top = len(sieve) |
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
| # Seen here: http://stackoverflow.com/questions/16996217/prime-factorization-list | |
| def factorize(n): | |
| primfac = [] | |
| d = 2 | |
| while d*d <= n: | |
| while (n % d) == 0: | |
| primfac.append(d) # supposing you want multiple factors repeated | |
| n //= 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
| #! /usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| USE UNDER YOUR OWN RESPONSIBILITY!! | |
| IMPORTANT: options with sub-levels MUST end with spaces!!! | |
| """ |
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
| $ awk '{if(min==""){min=max=$1}; if($1>max) {max=$1}; if($1< min) {min=$1}; total+=$1; count+=1} END {print total/count, min, max}' FILE.DAT |
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
| #change the hardstatus settings to give an window list at the bottom of the | |
| #screen, with the time and date and with the current window highlighted | |
| startup_message off | |
| hardstatus alwayslastline | |
| #hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}' | |
| hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}]%{=b C}[ %m/%d %c ]%{W}' | |
| defscrollback 5000 | |
| autodetach on | |
| idle 600 eval "screen cmatrix -f -o -u 10" "idle 0" |