This file contains hidden or 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
set.seed(1) | |
df <- data.frame(x=rnorm(10), y=rnorm(10)) | |
d1 <- dist(df) | |
min(d1) | |
#0.2036045 | |
which.min(d1) | |
#43 | |
df[combn(row.names(df),2)[,match(min(d1),d1)],] | |
# x y |
This file contains hidden or 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'); | |
var post_array = []; | |
var user_array = []; | |
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')}); | |
var subreddits = ["AskReddit", "politics", "The_Donald", "funny", "nba", "Overwatch", "gaming", "pics", "news", "todayilearned", "videos", "movies", "worldnews", "soccer", "relationships", "WTF", "SandersForPresident", "AdviceAnimals", "gifs", "leagueoflegends", "aww", "BlackPeopleTwitter", "hockey", "SquaredCircle", "gameofthrones", "nfl", "GlobalOffensive", "h3h3productions", "arrow", "DotA2", "pcmasterrace", "hiphopheads", "me_irl", "Showerthoughts", "science", "Mr_Trump", "Games", "mildlyinteresting", "asoiaf", "technology", "hillaryclinton", "IAmA", "4chan", "hearthstone", "TumblrInAction", "magicTCG", "Jokes", "PoliticalDiscussion", "tifu", "baseball", "CFB", "enoughsanderss |
This file contains hidden or 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" | |
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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_%'; |