Skip to content

Instantly share code, notes, and snippets.

@Faxn
Faxn / random_program.py
Last active March 26, 2018 23:28
Idea came up in conversation. It's a python script that starts a random program off your hard drive.
import os.path
import sys
import random
import re
import argparse
from pathlib import Path
def main(fast=False, once=False):
if fast:
get_exe = random_walk
@Faxn
Faxn / Sudoku.pl
Created February 23, 2014 19:55
Sudoku solver in perl using Moose
package Sudoku::Cell;
use Moose;
use warnings;
use parent 'Clone';
use integer;
has 'possible' =>(
is => 'rw',
isa => 'Int', #an array of booleans
default=>0b111111111, #9 1s
@Faxn
Faxn / fun.py
Last active October 15, 2020 05:11
We are given the following problem: Given a text file with 999,999 lines, one number per line, numbers in random order from 1 to 1,000,000 but a single number is missing, figure out what number is missing. Source: http://blog.moertel.com/posts/2013-12-14-great-old-timey-game-programming-hack.html#comment-1165807320
import argparse, locale, timeit, random
from math import *
"""
We are given the following problem:
Given a text file with 999,999 lines, one number per line,
numbers in random order from 1 to 1,000,000 but a single number is
missing, figure out what number is missing.
Source: http://blog.moertel.com/posts/2013-12-14-great-old-timey-game-programming-hack.html#comment-1165807320
@Faxn
Faxn / csvMerge.py
Created December 9, 2013 18:04
Small script to merge and split csv files.
import csv, argparse, _thread, os, time
#TODO: break these out into command line opts
in_file_open_args = dict(newline='', encoding='CP1252', errors='strict')
out_file_open_args = dict(newline='', encoding='UTF-8', errors='backslashreplace')
#opens files from the list of paths provided as csv files and writes all
#of their rows into the output FILE provides as out_file.
def merge(infile_names, out_file):