Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
@ecounysis
ecounysis / lib.py
Last active January 18, 2023 19:03
poker stuff
# Poker Hand Analyser Library for Project Euler: Problem 54
from collections import namedtuple
suits = "h,d,c,s".split(",")
faces = "2,3,4,5,6,7,8,9,T,J,Q,K,A"
face = faces.split(',')
class Card(namedtuple('Card', 'face, suit')):
def __repr__(self):
@ecounysis
ecounysis / baseball_sim.py
Last active September 9, 2021 17:33
a simple simulation of a baseball game using on-base average as an input
import random
def at_bat(hitter):
if (random.random() < hitter['avg']):
return 'ON'
else:
return 'OUT'
def inning():
@ecounysis
ecounysis / OAuthBase.cs
Last active May 14, 2024 22:33 — forked from ChanahC/OAuthBase.cs
OAuth 1.0 library recommended by NetSuite for c#
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
// https://gist.github.com/ecounysis/7889b67704a26f26369399a636105233
// https://netsuite.custhelp.com/app/answers/detail/a_id/42169/kw/C%23%20&gt;%20RESTlet%20Authentication%20Using%20Token%20(Token-Based%20Authentication)
namespace OAuth
{
@ecounysis
ecounysis / markdown.pl
Created December 7, 2016 21:43
Markdown to HTML
#!/usr/bin/perl
#
# Markdown -- A text-to-HTML conversion tool for web writers
#
# Copyright (c) 2004 John Gruber
# <http://daringfireball.net/projects/markdown/>
#
import re
class Book:
def __init__(self, desc):
ba = desc.split(" by ")
self.title = ba[0]
self.author = ba[1]
books = []
# I wrote this after I answered this question on SO
# http://stackoverflow.com/q/40663103/102022
def hangman(word):
word = word.lower()
right_letters = []
wrong_letters = []
def guess(letter):
letter = letter.lower()
if letter in right_letters or letter in wrong_letters:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define MAXSIZE 65536
char pw[MAXSIZE];
void print_usage();
int randomizebuff(char *buff, int start, int end, int buffsize);
int number(char *st);
@ecounysis
ecounysis / MemoizationTesting.cs
Last active May 17, 2018 22:10
easy function memoization in C#
// Copyright (c) 2016 Eric Christensen
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
@ecounysis
ecounysis / hrm20.asm
Created June 12, 2016 23:30
Human Resource Machine Year 20
a:
b:
COPYFROM 9
COPYTO 2
INBOX
COPYTO 0
JUMPZ f
INBOX
COPYTO 1
@ecounysis
ecounysis / hrm19.asm
Created June 12, 2016 16:09
Humana Resource Machine Level 19
a:
b:
INBOX
COPYTO 0
OUTBOX
c:
COPYFROM 0
JUMPZ a
JUMPN e
BUMPDN 0