Skip to content

Instantly share code, notes, and snippets.

View kapadia's full-sized avatar
💭
eating a pecan bar

Amit Kapadia kapadia

💭
eating a pecan bar
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kapadia
kapadia / go.sh
Created December 11, 2014 23:48
Bash Error Handling
#!/bin/bash
# Use -e to exit the script as soon as anything returns non-zero
set -eou pipefail
function usage() {
echo ""
echo "Template script for bash error handling."
echo ""
import rasterio
with rasterio.open('input.tif') as src:
source = src.read_band(1)
def window_transform(transform, offset):
result = transform[:]
result[3] = transform[3] + offset[0]*transform[5]
result[0] = transform[0] + offset[1]*transform[1]
return result
@minrk
minrk / nbstripout
Last active June 6, 2023 06:23
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@kwmsmith
kwmsmith / pairwise_cython.pyx
Last active August 12, 2022 04:25
Numba vs. Cython: Parallel Cython with OMP
#cython:boundscheck=False
#cython:wraparound=False
import numpy as np
from cython.parallel cimport prange
from libc.math cimport sqrt
cdef inline double dotp(int i, int j, int N, double[:, ::1] X) nogil:
cdef:
int k
@return1
return1 / gist:5059418
Created February 28, 2013 19:36
S3/Cloudfront CORS (Cross-Origin Resource Sharing) Configuration for Webfonts in Firefox. make sure to redistribute Cloudfront after applying this config to the S3 bucket. Also you should restrict the origin to you domain, just to be safe.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Content-*</AllowedHeader>
<AllowedHeader>Host</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@ZJONSSON
ZJONSSON / index.html
Created August 1, 2012 19:06 — forked from syntagmatic/index.html
Scatterplot (WebGL-2D)
<!doctype html>
<link rel="stylesheet" type="text/css" href="style.css" />
<h1>Nutrient Scatterplot (WebGL-2D)</h1>
<canvas id="chart"></canvas>
<div id="controls">
<span id="hover-food"></span><br/>
X axis <select id="xaxis"></select><br/>
Y axis <select id="yaxis"></select><br/>
@sgillies
sgillies / pipelinedemo.py
Created September 21, 2011 18:14
Data processing pipeline demo
# pipelinedemo.py
# Data processing pipeline demo
from json import dumps
import logging
def coroutine(func):
"""Used as a decorator, advances a generator to active it"""
def start(*args,**kwargs):
cr = func(*args,**kwargs)
@lucasallan
lucasallan / install_postgis_osx.sh
Created September 6, 2011 21:03 — forked from klebervirgilio/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@netj
netj / memusg
Last active January 29, 2024 15:04
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #