Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
@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>%20RESTlet%20Authentication%20Using%20Token%20(Token-Based%20Authentication)
namespace OAuth
{
@ecounysis
ecounysis / LICENSE.txt
Created March 30, 2010 17:11
Black-Scholes Option Pricing Model
Copyright (C) 2011, 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
@ecounysis
ecounysis / bs.ml
Created July 13, 2010 08:08
Black-Scholes Option Pricing Model in OCaml
let list_sum ls = List.fold_left (fun a x->a+.x) 0.0 ls
let list_init c f = Array.to_list (Array.init c (fun x->f x))
let normal zz =
match zz with
|v when v = 0.0 -> 0.5
|v when v >= 6.0 -> 1.0
|v when v <= -6.0 -> 0.0
|v ->
let p = 0.2316419 in
@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 / 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 / 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);