Skip to content

Instantly share code, notes, and snippets.

View wpbonelli's full-sized avatar

wpbonelli

  • UCAR / @usgs
  • 22:27 (UTC -04:00)
View GitHub Profile
@jagregory
jagregory / gist:710671
Created November 22, 2010 21:01
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork git@github...my-fork.git
@audy
audy / shannon.py
Created January 17, 2011 17:28
Shannon Diversity Index
#!/usr/bin/env python
# Shannon Diversity Index
# http://en.wikipedia.org/wiki/Shannon_index
import sys
def sdi(data):
""" Given a hash { 'species': count } , returns the SDI
@igniteflow
igniteflow / git_python_current_branch.py
Created February 7, 2012 17:33
GitPython get current active branch
"""
Gets the name of the active Git branch as a string.
Depends on GitPython
pip install GitPython
"""
from git import Repo
repo = Repo('/path/to/your/repo')
branch = repo.active_branch

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@ZedThree
ZedThree / fortran-dot-graph.py
Last active February 2, 2023 21:15
Build a dot graph of the Fortran modules in a list of files.
import re
def build_graph(files,exclude=['hdf5','h5lt','mpi']):
"""Build a dot graph of the Fortran modules in a list of files,
excluding modules named in the list exclude"""
# Start the graph
graph = "digraph G {\n"
deps = {}
p = re.compile("^(?:module|program) ([a-zA-Z0-9_]*)",
@mgold
mgold / README.md
Last active August 28, 2021 19:20
Spherical Coordinates

Grab the brown and black knobs. You can also dial some of the numbers on the right.

Spherical coordinates are defined by ρ (rho, the distance from the origin), θ (theta, rotation parallel to the xy-plane), and φ (phi, inclination from the north pole to the south pole). This interactive drawing shows how they relate to the Cartesian xyz coordinates. The key is the horizontal slice of radius r.

  • z = ρ cos φ
  • r = ρ sin φ

Which makes sense: when φ=0, we're looking at the north pole, z=ρ and r=0. Then we're left with the familiar equations:

  • x = r cos θ
@olih
olih / jq-cheetsheet.md
Last active July 16, 2024 23:02
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@elnygren
elnygren / expression_problem.clj
Last active December 3, 2022 16:33
Solving the Expression Problem with Clojure
; The Expression Problem and my sources:
; http://stackoverflow.com/questions/3596366/what-is-the-expression-problem
; http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/
; http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/
; http://www.ibm.com/developerworks/library/j-clojure-protocols/
; To begin demonstrating the problem, we first need some
; "legacy code" with datastructures and functionality:
@ryanmaclean
ryanmaclean / check_docker_tag.sh
Created September 29, 2016 18:05
Check if Docker Image with Tag Exists
#!/bin/bash
# This script will check to see if a Docker image exists for a specific tag.
# Taken from here, with love: https://www.reddit.com/r/docker/comments/4hwdma/check_if_an_image_tag_for_a_private_repo_exists/
TOKEN=$( curl -sSLd "username=${DOCKER_HUB_USERNAME}&password=${DOCKER_HUB_PASSWORD}" https://hub.docker.com/v2/users/login | jq -r ".token" )
curl -sH "Authorization: JWT $TOKEN" "https://hub.docker.com/v2/repositories/${DOCKER_REPO}/tags/${DOCKER_TAG}/" | jq .
#{
# "name": "latest",
# "id": 780668,
@chrisdone
chrisdone / expression_problem.hs
Created November 2, 2016 11:34 — forked from elnygren/expression_problem.clj
Solving the Expression Problem with Haskell
{-# LANGUAGE NamedFieldPuns #-}
-- The Expression Problem and my sources:
-- http://stackoverflow.com/questions/3596366/what-is-the-expression-problem
-- http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/
-- http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/
-- http://www.ibm.com/developerworks/library/j-clojure-protocols/
-- To begin demonstrating the problem, we first need some