Skip to content

Instantly share code, notes, and snippets.

View mpadge's full-sized avatar
🤹‍♀️
Coding away ...

mark padgham mpadge

🤹‍♀️
Coding away ...
View GitHub Profile
@jackrusher
jackrusher / gist:5139396
Last active November 13, 2024 21:08
Hofstadter on Lisp: Atoms and Lists, re-printed in Metamagical Themas.

Hofstadter on Lisp

In the mid-80s, while reading through my roommate's collection of Scientific American back issues, I encountered this introduction to Lisp written by Douglas Hofstadter. I found it very charming at the time, and provide it here (somewhat illegally) for the edification of a new generation of Lispers.

In a testament to the timelessness of Lisp, you can still run all the examples below in emacs if you install these aliases:

(defalias 'plus #'+)
(defalias 'quotient #'/)
(defalias 'times #'*)
(defalias 'difference #'-)
@amcgregor
amcgregor / _laws.md
Last active February 3, 2022 22:42
Alice's Laws

Alice's Laws

  1. You can only count on yourself.
  2. Never reveal more than you have to.
  3. Execution is nine-tenths of the job.
  4. Give credit where credit is due.
  5. When all else fails, do it yourself.
  6. 90% of a project takes 90% of the time.
  7. The remaining 10% takes an additional 90% of the time.
  8. Never date a co-worker.
@hrbrmstr
hrbrmstr / newpkg.sh
Created December 27, 2015 17:56
R package skeleton maker
#!/bin/bash
# AUTHOR: Bob Rudis <[email protected]> (@hrbrmstr)
# LICENSE: MIT + file zLICENSE
TODAY=`date +%Y-%m-%d`
TODAY_MD=`date +%B\ %d,\ %Y`
YEAR=`date +%Y`
PACKAGENAME=$1
library(silicate)
data("wrld_simpl", package = "maptools")
#edges are unique segments (undirected)
#segments are directed instances of edges, belonging to arcs/ways or feature boundaries
library(silicate)
library(sf)
x <- PATH(st_as_sf(wrld_simpl))
#x <- PATH(minimal_mesh)
@goldingn
goldingn / parallel_progress.R
Created April 14, 2018 00:50
prototype of parallel progress reporting (for processes on the same file system)
# progress information in parallel processes (that use the same filesystem)
# the master function sets up a tempfile for each process, spawns processes, and
# passes the corresponding tempfile location to each; each process dumps
# progress information into its tempfile; the master function polls those files
# for the progress information and returns it to the screen; the previous line
# is overwritten, as for progress bars
library (future)
# an environment to stash file info in, to hack around scoping issues. A package
@goldingn
goldingn / multiple_progress.R
Last active May 21, 2018 00:50
multiple progress bars on a single line, to be combined with parallel_progress.R
# plotting multiple progress bars on the same line, as a precursor to running
# the progress bars in parallel
library (progress)
library (future)
library (R6)
new_connection <- function () {
f <- tempfile()
file.create(f)
@beemyfriend
beemyfriend / latticeWObstacles.R
Created July 15, 2018 04:47
Exploring graph substructures with topological obstacles (missing nodes)
####
# Dependencies
####
library(tidyverse)
library(igraph)
####
# The pattern is to identify points to extend the structure of
@beemyfriend
beemyfriend / latticeWObstaclesTopology.R
Created July 16, 2018 01:54
Exploring graph substructures with topological obstacles (missing nodes) and node weights
library(tidyverse)
library(igraph)
####
# The pattern is to identify points to extend the structure of
# dyads and subsequent structures
# And make sure the extension isn't already part of the structure
####
@krlmlr
krlmlr / Rprofile-entrace
Last active January 7, 2021 01:59
Pretty stack traces in R
# Add this to your .Rprofile
options(
error = quote(rlang::entrace()),
rlang__backtrace_on_error = "collapse" # or "branch" or "full"
)
@lisawolderiksen
lisawolderiksen / git-commit-template.md
Last active November 11, 2024 09:31
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the