Skip to content

Instantly share code, notes, and snippets.

View sivartravis's full-sized avatar

Travis Taylor sivartravis

  • Cambridge, MA
View GitHub Profile
@nickkraakman
nickkraakman / iEDGAR
Created November 12, 2014 11:15
Get XML response of SEC EDGAR filing URLs using the iEDGAR API
<?php
function getURLs($ticker){
$content = file_get_content("https://www.valuespreadsheet.com/iedgar/results.php?stock=".$ticker."&output=xml");
$xml = simplexml_load_string($content);
echo "<pre>"; print_r($xml); echo "</pre>";
}
library(ggplot2);
library(grid);
data(iris)
x <- jitter(iris[,c('Sepal.Length')])
y <- jitter(iris[,c('Sepal.Width')])
z <- factor(iris[,c('Species')])
# The color blind palette without black:
@jeromyanglim
jeromyanglim / 3catggplot2.r
Created May 3, 2012 12:10
plot with three categorical variables and one continuous variable using ggplot2
#http://jeromyanglim.blogspot.com.au/2012/05/how-to-plot-three-categorical-variables.html
library(ggplot2)
# Create some data
set.seed(4444)
Data <- expand.grid(group=c("Apples", "Bananas", "Carrots", "Durians", "Eggplants"),
year=c("2000", "2001", "2002"),
quality=c("Grade A", "Grade B", "Grade C", "Grade D", "Grade E"))
Group.Weight <- data.frame(
group=c("Apples", "Bananas", "Carrots", "Durians", "Eggplants"),
@alexkingorg
alexkingorg / wp-stats.php
Created January 3, 2012 04:28
WordPress per-year blog stats
<?php
header('Content-type: text/plain');
global $wpdb;
?>
<table class="numbers">
<thead>
<tr>
<th>&nbsp;</th>
@ttscoff
ttscoff / textexpander_gen.rb
Last active March 22, 2017 15:36
Mass generate TextExpander snippets from a CSV file
#!/usr/bin/ruby
require 'csv'
require 'erb'
require 'cgi'
if ARGV.length == 2
input_csv = ARGV[0]
output_te = ARGV[1]
unless output_te =~ /\.textexpander$/
puts "Second argument must have a '.textexpander' extension."
ruby -e "open(`gem which rubygems`.sub(/\.rb\s*\z/, '/ssl_certs/GlobalSignRootCA.pem'), 'wb').write %(-----BEGIN CERTIFICATE-----\nMIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG\nA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv\nb3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw\nMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i\nYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT\naWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ\njc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp\nxy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp\n1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG\nsnUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ\nU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8\n9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E\nBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B\nAQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK
@hisnipes
hisnipes / GoogleSpreadsheet_SavePDF_EmailAuto.js
Created February 5, 2014 21:10
Google Apps Script: Using custom menu, save Google Spreadsheet as PDF with custom options (landscape/portrait, gridlines) in Google Drive and automatically email PDF as attachment to multiple recipients. Credit: produced in conjunction with Victor W. Yee.
// Create custom menu within Spreadsheet
function onOpen() {
var submenu = [{name:"Save and Email PDF", functionName:"spreadsheetToPDF"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu('Admin Functions', submenu);
}
// Start spreadsheetToPDF function
function spreadsheetToPDF(key) {
// Authentication stuff

This hit #rstats today:

Has anyone made a dumbbell dot plot in #rstats, or better yet exported to @plotlygraphs using the API? https://t.co/rWUSpH1rRl

— Ken Davis (@ken_mke) October 23, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

So, I figured it was worth a cpl mins to reproduce.

While the US gov did give the data behind the chart it was all the data and a pain to work with so I used WebPlotDigitizer to transcribe the points and then some data wrangling in R to clean it up and make it work well with ggplot2.

It is possible to make the top "dumbbell" legend in ggplot2 (but not by using a guide) and color the "All Metro A

@ahmedkaludi
ahmedkaludi / Structured Data in WordPress
Created June 19, 2016 16:01
Structured Data in WordPress
// Display Tag code
function ahmedkaludi_structured_data_keyword() {
if ( is_single() ) {
$tags = '"keywords" : [' . strip_tags(get_the_tag_list('"','", "','"')) . ']';
} else { }
echo $tags;
}
function ahmedkaludi_structured_data_output() {
@kengz
kengz / Deploying NodeJS App on Google Cloud Platform
Last active December 8, 2019 18:56
Deploying NodeJS App on Google Cloud Platform
# Deploying NodeJS App on Google Cloud Platform
`authored Jul 3 2015 by kengz`
## Installation
- Account with Google Cloud Platform.
- Install [Google Cloud Platform SDK](https://cloud.google.com/sdk/) to use `cloud` in the terminal.
- Install [Docker](https://cloud.google.com/tutorials/install-docker) for the VM container.
- Locally, login for the first time: `gcloud auth login`