Skip to content

Instantly share code, notes, and snippets.

require 'date'
Date.new(2019,10,1).upto(Date.today) do |date|
d = date.strftime("%y%m%d")
url = "https://fsapps.fiscal.treasury.gov/dts/files/#{d}00.xlsx"
unless File.exist? "data/#{d}.xlsx"
cmd = "curl '#{url}' --output data/#{d}.xlsx"
p cmd
`#{cmd}`
end
use std::process::{Command, Output};
// Struct to represent a system process
pub struct SystemProcess {
// The process itself
pub process: Command,
// The output of the process, if it has been run
pub output: Option<Output>,
}
@mrcsparker
mrcsparker / inline-rust.py
Created May 7, 2023 01:35
Inline Rust for Python.
"""inline-rust.
Based on https://gist.github.com/adamnew123456/12546e6e36607a63e254
Works with integers out-of-the-box. Other types not so much without work.
"""
import ctypes
import tempfile
import os
require 'stupidedi'
require 'nokogiri'
require 'pp'
class Gen
def run(name, guide)
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml['medi'].edimap("xmlns:medi" => "http://www.milyn.org/schema/edi-message-mapping-1.6.xsd") {
xml['medi'].description('name' => guide.name, 'version' => 1.0)

Sample R Code

Load movie data

# Load dplyr
library(dplyr)

# Load ggplot2
library(ggplot2)
@mrcsparker
mrcsparker / alchemy.ex
Created September 21, 2016 01:50
Alchemy API for Elixir
defmodule Foo.Alchemy do
use HTTPoison.Base
def process_url(url) do
URI.encode(Application.get_env(:foo, :alchemy_url) <> url)
end
def request(url, text) do
querystring = params(text) |> to_querystring
case post(url, querystring, headers) do
@mrcsparker
mrcsparker / script.js
Created September 1, 2016 02:34
AB Solutions - This House Has People In It
$(document).ready(function() {
/**
* @return {undefined}
*/
function val() {
$("input").val(function() {
return this.value.toLowerCase();
});
}
/**
##
# <p>Represents a point on the surface of a sphere. (The Earth is almost
# spherical.)</p>
#
# <p>To create an instance, call one of the static methods fromDegrees() or
# fromRadians().</p>
#
# <p>This code was originally published at
# <a href="http://JanMatuschek.de/LatitudeLongitudeBoundingCoordinates#Java">
# http://JanMatuschek.de/LatitudeLongitudeBoundingCoordinates#Java</a>.</p>
#!/bin/bash
# split-vpn
# patches junos pulse connections connections to allow split tunnelling
# relaunch with sudo if we aren't root
if [[ $EUID -ne 0 ]]; then
echo "$0: relaunching as sudo $0"
sudo "$0" $@
exit $?
@mrcsparker
mrcsparker / R.md
Last active November 13, 2015 15:03
R in 10 minutes

Sample R Code

# Filtering data sets
install.packages("dplyr")

# Visualizing data sets
install.packages("ggplot2")

# Clean up data sets