Skip to content

Instantly share code, notes, and snippets.

View dgerlanc's full-sized avatar

Dan Gerlanc dgerlanc

View GitHub Profile
@dgerlanc
dgerlanc / gccemacs.md
Created August 6, 2020 13:13 — forked from AllenDang/gccemacs.md
Build gccemacs on MacOS catalina with gcc 10 installed by homebrew.

Build gccemacs on MacOS catalina

It's a hard time to make gccemacs work on MacOS catalina. I've met countless problems by following every tutorials I can get from google. Fortunately I finally get it work!

Hope this tutorial could help you.

GCC with libgccjit enabled

cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula

Edit gcc.rb like this

@dgerlanc
dgerlanc / test-env
Created September 30, 2019 18:19
Test Environment
name: test-env
channels:
- defaults
dependencies:
- python=3.7.*
- pyarrow
- requests
# Convert coordinates to integers to calculate frequencies
# Multiply by 1e5 b/c coordinates have 5 decimal digits
int_coords = gt[, lapply(.(lat=lat, long=long), function(x) as.integer(x * 1e5))]
coord_n = int_coords[, .(freq=.N), by=.(lat, long)]
coord_n[, lat:=lat / 1e5]
coord_n[, long:=long / 1e5]
coord_n_gt9 <- coord_n[freq > 9,]
p <- ggplot() +
geom_polygon(data=all_states, aes(x=long, y=lat, group=group),
color="grey60", fill="white") +
geom_point(data=coord_n_gt9, aes(x=long, y=lat, size=freq),
color="#A60000", fill="#FF7373", pch=21, alpha=0.25) +
xlim(min(all_states$long), max(all_states$long)) +
ylim(min(all_states$lat), max(all_states$lat)) +
scale_size_continuous(breaks=c(50,100,500,1000,2500,7000),
trans="sqrt", range=c(1,10), name="Count") +
@dgerlanc
dgerlanc / themed-ggplot2-map.R
Created July 3, 2018 21:08
4th Plot in Github Map post.
blank_theme <- function() {
theme(
axis.line=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
library(ggplot2)
all_states <- map_data("state")
p = ggplot()
p = p + geom_polygon(data=all_states, aes(x=long, y=lat, group = group), fill="white")
p = p + geom_point(data=coord_n, aes(x=long, y=lat, size=freq), pch=21, size=pt_scale, alpha=1/2)
p = p + xlim(min(all_states$long), max(all_states$long)) +
ylim(min(all_states$lat), max(all_states$lat))
print(p)
@dgerlanc
dgerlanc / use-mapdata.R
Last active June 28, 2018 00:02
Simple US map with state borders and capitals
library(mapdata)
data(us.cities)
map("state", col="gray90", fill=TRUE, lwd=0.1, mar=c(0,0,0,0), xlim=c(-127,-65))
map("worldHires", "Canada", xlim=c(-127,-110), ylim=c(48,64), col="gray95", fill=TRUE, add=TRUE)
map("worldHires","Mexico", xlim=c(-127,-110), ylim=c(28,45), col="gray95", fill=TRUE, add=TRUE)
points(gt$long, gt$lat, cex=pt_scale, pch=19, col=MAP_BLACK)
map.cities(us.cities, minpop=5e5, label=TRUE, pch=19, col='red')
title("Locations of Github Users", line=1)
@dgerlanc
dgerlanc / simple-map-of-usa.R
Last active June 28, 2018 00:00
Built in map of the USA
library(maps)
pt_scale = 0.1
map("usa", col="gray95", fill=TRUE, boundary=TRUE, mar=c(0,0,0,0))
points(gt$long, gt$lat, pch=19, cex=pt_scale, col=rgb(0, 0, 0, alpha=0.75))

Keybase proof

I hereby claim:

  • I am dgerlanc on github.
  • I am dgerlanc (https://keybase.io/dgerlanc) on keybase.
  • I have a public key ASAWW156vzCkP9v8AGpT9O57uU9qGaBqDMgyMUDIqmjcxgo

To claim this, I am signing this object:

@dgerlanc
dgerlanc / get-wiki-coordinates.rb
Created March 28, 2018 22:47
Heuristic using Wikipedia search to map locations to geographical coordinates
require 'nokogiri'
require 'net/http'
require 'csv'
@log = File.new("logs/geo-#{Time.now.to_s}.log", 'w+')
@wrong = File.new("logs/unparsed_geo-#{Time.now.to_s}.log", 'w+')
def get_coordinates(location_string)
search_url = "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&profile=default&search=#{URI.escape(location_string)}&fulltext=Search"
uri = URI.parse search_url