Skip to content

Instantly share code, notes, and snippets.

using System;
using StructureMap;
namespace ConsoleApplication1
{
class Program {
private static void Main(string[] args) {
IContainer container = ConfigureDependencies();
IAppEngine appEngine = container.GetInstance<IAppEngine>();
@ameerkat
ameerkat / BoyerMooreStringSearch.py
Created October 14, 2010 17:46
Boyer Moore string search implementation in Python
# Boyer Moore String Search implementation in Python
# Ameer Ayoub <ameer.ayoub@gmail.com>
# Generate the Bad Character Skip List
def generateBadCharShift(term):
skipList = {}
for i in range(0, len(term)-1):
skipList[term[i]] = len(term)-i-1
return skipList
@ameerkat
ameerkat / sorts.py
Created December 7, 2010 15:04
Various sorts implemented in Python (Insertion, Bubble, Merge, Quick, Counting)
# BunchO Sorting Algorithms
# Ameer Ayoub <ameer.ayoub@gmail.com>
# Last Modified 12/2/2010
import random
#
# Insertion Sort
#
def insertion_sort(l):
"""Given an input list, returns a sorted permutation of the list
@ameerkat
ameerkat / order_statistics.py
Created December 10, 2010 21:04
Order statistics using randomized pivot
# Order Statistics
# Ameer Ayoub <ameer.ayoub@gmail.com>
import random, copy
# From quicksort
# Nonrandomized Pivot
def partition(l, p, q, pivot=None):
r = copy.copy(l)
if pivot:
r[pivot], r[p] = r[p], r[pivot]
@medecau
medecau / opcp.md
Last active March 7, 2024 18:11
Online Programming Contests and Puzzles
@bzerangue
bzerangue / google-weather-api-conditions.xml
Created February 1, 2011 23:13
Google Weather API Conditions List
<?xml version="1.0" encoding="UTF-8"?>
<!--Google Weather API Conditions. Compiled by Dennis Delimarsky, http://dennisdel.com/content/conditions.xml-->
<!--Tweaked by Brian Zerangue, February 1, 2011-->
<conditions>
<type handle="partly-sunny">Partly Sunny</type>
<type handle="scattered-thunderstorms">Scattered Thunderstorms</type>
<type handle="showers">Showers</type>
<type handle="scattered-showers">Scattered Showers</type>
<type handle="rain-and-snow">Rain and Snow</type>
<type handle="overcast">Overcast</type>
@ameerkat
ameerkat / euler39optimized.py
Created April 5, 2011 04:28
Fully optimized euler #39!
from fractions import gcd
def euler39optimized():
sum_count = [0] * 1001
y = 2
while y**2 <= 500:
for z in [x for x in range(y) if gcd(y, x) == 1]:
a = y**2 - z**2
b = 2*y*z
c = y**2 + z**2
@jeresig
jeresig / .vimrc
Created May 4, 2011 16:46
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on
@ameerkat
ameerkat / inc_v_num.py
Created May 19, 2011 01:20
Increment version number in drupal module info file
# increment_version_num.py
# Utility to incremement version number in drupal info files
# Ameer Ayoub <ameer.ayoub@gmail.com>
import re, sys, os
major_v = 0
minor_v = 0
def inc_dv_num(s, minor = True):
global major_v, minor_v
@ameerkat
ameerkat / fib3.cpp
Created June 14, 2011 21:39
Calculating Fibonacci numbers with matrices
/* Fibonacci Calculation using Matrices
* Ameer Ayoub <ameer.ayoub@gmail.com>
* Jun 13, 2011
*/
#include <iostream>
#include <math.h>
using namespace std;
const int fib_matrix_size = 2;