Skip to content

Instantly share code, notes, and snippets.

View ctbarna's full-sized avatar

Chris Barna ctbarna

View GitHub Profile

Installing PARI/GP on Mac

Prerequisites

  • Apple Developer Tools
    • Note: this is like 2GB. You might be better off simply installing the gcc compiler from here. I actually have no idea if this will work but if somebody is brave enough to try, that'd be awesome.
  • Slight knowledge of the command line (or at least a little bravery and some faith).
# Shell script to install PARI/GP
VERSION=2.5.0
URL=http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-$VERSION.tar.gz
DATE=`date +%s`
# Credit to http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
DIR="$( cd "$( dirname "$0" )" && pwd )"
mkdir $DIR/tmp$DATE
cd $DIR/tmp$DATE
@ctbarna
ctbarna / amazon.rb
Created August 30, 2011 20:41
A little script I wrote to download images from Amazon.
# Download book covers from Amazon.
# Requires asin gem.
require 'net/http'
require 'asin'
client = ASIN::Client.instance
# Images Folder
IMG_DIR = ""
# API credentials
@ctbarna
ctbarna / fdny_response_time.rb
Created August 22, 2011 17:05
Parse FDNY response time.
# Parse the FDNY average response time into JSON.
require 'rubygems'
require 'csv'
require 'json'
FILE = '../../Data/FDNY_monthly_response_time_001.TXT'
# Read the data
data = CSV.read(FILE, :col_sep => "\t",
:headers => true, :write_headers => false)
@ctbarna
ctbarna / ga-ext.js
Created April 27, 2011 18:07
Track External Links with Google Analytics
var gaParentDiv = ""; // Only change links in this selector including trailing space.
var trackingBase = "/ext/";
$(parentDiv+"a[href^=http\\:\\/\\/]:not(a[href*=\\/"+document.domain+"])").click(function () {
pageTracker._trackPageview(trackingBase+$(this).attr("href"));
});
@ctbarna
ctbarna / conditionally-load-jquery.js
Created April 13, 2011 18:22 — forked from benbalter/conditionally-load-jquery.js
Conditionally load jQuery (with slight version independence). Not expecting the API to change a whole lot in the sub-versions.
//Conditionally load jQuery
//inspired by http://www.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/
window.onload = function () {
if (typeof jQuery == 'undefined') {
var jQ = document.createElement('script');
jQ.type = 'text/javascript';
jQ.onload = jQ.onreadystatechange = myOnLoadEvent;
jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js';
document.body.appendChild(jQ);
@ctbarna
ctbarna / rotator.js
Created April 6, 2011 18:10
A simple image rotator I wrote because I don't have admin access in CommonSpot. Images are grabbed from the srcID selector in a custom page then rotated through targetDiv on a target page depending on the day of the year. Functionality is kind of hacky be
/**
* rotator.js
* @author Chris Barna <chris@unbrain.net>
* Rotate images based on the date.
**/
// Variables
var url = "rotation.cfm";
var srcID = "#cs_control_9951781";
var customPanelDivs = new Array("#cs_control_9963945", "#cs_control_9963960");