Skip to content

Instantly share code, notes, and snippets.

View stevepowell99's full-sized avatar

Stephen Powell stevepowell99

View GitHub Profile
@stevepowell99
stevepowell99 / cm3functions.R
Created October 8, 2023 18:52
Causal Map 3 Functions
# These are all the main Causal Map 3 functions except for the NLP functions which are in a separate file.
# constants -----------------------------------------------------------------
contrary_color <- "#f2ab73"
ordinary_color <- "#058488"
# helpers -----------------------------------------------------------------
@stevepowell99
stevepowell99 / extractAnnotations.py
Last active December 20, 2021 21:03
Extracts annotations and highlighted passages in all .pdf files in a folder recursively and outputs them as text files with the same name and modification date
#!/usr/bin/env python
# see http://socialdatablog.com/extract-pdf-annotations.html
myxkfolder="/home/steve/xk/" #you need to set this to where you want your to-dos to appear
import poppler, os.path, os, time, datetime
for root, dirs, files in os.walk('./'):
for lpath in files:
@stevepowell99
stevepowell99 / gist:8c5d59d3d1af13a3c1693f2358314e25
Created November 13, 2019 12:55
heatmaps for UNICEF ECARO
library(tidyverse)
library(readxl)
suppressMessages(library(dendextend))
library(d3heatmap)
data <- readxl::read_excel("Data.xlsx",range="A3:CU24",na="NK")
mat=data %>% select(-(1:3))
rownames(mat) <- data[1:21,1]
mat2 <- mat %>%
@stevepowell99
stevepowell99 / DiagrammeRanimate.r
Last active August 9, 2018 10:09
Hack to animate a series of DiagrammeR graphs.
# Animation not yet possible natively in DiagrammeR: https://github.com/rich-iannone/DiagrammeR/issues/8
# so this simple hack for Shiny is based on https://stackoverflow.com/questions/27194893/reset-animation-in-shiny-r-studio#27224900
library(shiny)
library(DiagrammeRsvg)
library(DiagrammeR)
ui <- (fluidPage(
# Application title
headerPanel("Diagrammer Animation"),
@stevepowell99
stevepowell99 / rfeed.xml
Last active May 16, 2016 09:03
Rss feed for tagged posts on blot.im; see http://stevepowell.blot.im/rfeed
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>{{title}}</title>
<link>{{blogURL}}</link>
<description>The feed of updates on R to {{name}}'s blog.</description>
<updated>{{updated}}</updated>
<id>{{blogURL}}</id>
<author>
<name>{{name}}</name>
@stevepowell99
stevepowell99 / extractDivs.py
Created January 29, 2015 07:52
Goes through a pelican output folder and extracts just the article divs.
#!/usr/bin/env python
import poppler, os.path, os, time, datetime
from bs4 import BeautifulSoup
g = open("./output/all.html","w")
x=""