Skip to content

Instantly share code, notes, and snippets.

View Sharpie's full-sized avatar

Charlie Sharpsteen Sharpie

View GitHub Profile
@Sharpie
Sharpie / .vimrc
Created January 27, 2010 01:24
A vim profile file designed for editing Fortran source code
" Ensure correct syntax highlighting and auto-indentation for Fortran free-form
" source code.
let fortran_free_source=1
let fortran_do_enddo=1
filetype plugin indent on
syntax on
" Turn on line numbers and row/column numbers.
set nu
@Sharpie
Sharpie / grainAnalysis.R
Created January 31, 2010 17:44
R code related to graphical analysis of a sieved soil sample.
# Load Data
grainData <- read.csv('grainSize.csv', check.names=F, na.strings='--' )
# Calculate Derived Sample Values
grainData[['Phi Diameter']] <- -log2( grainData[['Grain Diameter']] )
totalWeight <- sum( grainData[['Sample Weight']] )
grainData[["Percent Retained"]] <- grainData[['Sample Weight']] / totalWeight
grainData[["Cumulative Percent"]] <- cumsum( grainData[["Percent Retained"]] )
grainData[['Percent Finer']] <- 1 - grainData[['Cumulative Percent']]
@Sharpie
Sharpie / mRunif.c
Created March 6, 2010 04:44
An example of calling R functions from C
//myRunif.c
#include <R.h>
#include <Rinternals.h>
SEXP myRunif( SEXP n, SEXP min, SEXP max ){
SEXP statsPackage;
PROTECT(
statsPackage = eval( lang2( install("getNamespace"),
ScalarString(mkChar("stats")) ),
@Sharpie
Sharpie / procTest.f90
Created March 30, 2010 13:46
Demonstration of using Fortran 2003 procedure pointers
program procTest
implicit none
integer :: n
interface
function forced()
integer:: forced
end function forced
@Sharpie
Sharpie / qgisMovePoint.py
Created June 13, 2010 01:10
Function to allow editing of QGIS point coordinates via the Python console.
# Arrgh... QGIS doesn't appear to have a way of editing the coordinates of a point. Only input via CSV
# files. This is the way to go for large numbers of coordinates but it just plain sucks balls for
# dealing with a handful of points. I don't know much about the guts of QGIS so I can't submit a formal
# fix, but it does have a python interpreter...
# Based on code given in this post by Carson Farmer:
#
# http://www.mail-archive.com/qgis-user@lists.osgeo.org/msg01446.html
#
# Date: 11/04/2008
@Sharpie
Sharpie / shortCite.bib
Created July 26, 2010 21:32
Example showing how to use natbib's \defcitealias to shorten or alter BibTeX citations.
@techreport{caltrans2002,
Author = {{California Department of Transportation}},
Title = {{Humboldt Bay Bridges Seismic Substructure Retrofit Environmental Assessment/Finding of No Significant Impact (EA/FONSI)}},
Year = {2002}}
@Sharpie
Sharpie / inlineNode.tex
Created August 6, 2010 21:07
Example showing various styles of relative positioning with TikZ.
\documentclass{minimal}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\begin{document}
@Sharpie
Sharpie / tooltip.tex
Created January 14, 2011 21:18
TeX Code for making tooltips
% Decoding the PDF primitives used by these functions is somewhat possible with
% the help of the PDF spec:
%
% http://www.adobe.com/devnet/pdf/pdf_reference.html
%
% Attempt #1
% Adapted from a post by Herbert Voss on comp.text.tex:
%
% https://groups.google.com/d/msg/comp.text.tex/hjYT89EzN_E/MWXw1eksMhkJ
@Sharpie
Sharpie / console.py
Created February 9, 2011 05:08
Main application for a pure PyQGIS app running an IPython console
"""
/***************************************************************************
ipythonDialog
A QGIS plugin
An enhanced QGIS console powered by IPython
-------------------
begin : 2011-02-06
copyright : (C) 2011 by Charlie Sharpsteen
email : source@sharpsteen.net
***************************************************************************/
@Sharpie
Sharpie / permutations.R
Created February 17, 2011 21:18
Lazy permutations
require(itertools)
permutations <- function(iterable) {
# Returns permutations of iterable. Based on code given in the documentation
# of the `permutation` function in the Python itertools module:
# http://docs.python.org/library/itertools.html#itertools.permutations
n <- length(iterable)
indicies <- seq(n)
cycles <- rev(indicies)
stop_iteration <- FALSE