Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Hello old friend!

Necronet necronet

👨‍💻
Hello old friend!
View GitHub Profile
@necronet
necronet / open_pr_by_commit.sh
Created Mar 31, 2021
Open PR for a specific commit
View open_pr_by_commit.sh
# Get PR number for a specific commit
local pr_number=$(git log --reverse --ancestry-path <commit_id>..master --grep="Merge pull request" --oneline | head -n 1 | awk '{print $5}' | sed -E 's/#//g')
# Open PR in the browser
open "https://github.tumblr.net/TumblrMobile/android2/pull/$pr_number"
@necronet
necronet / getMergedManifest.sh
Created Mar 30, 2021
Get Merged Manifest android and copy to clipboard
View getMergedManifest.sh
cat <module_name>/build/intermediates/merged_manifest/celrayDebug/out/AndroidManifest.xml | pbcopy
@necronet
necronet / aws_dynamo_101.sh
Created Jan 2, 2021
An easy example of some aws console operation for dynamodb
View aws_dynamo_101.sh
# List all the tables using a profile
aws dynamodb list-tables --profile <profile_name> | jq
# Get all item in a table using a profile (expensive)
aws dynamodb scan --table-name <table_name> --profile <profile_name> | jq
# Get an specific item based on id using a profile
aws dynamodb get-item --key '{"id":{"S":"009871"}}' --table-name <table_name> --profile <profile_name> | jq
# Create an item using a profile
@necronet
necronet / residual.R
Created Jul 13, 2020
Find the largest residual of 2 digits number that can be divided by the sum of itself
View residual.R
# Find the largest residual of 2 digits number that can be divided by the sum of itself
# maxres(ab/(a+b))
library(tidyr)
count <- 0
max_index <- 0
for( i in 10:99) {
digits <- as.integer(substring(i, seq(nchar(i)), seq(nchar(i))))
aplusb <- digits[1] + digits[2]
@necronet
necronet / variation.R
Created Jul 4, 2020
Get all numbers 3 digits, divisible by 3 that follow this formula, a + 3b + c where a != 0
View variation.R
# Get all numbers 3 digits, divisible by 3 that follow this formula
# a + 3b + c where a != 0
library(tidyr)
count <- 0
n <- c()
for( i in 100:999) {
digits <- as.integer(substring(i, seq(nchar(i)), seq(nchar(i))))
formula <- (digits[1] + 3*digits[2] + digits[3])
@necronet
necronet / ptf_data_extraction.R
Last active Jun 27, 2020
Quickly filtering data for PTF
View ptf_data_extraction.R
library(readr)
library(skimr)
library(dplyr)
library(stringr)
data <- readr::read_csv('data.csv')
skimr::skim(data)
data_cleaned <- data %>% filter(!stringr::str_detect(Page, "@powertofly\\.com")) %>%
mutate(Registrations =
@necronet
necronet / lambda_selection_glmnet.R
Created Jun 18, 2020
Quick gist to show lambda selection difference between explicit and heuristic
View lambda_selection_glmnet.R
library(glmnet)
x_var <- data.matrix(mtcars[, c("hp", "wt", "drat")])
y_var <- mtcars[, "mpg"]
fit_lambda_specified <- cv.glmnet(x_var, y_var, alpha = 0, lambda = 10^seq(5, -5, by = -.1))
fit_lambda_automatic <- cv.glmnet(x_var, y_var, alpha = 0)
plot(fit_lambda_specified, xvar="lambda")
plot(fit_lambda_automatic, xvar="lambda")
@necronet
necronet / spacyr_bug.R
Created Jun 5, 2020
Spacy R crashes on tokenizer
View spacyr_bug.R
corpus <- readr::read_csv("corpus.csv")
# Work with
#t <- corpus$text[1:100]
t <- corpus$text[124]
spacyr::spacy_tokenize(t)
@necronet
necronet / corpus.csv
Created Jun 5, 2020
spacyr crash on tokenizer
View corpus.csv
We can't make this file beautiful and searchable because it's too large.
text,label
Stuning even for the non-gamer: This sound track was beautiful! It paints the senery in your mind so well I would recomend it even to people who hate video game music! I have played the game Chrono Cross but out of all of the games I have ever played it has the best music! It backs away from crude keyboarding and takes a fresher step with grate guitars and soulful orchestras. It would impress anyone who cares to listen! ^_^,__label__2
" The best soundtrack ever to anything.: I'm reading a lot of reviews saying that this is the best 'game soundtrack' and I figured that I'd write a review to disagree a bit. This in my opinino is Yasunori Mitsuda's ultimate masterpiece. The music is timeless and I'm been listening to it for years now and its beauty simply refuses to fade.The price tag on this is pretty staggering I must say, but if you are going to buy any cd for this much money, this is the only one that I feel would be worth every penny.",__label__2
@necronet
necronet / gradient_background_ggplot2.R
Created Jun 4, 2020
On Adding a custom gradient w/ background layer to ggplot
View gradient_background_ggplot2.R
g <- rasterGrob(greens, width = unit(1, "npc"), height = unit(1, "npc"), interpolate = TRUE)
test <- ggplot(mtcars, aes(x = mtcars$hp, y = mtcars$mpg)) +
theme(plot.background = element_blank(),
panel.background = element_blank()) +
annotation_custom(
grob = g, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf
) + geom_point()
plot_grid(test, labels = c('A'))