Skip to content

Instantly share code, notes, and snippets.

View j450h1's full-sized avatar

Jas Sohi j450h1

View GitHub Profile
@rich-iannone
rich-iannone / gist:1da1ae7a7203958a0c5b1bd1d4b24017
Last active October 13, 2021 03:51
This gt code allows you to make a summary table based on the `pizzaplace` dataset.
library(tidyverse)
library(paletteer)
library(gt)
pizzaplace %>%
mutate(type = case_when(
type == "chicken" ~ "chicken (pizzas with chicken as a major ingredient)",
type == "classic" ~ "classic (classical pizzas)",
type == "supreme" ~ "supreme (pizzas that try a little harder)",
type == "veggie" ~ "veggie (pizzas without any meats whatsoever)",
@mkahn5
mkahn5 / main.py
Created December 27, 2018 14:31
Cloud Function BigQuery Append
def import_to_big_query(data, context, dataset='UPDATE_DATASET_HERE', table='UPDATE_TABLE_HERE', verbose=True):
def vprint(s):
if verbose:
print(s)
vprint('Event ID: {}'.format(context.event_id))
vprint('Event type: {}'.format(context.event_type))
vprint('Importing required modules.')
from google.cloud import bigquery
@ppetraki
ppetraki / fetch_gdrive_file.sh
Created November 8, 2017 20:58
allows you do non-interactively download large public files from gdrive
#!/bin/bash
SOURCE="$1"
if [ "${SOURCE}" == "" ]; then
echo "Must specify a source url"
exit 1
fi
DEST="$2"
if [ "${DEST}" == "" ]; then
@arose13
arose13 / install-conda.sh
Last active February 18, 2024 12:20
Install Miniconda in Ubuntu
# Setup Ubuntu
sudo apt update --yes
sudo apt upgrade --yes
# Get Miniconda and make it the main Python interpreter
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p ~/miniconda
rm ~/miniconda.sh
export PATH=~/miniconda/bin:$PATH
# Day 0: Mean, Median, and Mode
# Selecting standard input
con <- file('stdin', open='r')
# We don't need the first input
data_line <- readLines(con)[[2]]
# splitting the data into individual string
split_data <- strsplit(data_line, " ")
@alysonla
alysonla / active-issues.sql
Last active September 19, 2023 11:21
Queries that power the open source section of the 2016 Octoverse report https://octoverse.github.com/2016/
-- Active issues
-- Count of total active issues in the specified time frame
-- Source: githubarchive public data set via Google BigQuery http://githubarchive.org/
SELECT
COUNT(DISTINCT JSON_EXTRACT_SCALAR(events.payload, '$.issue.id')) AS events_issue_count
FROM (SELECT * FROM TABLE_DATE_RANGE([githubarchive:day.],TIMESTAMP('2015-09-01'),TIMESTAMP('2016-08-31')))
AS events
-- 10,723,492 active issues
@MarkEdmondson1234
MarkEdmondson1234 / send_email_mailgun.R
Last active March 18, 2024 14:06
Send an email via an R function using Mailgun
#' Email a user a report is ready
#'
#' Requires an account at Mailgun: https://mailgun.com
#' Pre-verification can only send to a whitelist of emails you configure
#'
#' @param email Email to send to
#' @param mail_message Any extra info
#'
#' @return TRUE if successful email sent
#' @import httr
@pvictor
pvictor / bb8_with_ggplot2.R
Created April 25, 2016 13:57
A Star Wars BB-8 with ggplot2 !
# BB-8 --------------------------------------------------------------------
# Inspired by Brian Hough in http://codepen.io/bhough/pen/wawrPL
# Packages ----------------------------------------------------------------
library("dplyr")
library("ggplot2")
@dannguyen
dannguyen / selenium-screenshotting.md
Last active February 15, 2023 15:59
Using Selenium and Python to screenshot a javascript-heavy page

Using Selenium and Python to screenshot a javascript-heavy page

As websites become more JavaScript heavy, it's harder to automate things like screenshotting for archival purposes. I've seen examples and suggestions to use PhantomJS for visual testing/archiving of websites, but have run into issues such as the non-rendering of webfonts. I've never tried out Selenium until today...and while I'm not thinking about performance implications yet, Selenium seems far more accurate than PhantomJS...which makes sense since it actually opens a real browser. And it's not too hard to script to do complex interactions: here's an [example of how to log in to Twitter, write a tweet, upload an image, and send a tweet via Selenium and DOM element selection](https://gist.github.com/dannguyen/8a6fa49253c1d6a0eb92