Skip to content

Instantly share code, notes, and snippets.

View selcukakbas's full-sized avatar

Selcuk Akbas selcukakbas

View GitHub Profile
@sayle-doit
sayle-doit / bq_job_editions_cost_comparison_with_autoscaler.sql
Last active December 8, 2024 15:42
Compare BigQuery job costs when running a job on either BigQuery Editions with the autoscaler or on-demand with both new and old pricing models.
/*
* This query will look at the past 30 days of job history to analyze it for costs under
* BigQuery Editions while utilizing the new autoscaling feature that was introduced.
* It does this for those using both PAYG (Pay As You Go) and commitment models.
* It will also compare this versus running the query with the on-demand model.
*
* Note that this query utilizes some math modeling behaviors that the BigQuery
* autoscaler uses. Namely these are the up to 10 seconds "slot scale up time,"
* the minimum of 60 seconds "slot scale down time," and the behavior that the
* autoscaler scales up and down in factors of 100 slots for each job.
@krisjan-oldekamp
krisjan-oldekamp / google_bigquery_backup_views_scheduled_queries_git.py
Last active May 8, 2024 10:54
Backup BigQuery Views and Scheduled Queries to a Git repository using Python. Full article on stacktonic.com
############################################################
# Author Krisjan Oldekamp / Stacktonic.com
# Email [email protected]
# Article https://stacktonic.com/article/backup-your-valuable-big-query-views-and-scheduled-queries-using-python
############################################################
import os
import git
import google.oauth2.service_account
from google.cloud import bigquery
@krisjan-oldekamp
krisjan-oldekamp / google_dv360_api_activate_pause_lineitems.py
Last active November 16, 2022 05:03
Activate and pause Google Display & Video 360 (DV360) line items, using the DV360 API and Python
###################################################
# Author Krisjan Oldekamp / Stacktonic.com
# Email [email protected]
# Article https://stacktonic.com/article/how-to-activate-and-pause-line-items-in-google-dv-360-using-python
####################################################
import os
from urllib.error import HTTPError
from googleapiclient import discovery
from oauth2client.service_account import ServiceAccountCredentials
library(tidycensus)
library(ggiraph)
library(tidyverse)
library(patchwork)
vt_income <- get_acs(
geography = "county",
variables = "B19013_001",
state = "VT",
year = 2019,
@KoryNunn
KoryNunn / handshake-airdrop.md
Last active March 12, 2024 07:03
Handshake airdrop for github users.

Had 15 github followers in 2019? You can get about $4kAUD of crypto for minimal effort.

Explain this scam

That's legitimately a good default position to hold, however, in this case, the free money is a function of time, and not only charity.

In February 2020, in order to promote Handshake (HNS) to developers, an airdrop was offered to any Github user with more than 15 followers. The Airdrop would give you 4246HNS, at the time worth around at $0.08USD per coin, for a total of $339.68USD, pretty generous!

Today, 4246HNS is worth around $4000 dollarydoos, and there are plenty of github users who haven't claimed theirs.

@ikashnitsky
ikashnitsky / explain-map-borders.R
Last active January 1, 2023 17:33
Give an example how and why to use line borders instead of polygons outlines in maps -- https://ikashnitsky.github.io/2023/map-borders
#===============================================================================
# 2020-04-08 -- twitter upd 2023-01-01 ik-q
# Showcase the map hack -- use border lines instead of polygon outlines
# https://twitter.com/ikashnitsky/status/1247875600305598464
# https://ikashnitsky.github.io/2023/map-borders
# Ilya Kashnitsky, [email protected]
#===============================================================================
library(tidyverse)
library(sf)
@matthiaskern
matthiaskern / feedly_export_saved_for_later.js
Last active June 30, 2017 02:27
Small script to fetch saved for later items from feedly as JSON. Based on https://gist.github.com/bradcrawford/7288411
if(!(window.jQuery)) {
var script = document.createElement("script");
script.setAttribute("src", "https://code.jquery.com/jquery-2.2.1.min.js");
script.setAttribute("type", "text/javascript");
script.onload = logItems;
document.getElementsByTagName("head")[0].appendChild(script);
} else {
logItems();
}
@christophergandrud
christophergandrud / topicmodels_json_ldavis.R
Last active March 13, 2021 19:00
Convert the output of a topicmodels Latent Dirichlet Allocation model to JSON for use with LDAvis
#' Convert the output of a topicmodels Latent Dirichlet Allocation to JSON
#' for use with LDAvis
#'
#' @param fitted Output from a topicmodels \code{LDA} model.
#' @param corpus Corpus object used to create the document term
#' matrix for the \code{LDA} model. This should have been create with
#' the tm package's \code{Corpus} function.
#' @param doc_term The document term matrix used in the \code{LDA}
#' model. This should have been created with the tm package's
#' \code{DocumentTermMatrix} function.
@christophergandrud
christophergandrud / r_stan_setup.sh
Last active October 31, 2024 18:29
Setup R, RStudio,and Stan on Ubuntu (for Amazon EC2)
########################################################
# Set up RStudio and JAGS on an Amazon EC2 instance
# Using Ubuntu 64-bit
# Christopher Gandrud
# 16 December 2014
# Partially from http://blog.yhathq.com/posts/r-in-the-cloud-part-1.html
# See yhat for EC2 instance set up
########################################################
# In your terminal navigate to key pair
@benmarwick
benmarwick / PDF-2-text-or-CSV.r
Last active July 18, 2022 03:48
Convert PDFs to text files or CSV files (DfR format) with R
# Here are a few methods for getting text from PDF files. Do read through
# the instructions carefully! NOte that this code is written for Windows 7,
# slight adjustments may be needed for other OSs
# Tell R what folder contains your 1000s of PDFs
dest <- "G:/somehere/with/many/PDFs"
# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)