Skip to content

Instantly share code, notes, and snippets.

View alexland's full-sized avatar

doug ybarbo alexland

View GitHub Profile
@ghoseb
ghoseb / factorial.py
Created November 14, 2008 18:58
The evolution of a Python Programmer
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@tzuryby
tzuryby / hash32.py
Created March 29, 2011 04:33
32bit hash function for python
hash32 = lambda value: hash(value) & 0xffffffff
@iurisilvio
iurisilvio / fib.py
Created October 3, 2011 17:36
Python Fibonacci Q-Matrix
fibs = {0: 0, 1: 1}
def _fib(n):
if n in fibs: return fibs[n]
if n % 2 == 0:
fibs[n] = ((2 * fib((n / 2) - 1)) + fib(n / 2)) * fib(n / 2)
return fibs[n]
else:
fibs[n] = (fib((n - 1) / 2) ** 2) + (fib((n+1) / 2) ** 2)
return fibs[n]
@alvinj
alvinj / sbtmkdirs.sh
Last active January 24, 2024 19:39
A shell script to create an SBT project directory structure
#!/bin/bash
#------------------------------------------------------------------------------
# Name: sbtmkdirs
# Version: 1.5
# Purpose: Create an SBT project directory structure with a few simple options.
# Author: Alvin Alexander, http://alvinalexander.com
# License: Creative Commons Attribution-ShareAlike 2.5 Generic
# http://creativecommons.org/licenses/by-sa/2.5/
#------------------------------------------------------------------------------
@alwerner
alwerner / retroactively add items to .gitignore
Last active March 21, 2022 23:14
retroactively add items to .gitignore
// make change to .gitignore
git rm --cached <filename>
// or, for all files
git rm -r --cached .
git add .
// then
@benbalter
benbalter / geojson-conversion.sh
Last active April 23, 2024 13:16
Bulk convert shapefiles to geojson using ogr2ogr
# Bulk convert shapefiles to geojson using ogr2ogr
# For more information, see http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/
# Note: Assumes you're in a folder with one or more zip files containing shape files
# and Outputs as geojson with the crs:84 SRS (for use on GitHub or elsewhere)
#geojson conversion
function shp2geojson() {
ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp"
}
@kerryrodden
kerryrodden / .block
Last active April 22, 2024 19:24
Sequences sunburst
license: apache-2.0
@Kartones
Kartones / postgres-cheatsheet.md
Last active June 18, 2024 15:09
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@JuPfu
JuPfu / CSVParboiledParser.scala
Last active October 29, 2015 07:20
A Scala Parboiled2 Grammar for CSV
/*
* Copyright (C) 2014 Juergen Pfundt
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package operator
object Functional {
class PipedObject[T] private[Functional] (value:T)
{
def |>[R] (f : T => R) = f(this.value)
}
implicit def toPiped[T] (value:T) = new PipedObject[T](value)
}