Skip to content

Instantly share code, notes, and snippets.

View MattSandy's full-sized avatar
💭
Hungry

Matt Sandy MattSandy

💭
Hungry
View GitHub Profile
@MattSandy
MattSandy / front_page.R
Created September 3, 2019 15:52
Gets the subreddits that made it to the front page the most often
library(tidyverse)
library(jsonlite)
library(plotly)
# Figure out which columns are lists
drop_lists <- function(df) {
for(column in names(df)) {
if(typeof(df[[column]])=="list") {
# Remove column
df[[column]] <- NULL
@MattSandy
MattSandy / run.js
Last active August 14, 2019 16:16
Get character length of every document on the page
var all = document.getElementsByTagName("*");
var tags = [];
var tmp = 0;
for (var i=0, max=all.length; i < max; i++) {
tmp = 0;
jQuery.each(all[i].attributes,function(pos,element){
tmp = tmp + element.name.length + element.value.length;
});
tmp = tmp + jQuery(all[i]).html().length;
if(typeof(tags[jQuery(all[i]).prop("tagName")]) == "undefined") {
@MattSandy
MattSandy / Candidate_Bigrams.png
Last active August 1, 2019 14:02
Candidate bigrams from the July 30th, 2019 Democratic Debate
Candidate_Bigrams.png
@MattSandy
MattSandy / album_counts.R
Created July 26, 2019 16:15
Find the cumulative number of albums an artist has released and predict future counts.
# https://en.wikipedia.org/wiki/The_Mountain_Goats_discography
# Scraping
library("rvest")
library("ggplot2")
library("ggthemes")
library("stringr")
library("tidyverse")
tbls <- "https://en.wikipedia.org/wiki/The_Mountain_Goats_discography" %>%
read_html %>% html_nodes("table")
@MattSandy
MattSandy / OfflineCallConversionFeedService.md
Last active May 23, 2019 17:19
Offline Conversion Tracking Information

Offline Conversion Tracking

Google Page

Upload call conversions

An UploadCallConversion maps to the Import conversion source in the Google Ads UI followed by choosing Conversion from calls.

A mobile click-to-call click cannot be uploaded as a conversion if there is no Google forwarding number attached to the call. Without a Google forwarding number, there is no way Google can be sure that the click led to a call and then to a conversion. If a click is uploaded like this, it will be ignored by the conversion tracker.

Once you create an UploadCallConversion, you can use the OfflineCallConversionFeedService to upload conversions for calls. See Importing Call Conversions below for details.

@MattSandy
MattSandy / avengers.R
Created May 7, 2019 20:31
IMDB scraping for Avengers:Endgame reviews
library(rvest)
library(magrittr)
library(stringr)
library(lubridate)
library(data.table)
library(ggplot2)
library(patchwork)
library(tidyverse)
# Functions ---------------------------------------------------------------
@MattSandy
MattSandy / scan.php
Created February 9, 2019 19:46
Scans the current directory and subdirectories for files which contain eval(), base64_decode(), or exec() references.
<?php
error_reporting(0);
if(isset($_GET['file'])) {
highlight_file(urldecode($_GET['file']));
die();
} else if(isset($_GET['del'])) {
unlink(urldecode($_GET['del']));
echo "file deleted";
die();
}
@MattSandy
MattSandy / tree.R
Created December 6, 2018 06:20
Christmas Tree
bulbs <- data.frame(x=c(300,500,650,400,600,500,450,500,500),y=(seq(100,600,60)/1.2))
s <- sample(0:1500)
r <- 0:500
mid <- 500
center <- rep(500,length(r))
tree <- data.frame(x = c(r,center,rev(r)+mid,center),
y = c(r,r+50,r,r+50),
g = c(s[r+1],s[r+1],s[r+mid*2],s[r+mid*2]))
ggplot(tree,aes(x=x,y=y)) +
geom_line(aes(group = g, colour = g),
@MattSandy
MattSandy / clock.R
Last active November 9, 2018 06:13
ggplot clock
ggplot(data.frame(t = c(1:60)),aes(t,3)) + geom_point() +
geom_point(data = data.frame(t = c(seq(0,11)*5),3),
aes(t,3,color=factor(t)), size=5) +
coord_polar() +
scale_x_continuous(labels = c(12,3,6,9),
breaks = c(0,15,30,45)) +
scale_y_continuous(limits = c(0,3)) +
theme_bw(base_size = 22) +
theme(title = element_blank(),
legend.key = element_blank(),
@MattSandy
MattSandy / tableau.php
Created November 9, 2018 02:29
Tableau Data Path Replace
<?php
error_reporting(E_ALL);
$url = str_replace("?dl=0","?dl=1",urldecode($_REQUEST['url']));
$thumbs = "";
$user['Not_Matt'] = array('C:/Users/Not_Matt/Dropbox/MSM/','C:\Users\Not_Matt\Dropbox\MSM\\');
$user['matt'] = '/Users/macbook/Dropbox/work/shared/MSM/';
if ($_POST['action'] == "download") {
$headers = get_headers($url, 1);