Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Diagnostics;
namespace ConsoleApp6
{
internal class Program
{
private static void Main(string[] args)
{
const int Ntests = (int)1e4;
@Ippo343
Ippo343 / gist:8884f7a210b54ca00e35de400908a074
Created July 13, 2018 09:19
Lazy sieve of eratosthenes in python
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import collections
import itertools
def sieve():
# This will store a running list of all the factors that can lead to a number:
# { number: [factors of the number] }
@Ippo343
Ippo343 / ConfigMerger.py
Created September 26, 2016 09:31
Class to merge multiple python logging configuration files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
logging.fileConfig is pretty awesome already,
but if you could fragment the logging configuration into multiple configuration files
and then merge them together it be even more awesomer. Alas, it can't.
Therefore, this module provides a convenience class that you can feed with configuration files.
The instance will read the configuration files and merge the logging related bits into one.
@Ippo343
Ippo343 / output.log
Created July 5, 2016 15:09
arv-camera-test output
Looking for the first available camera
vendor name = Allied Vision Technologies
model name = Manta_G-032B
device id = 50-0503355825
image width = 656
image height = 492
horizontal binning = 1
vertical binning = 1
payload = 322752 bytes
exposure = 15000 µs
@Ippo343
Ippo343 / xkcd1638.py
Created February 3, 2016 11:13
Script to compute the worst line in your bash history (http://xkcd.com/1638/)
import os
import string
alpha = string.letters + string.digits
max_ratio = -1
best_line = ""
with open(os.path.expanduser('~/.bash_history')) as f:
for line in f:
@Ippo343
Ippo343 / data.py
Created November 12, 2015 09:26
StackOverflow 33649423
import datetime
from itertools import takewhile, dropwhile
from dateutil.tz import tzoffset
from pprint import pprint
data = [{'id': 47},
{'operator': [{'id': 2}, {'login': u'fse'}]},
{'spot': [{'id': 207},
{'position': u'A1'},
{'spotDate': datetime.datetime(2015, 11, 4, 17, 7, 13, 326000, tzinfo=tzoffset(None, 3600))},
@Ippo343
Ippo343 / gist:e5c2331dcf8af2e24ab5
Created April 5, 2015 23:33
Cabal configure output
Searching for ghc in path.
Found ghc at C:\Haskell\2014.2.0.0\bin\ghc.exe
("C:\\Haskell\\2014.2.0.0\\bin\\ghc.exe",["--numeric-version"])
C:\Haskell\2014.2.0.0\bin\ghc.exe is version 7.8.3
looking for tool ghc-pkg near compiler in C:\Haskell\2014.2.0.0\bin
found ghc-pkg in C:\Haskell\2014.2.0.0\bin\ghc-pkg.exe
("C:\\Haskell\\2014.2.0.0\\bin\\ghc-pkg.exe",["--version"])
C:\Haskell\2014.2.0.0\bin\ghc-pkg.exe is version 7.8.3
("C:\\Haskell\\2014.2.0.0\\bin\\ghc.exe",["--supported-languages"])
("C:\\Haskell\\2014.2.0.0\\bin\\ghc.exe",["--info"])
@Ippo343
Ippo343 / Cabal-1.22.2.0.log
Created April 5, 2015 23:24
cabal-install log
[ 1 of 79] Compiling Distribution.Compat.CreatePipe ( C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\Distribution\Compat\CreatePipe.hs, C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\dist\setup\Distribution\Compat\CreatePipe.o )
[ 2 of 79] Compiling Distribution.Compat.Binary ( C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\Distribution\Compat\Binary.hs, C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\dist\setup\Distribution\Compat\Binary.o )
[ 3 of 79] Compiling Distribution.GetOpt ( C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\Distribution\GetOpt.hs, C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\dist\setup\Distribution\GetOpt.o )
[ 4 of 79] Compiling Distribution.TestSuite ( C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\Distribution\TestSuite.hs, C:\Users\MIPPO_~1\AppData\Local\Temp\Cabal-1.22.2.0-3008\Cabal-1.22.2.0\dist\setup\Dist
@Ippo343
Ippo343 / metapackage1.ckan
Last active August 29, 2015 14:15
CKAN metapackage example
{
"spec_version": "v1.6",
"name": "An awesome modpack",
"identifier": "IpposModpack",
"kind" : "metapackage",
"abstract": "Example ckan metapackage",
"license": "CC-BY-SA",
"depends": [
{
"name": "FerramAerospaceResearch"