Skip to content

Instantly share code, notes, and snippets.

View humanfactors's full-sized avatar
🏳️‍⚧️

Micah K. Wilson humanfactors

🏳️‍⚧️
View GitHub Profile
@humanfactors
humanfactors / gist:9a054984a4147a6c192dc0da28b675c1
Created February 11, 2021 07:46
ggplot2 frequency plot label woes
library(ggplot2)
mydata = structure(list(estimate = c(cor = 0.325795456913319, cor = 0.562197877060912,
cor = 0.440719760612754, cor = -0.0936850084700603, cor = 0.0360156238340214,
cor = 0.290449045144756, cor = 0.351442182968952, cor = 0.282652330413659,
cor = 0.484382008605981, cor = 0.555190439953125, cor = 0.153963602626727,
cor = 0.389799442186418, cor = 0.102658050525012, cor = 0.539213427685732,
cor = 0.599952880067505, cor = 0.353135730646411, cor = 0.5459587711875,
@humanfactors
humanfactors / kards_convert.R
Last active February 3, 2021 12:34
Kards Resource Converter ready for Feb 10th! Check what wildcards you'll get!
convert_table = data.frame(
stringsAsFactors = FALSE,
type = c("Standard", "Limited", "Special", "Elite"),
Resources = c(4L, 10L, 40L, 160L),
Amount = c(3, 3, 3, 1)
)
# 3 x Standard -> 3 x Limited -> 3 x Standard -> 3 x Limited -> 3 x Special -> 1 x Elite
order = unlist(list(rep("Standard",3),rep("Limited",3),rep("Standard",3),rep("Limited",3),rep("Special",3),"Elite"))
@humanfactors
humanfactors / upgrade_packages.R
Created July 14, 2020 14:06 — forked from bearloga/upgrade_packages.R
The script can be used to re-install packages after upgrading R (on Linux or Mac), since libraries cannot be reused between different minor versions (e.g. when upgrading 3.2.3 to 3.3.2). It detects when a package was installed from CRAN vs GitHub/Git and re-installs it using the appropriate func. Usage: `Rscript upgrade_packages.R`
# WMF only:
if (file.exists("/etc/wikimedia-cluster")) {
message('Detected that this script is being run on a WMF machine ("', Sys.info()["nodename"], '"). Setting proxies...')
Sys.setenv("http_proxy" = "http://webproxy.eqiad.wmnet:8080")
Sys.setenv("https_proxy" = "http://webproxy.eqiad.wmnet:8080")
}
# General use:
message("Checking for a personal library...")
if (!dir.exists(Sys.getenv("R_LIBS_USER"))) {
@humanfactors
humanfactors / borderless.ahk
Created May 29, 2020 14:19 — forked from kchat001/borderless.ahk
An AutoHotKey Script that allows to toggle the window title and the border chrome of the current window independently (Ctrl+Win+t and Ctrl+Win+b)
#SingleInstance, force
#NoEnv
; Borderless Window - AutoHotkey Script
; The script toggles the window border and title bar of the current window independently
; The hotkey is Control+Win+t. It applies changes to whatever window has focus.
^#t::
WinGetTitle, currentWindow, A
IfWinExist %currentWindow%
@humanfactors
humanfactors / unicode.ahk
Created December 11, 2019 07:42 — forked from kbauer/unicode.ahk
Autohotkey-script for converting LaTeX-like input to unicode characters. "Ctrl+Alt+Shift+U" toggles it on and off.
;; -*- mode: text; coding: utf-8 -*-
;;
;; DO NOT EDIT MANUALLY!
;;
;; FILE IS GENERATED BY EMACS LISP SCRIPT
;; `%((file-name-nondirectory qta-ahkdata:generator-script-file)%)'
;;
;;
;; Writing LaTeX glyphs with
;; AutoHotKey (unicode versions only)
@humanfactors
humanfactors / quicknav-keybinds.el
Created May 27, 2018 09:52
Quick navigation in Spacemacs, with a quick open in system viewer.
(defmacro when-system (type &rest body)
"Evaluate BODY if `system-type' equals TYPE."
(declare (indent defun))
`(when (eq system-type ',type)
,@body))
(defun open-directory-in-system-viewer ()
(interactive)
@humanfactors
humanfactors / web-servers.md
Created February 26, 2018 15:52 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@humanfactors
humanfactors / minimal-template.tex
Created February 20, 2018 16:35 — forked from Michael0x2a/minimal-template.tex
Minimal LaTeX template
\documentclass{article}
% General document formatting
\usepackage[margin=0.7in]{geometry}
\usepackage[parfill]{parskip}
\usepackage[utf8]{inputenc}
% Related to math
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\begin{document}
@humanfactors
humanfactors / plot_aligned_series.R
Created February 19, 2018 05:50 — forked from tomhopper/plot_aligned_series.R
Align multiple ggplot2 graphs with a common x axis and different y axes, each with different y-axis labels.
#' When plotting multiple data series that share a common x axis but different y axes,
#' we can just plot each graph separately. This suffers from the drawback that the shared axis will typically
#' not align across graphs due to different plot margins.
#' One easy solution is to reshape2::melt() the data and use ggplot2's facet_grid() mapping. However, there is
#' no way to label individual y axes.
#' facet_grid() and facet_wrap() were designed to plot small multiples, where both x- and y-axis ranges are
#' shared acros all plots in the facetting. While the facet_ calls allow us to use different scales with
#' the \code{scales = "free"} argument, they should not be used this way.
#' A more robust approach is to the grid package grid.draw(), rbind() and ggplotGrob() to create a grid of
#' individual plots where the plot axes are properly aligned within the grid.
ip a | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'