Skip to content

Instantly share code, notes, and snippets.

View PJensen's full-sized avatar

Pete Jensen PJensen

  • New England
View GitHub Profile
@PJensen
PJensen / success.c
Created February 13, 2009 05:00
In the beginning ...
#include <stdlib.h>
int main(int argc, char** argv) { return EXIT_FAILURE; }
@PJensen
PJensen / ECurve.py
Created June 30, 2009 23:36
Elliptic Curves
# Author: Pete Jensen
# Author: Natasha Mandryk (math)
class ECurve:
def __init__(self, p, a, b):
# Define basic variables, coefficients and prime p.
# (y^2 mod p) = (x^3 + ax + b) mod p
self.__a = a # The coefficient: a
self.__b = b # The coefficient: b
self.__p = p # The prime p.
@PJensen
PJensen / ECurve.py
Created July 13, 2009 15:52
Elliptic Curves
# Authors: Pete Jensen, Natasha Mandryk (math)
class ECurve:
def __init__(self, p, a, b):
# Define basic variables, coefficients and prime p.
# (y^2 mod p) = (x^3 + ax + b) mod p
self.__a = a # The coefficient: a
self.__b = b # The coefficient: b
self.__p = p # The prime p.
@PJensen
PJensen / VSSRemover.py
Created July 13, 2009 20:57
VSS Remover; incomplete
import os, sys, string
class VSSRemover:
def __init__(self, aStartDir):
self._startDir = aStartDir
self._extensions = ['sln', 'scc', 'vssscc', 'csproj', 'vspscc']
self._slnSCTagOne = "GlobalSection(SourceCodeControl)"
@ECHO OFF
REM The following applies trigger patches to the selected database using
REM a preset username catalog and password.
ECHO Setting db connection information
SET dbUser=[[UserNameHere]]
SET dbCatalog=[[CatalogNameHere]
SET dbServer=[[ServerNameHere]
ECHO ***
/// <summary>
/// Computes scalar result from collection of booleans
/// </summary>
/// <param name="aBooleans">Array of booleans to be aggregated</param>
/// <returns>The aggregation of all booleans;
/// <value>true if all true, false if otherwise.</value>
/// </returns>
public bool aggregateBooleans(bool[] aBooleans)
{
bool tmpReturn = true;
@PJensen
PJensen / a_RandomChoice.cs
Created September 20, 2010 16:50
Similar to Pythons Random-choice but for C#
/// <summary>
/// RandomChoice
/// <example>
/// <code>
/// var flowerColor = Dice.RandomChoice<Colour>(new List<Colour>()
/// {
/// new Colour(ConsoleColor.Magenta, ConsoleColor.Green),
/// new Colour(ConsoleColor.Red, ConsoleColor.Green),
/// new Colour(ConsoleColor.Yellow, ConsoleColor.Green),
/// new Colour(ConsoleColor.DarkMagenta, ConsoleColor.Green),
@PJensen
PJensen / nThNumber.cs
Created October 4, 2010 15:25
private static string nth(int n)
/// <summary>
/// Given a number (n) returns a string referring to that number (n)
/// using (st), (nd), (th), (rd) as suffixes.
/// </summary>
/// <param name="n">The number to convert to nth notation.</param>
/// <returns>The passed number in nth notation.</returns>
private static string nth(int n)
{
switch (n) {
case 11:
@PJensen
PJensen / p55.py
Created October 31, 2010 18:37
Find the number of lychrel numbers below 10k.
import time
##
# @File: p55.py
# @Author: PJensen
# @Version: Oct 31, 2010
# @Description: Find the number of lychrel numbers below 10k.
# http://projecteuler.net/index.php?section=problems&id=55
##
def fast_lychrel(n):
N_MAX = 50
@PJensen
PJensen / p74.py
Created November 1, 2010 01:01
Unoptimized solution for Problem-74.
import time
##
# @Fle: p74.py
# @Author: PJensen
# @Version: Oct 31, 2010
# @Description: Unoptimized solution for Problem-74.
# http://projecteuler.net/index.php?section=problems&id=74
# n-factorial