Skip to content

Instantly share code, notes, and snippets.

@joeegan
joeegan / ps1a.py
Created April 13, 2011 23:55
1000th prime number
odd_numbers = [];
non_primes = [];
i = 1
while i <= 10000:
i = i + 2
odd_numbers.append(i)
print len(odd_numbers)
@joeegan
joeegan / py1b.py
Created April 18, 2011 21:36
py1b.py
from math import *
odd_numbers = [];
non_primes = [];
limit = 8000 # needs to be 8000 to calculate 1000th prime
i = 1
while i <= limit:
i = i + 2
@joeegan
joeegan / throwErrorIfJquerySelectorUndefined.js
Created April 21, 2011 16:26
throwErrorIfJquerySelectorUndefined.js
// anonymous func to avoid polluting global namespace, and $ conflict
(function($){
// throw error for undefined selectors
var jQueryInit = $.fn.init;
$.fn.init = function(selector, context, rootjQuery) {
var result = new jQueryInit(selector, context, rootjQuery);
if (result.length === 0)
throw "jQuery cannot find the following selector: '" + selector + "'";
return result;
@joeegan
joeegan / py1b2.py
Created April 22, 2011 22:43
py1b2.py
from math import *
def calculate_n_primes(n):
primes = []
prime_candidate = 1
global its_a_prime
its_a_prime = True
while len(primes) < (n + 1):
@joeegan
joeegan / jQueryCountdown.js
Created April 27, 2011 10:58
jQueryCountdown.js
$(function(){
var timeJq = $('span#time-js');
timeJq.countdown({
until: '+3h',
layout:'{d<}{dn} {dl} and {d>}'+'{hn} {hl}, {mn} {ml} and {sn} {sl}'
});
});
/* http://keith-wood.name/countdown.html
@joeegan
joeegan / gist:944332
Created April 27, 2011 14:25
formatted date
var date = new Date();
var minutes = date.getMinutes();
if (minutes < 10) {
minutes = "0" + minutes
}
date = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' ' + date.getHours() + ':' + minutes;
@joeegan
joeegan / gist:958733
Created May 6, 2011 10:26
downloadify
$('#downloadify').downloadify({
data: function(){
var topRowCsv = "MiC " + $('.events-title-js').text() + ",From,To,Location" + "\n";
function removeNewLineChars(str) {
return str.replace(/\r/g, "").replace(/\n/g, "");
}
@joeegan
joeegan / gist:966337
Created May 11, 2011 12:02
vimrc backup
" .vimrc Joe Egan 2009-07-27 2009-11-09 22:35:19
" BASIC
set nocompatible " remove old vim commands
set mouse=a " have the mouse enabled all the time:
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set lbr
set cursorline
set laststatus=2
Pbm.InfiniteScroll = {};
Pbm.InfiniteScroll.count = 0;
Pbm.InfiniteScroll.init = function (url, liSelector) {
var max = $.deparam.querystring(url).max;
var endpoint = url.slice(0, url.indexOf('?'));
function displaySpinner() {
var old = trigger.onclick;
trigger.onclick = function() {
if(old) old();
myFunc();
return false;
};