Skip to content

Instantly share code, notes, and snippets.

@zgfabian
zgfabian / company-pspp.el
Last active February 25, 2024 14:27
Emacs company-mode completion for pspp keywords
;; complete pspp commands and keywords
;; See GNU PSPP project at https://www.gnu.org/software/pspp/
;; slightly modified version of Austin Bingham's
;; https://sixty-north.com/blog/writing-the-simplest-emacs-company-mode-backend.html
(require 'company)
;; +
(set (make-local-variable 'font-lock-keywords-case-fold-search) t)
(defconst pspp-completions
'("ADD DOCUMENT"
"ADD"
@zgfabian
zgfabian / minimal-example.R
Last active August 2, 2021 02:19
Minimal example for local xaringan deployment
setwd(".")
dir.create("./lib")
## download remark.js /it can be good idea to pin a specific version to be future-proof/
xaringan::summon_remark(version = "0.14.1", to = "./lib/")
list.files("./lib/")
## file.create("minimal-example.rmd")
# file.edit("minimal-example.rmd") or download
url <- "https://raw.githubusercontent.com/ZGFabian/zgfabian.github.io/gh-pages/static/xaringan-prez/_minimal-example.rmd"
download.file(url = url, destfile = "minimal-example.rmd")
@zgfabian
zgfabian / minimal-example.rmd
Last active August 2, 2021 02:21
A minimal Rmarkdown example for xaringan presentation
---
title: "Xaringan minimal example"
author: "zgfabian"
output:
xaringan::moon_reader:
seal: true
css: [default, rutgers, rutgers-fonts]
lib_dir: ./lib
nature:
highlightLines: true
@zgfabian
zgfabian / eurostat-map.R
Created August 26, 2020 13:41
R script to create EU map for employment rate
# eurostat-map.R
# base code from: https://rstudio-pubs-static.s3.amazonaws.com/210495_a135718dda984805ada63d61bff87800.html
# (Markus Kainu Generated: 2016-09-19)
options(prompt = " ", continue = " ")
library(colorout)
library(eurostat)
library(dplyr)
library(ggplot2)
# library(stringr)
library(sf)
@zgfabian
zgfabian / owid-death.R
Last active August 17, 2020 20:04
These two scripts download covid-19 data from OWID and create a faceted ggplot2 charts for some selected countries
# COVID-19 death per million plots with custom theme
# Data source: https://ourworldindata.org/
library(tidyverse)
# library(ggthemes)
library(extrafont)
library(ggrepel)
# Create a new theme
theme_grey_b <- function(base_size = 10, base_famiy = "") {
theme_bw() %+replace%
theme(
@zgfabian
zgfabian / word_cloud_sapiens.R
Last active July 3, 2019 07:00
This is a simple R script that creates a word cloud. The example used here is Y. N. Harari's bestseller, Sapiens: A Brief History Of Humankind.
# Source of the codes used here with minor modifications:
# http://www.sthda.com/english/wiki/text-mining-and-word-cloud-fundamentals-in-r-5-simple-steps-you-should-know
# Install
# Note: "tm" package require that libxml2-dev should be installed on your linux system.
# install.packages("tm") # for text mining
# install.packages("wordcloud") # word-cloud generator
# install.packages("RColorBrewer") # color palettes
# install.packages("wesanderson") # for Wes Anderson color palettes
# Load
library("tm")
@zgfabian
zgfabian / pspp_run.sh
Last active December 12, 2015 07:39
Bash script to run PSPP. You can use it with Sublime-text-2 build command. It outputs to a html file named output$date.html in output subfolder. After successful build, output.html opened in default browser, otherwise returns pspp error message in a terminal window. Tested on Ubuntu 12.04.
#!/bin/sh
_now=$(date +"%m_%d_%Y_%T")
_file="output/output_$_now.html"
echo $_now
echo $_file
mkdir -p output
echo "Starting output to $_file..."
pspp $1 -o $_file && xdg-open $_file
if [ $? -eq 0 ]
then echo 'PSPP executed without errors. (This window will be closed in 10 sec.)'
@zgfabian
zgfabian / pspp.sublime-completions
Last active December 12, 2015 07:38
sublime text 2 completions for pspp
{
"scope": "source.pspp",
"completions":
[
{ "trigger": "f", "contents": "FREQUENCIES" },
{ "trigger": "des", "contents": "DESCRIPTIVES" },
{ "trigger": "mea", "contents": "MEANS" },
{ "trigger": "get", "contents": "GET FILE=" },
{ "trigger": "cro", "contents": "CROSSTABS" },
@zgfabian
zgfabian / pspp.JSON-tmLanguage
Last active December 10, 2015 12:38
GNU PSPP (and IBM SPSS) completion file for Sublime Text 2.
{ "comment": "GNU PSPP syntax version 0.1.0",
"name": "pspp",
"scopeName": "source.pspp",
"fileTypes": ["sps","SPS","out"],
"foldingStartMarker": "\\{\\s*$",
"foldingStopMarker": "^\\s*\\}",
"patterns": [
{ "name": "comment.block.pspp",
"begin": "^[\\d\\.\\s]*?\/\\*",
"end": "^[\\d\\.\\s]*?\\*\/"