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
## !!! gawk, non posix | |
## run: gawk -v cmp=[fst|snd] -f thisfile | |
## prints half `lspci -k` output, cutting sensibly ;) | |
## see: https://forum.ubuntu-it.org/viewtopic.php?f=33&t=654734&sid=8194abf8e927662044c7c8f3ab902872 | |
function fst(val, cmp) { | |
return (val < cmp) ? 1 : 0 | |
} | |
function snd(val, cmp) { |
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
# Cfr. https://forum.ubuntu-it.org/viewtopic.php?p=5297724#p5297724 | |
# ... and https://forum.ubuntu-it.org/viewtopic.php?f=33&t=649359 | |
# ... and https://gist.github.com/crap0101/7dd3acd6f294507505fc23a5b62890ef | |
import argparse | |
import functools | |
import itertools | |
import collections | |
import math |
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
# Cfr. https://forum.ubuntu-it.org/viewtopic.php?p=5297724#p5297724 | |
# ... and https://forum.ubuntu-it.org/viewtopic.php?f=33&t=649359 | |
import math | |
import time | |
def is_primo(n): | |
lst_range = [x for x in range(2, n+1)] | |
lim = int(math.sqrt(n)) |
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 python3 | |
# Cfr. https://forum.ubuntu-it.org/viewtopic.php?f=33&t=649253 | |
import argparse | |
import collections | |
import random | |
import sys | |
import timeit |
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
# Cfr. http://rickystewart.wordpress.com/2013/09/03/why-sorting-an-array-makes-a-python-loop-faster/ | |
from __future__ import print_function | |
import random | |
import timeit | |
MAX = int(1e6) | |
ls = [x for x in range(MAX)] | |
lu = [x for x in range(MAX)] | |
random.shuffle(lu) |
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 python | |
#coding: utf-8 | |
import shelve | |
from contextlib import closing | |
import itertools as it | |
import time | |
import random | |
import argparse |
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
# -*- coding: utf-8 -*- | |
# This file is part of ImparaParole and is released under a MIT-like license | |
# Copyright (c) 2010 Marco Chieppa (aka crap0101) | |
# See the file COPYING.txt in the root directory of this package. | |
""" | |
Conway's Game of Life (modified to be used with pygame) | |
NOTE: needs the classes GenericGameObject and Grid |
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
#coding: utf-8 | |
# Copyright (C) 2011 by Enrico Franchi (tweaks by crap0101) | |
# | |
# This file is released under the terms of the MIT license | |
# http://www.opensource.org/licenses/mit-license.php | |
import itertools as it | |
import functools |