This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'https://api.smartystreets.com/street-address?'; | |
$url .= 'auth-id=[auth-id]&auth-token=[auth-token]'; | |
$url .= '&street=' . $street . '&zipcode=' . $zip; | |
$urlData = json_decode(file_get_contents($url),true); | |
//print_r($urlData); | |
if(isset($urlData[0]['metadata']['latitude'])) { | |
$latitude = $urlData[0]['metadata']['latitude']; | |
$longitude = $urlData[0]['metadata']['longitude']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Connect to this using websockets on port 9454 | |
#Send in the format of {"data":[1,2,3]} | |
#The ppp returns the standard deviation of the sent array | |
library(jsonlite) | |
library(httpuv) | |
#server | |
app <- list( | |
onWSOpen = function(ws) { | |
ws$onMessage(function(binary, message) { | |
write(message, file = "log.txt",append = TRUE, sep = "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT `TABLE_NAME`,`COLUMN_NAME` | |
FROM `INFORMATION_SCHEMA`.`COLUMNS` | |
WHERE `TABLE_SCHEMA`='wordpress' | |
AND `TABLE_NAME` LIKE 'wp_%'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php define('WP_USE_THEMES', false); require('./wp-blog-header.php'); | |
remove_inactive_themes(); | |
function remove_inactive_themes() | |
{ | |
echo '<h1>Removing Inactive Themes</h1><ul>'; | |
$theme_dir = get_theme_root(); | |
$template_dir = get_template_directory(); | |
foreach (scandir($theme_dir) as $res) { | |
if (is_dir($theme_dir . '/' . $res)&&($res!='.')&($res!='..')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var notifier = require('node-notifier'); | |
var status = ""; | |
var url = "[tracking url]"; | |
var interval = setInterval(function(url, notifier) { | |
get_status(url, notifier); | |
}, 30000, url, notifier); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to run the script | |
# rscript csv-wide.R "~/path/to/in.csv" "~/path/to/out.csv" column_name_for_matches | |
args = commandArgs(trailingOnly=TRUE) | |
match_column <- args[3] | |
max_width <- 0 | |
csv <- read.csv(args[1], header = T, sep = ",", quote = "\"", | |
stringsAsFactors = F, encoding="UTF-8", fill=T) | |
csv[[match_column]] <- as.character(csv[[match_column]]) | |
#grabs the max length of columns that will exist | |
for(needle in unique(csv[[match_column]])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input<-file('stdin', 'r') | |
rows <- readLines(input, n=1) | |
story <- c() | |
story <- unlist(lapply(rows,function(x) { | |
split <- strsplit(gsub("[[:punct:]]", "",x), " |\t") | |
return(split) | |
})) | |
df <- data.frame(sort(table(story),decreasing=TRUE)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df <- read.csv(paste("~/R/df/","import.csv",sep=""), | |
header = TRUE, sep = ",", quote = "\"",stringsAsFactors = FALSE, encoding="UTF-8") | |
names(df) <- c("herd","date","disease") | |
output <- matrix(, nrow = 0, ncol = 4) | |
for(herd in unique(df$herd)) { | |
for(date in unique(df$date)) { | |
for(disease in unique(df$disease)) { | |
subset <- df[which(df$herd==herd & df$date==date),] | |
output <- rbind(output,c(herd,date,disease,nrow(subset[which(subset$disease==disease),])/nrow(subset))) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var https = require('https'); | |
var fs = require('fs'); | |
fs.writeFile('posts.csv', 'Author,ID,Post Date,Comments,Score,Stickied,Pull,Subreddit\n', function(){console.log('done')}); | |
fs.writeFile('users.csv', 'Author,Author Date\n', function(){console.log('done')}); | |
scrape_hot("",1,"The_Donald"); | |
scrape_hot("",1,"SandersForPresident"); | |
scrape_hot("",1,"hillaryclinton"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pop <- read.csv(paste("~/R/dumb_shit/import/","pop.csv",sep=""), header = FALSE, sep = ",", quote = "\"",stringsAsFactors = FALSE, encoding="UTF-8") | |
coverage <- read.csv(paste("~/R/dumb_shit/import/","coverage.csv",sep=""), header = FALSE, sep = ",", quote = "\"",stringsAsFactors = FALSE, encoding="UTF-8") | |
names(pop) <- c("City","State","Pop") | |
names(coverage) <- c("City","State") | |
find_match <- function(x) { | |
result <- NA | |
if(nrow(coverage[which(coverage$City==x["City"] & coverage$State==x["State"]),])>0) { | |
result <- "Match" | |
} |