Skip to content

Instantly share code, notes, and snippets.

View adrienshen's full-sized avatar
🎯
Focusing

shanhui.dev adrienshen

🎯
Focusing
  • Freelance
  • Lima, Peru
  • 07:13 (UTC -05:00)
View GitHub Profile
@adrienshen
adrienshen / gist:d281e160fec36a3f53b7ff080d052e88
Last active March 15, 2024 04:00
Beating the Austin DPS Appointment Booking System
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
import pprint
pp = pprint.PrettyPrinter(indent=4)
import requests
import json
from datetime import datetime
DEV_FORCE_BOOKING = False
@adrienshen
adrienshen / cleanscreenshots.py
Last active March 27, 2020 20:36
Automate Removal of Old Dropbox Screenshots
import os
from datetime import datetime, timedelta
dropbox_screenshot_dir = '/Users/adrienshen/Dropbox/Screenshots'
defaults = {
'days_since': 30,
}
oldest_date = datetime.now() - timedelta(defaults['days_since'])
def browse_files():
@adrienshen
adrienshen / proxy-stream.js
Last active December 30, 2023 19:10
Simple method to pipe ytdl-node steam into Express endpoint POC
const ytdl = require('ytdl-core');
const express = require('express');
const app = express();
const videoID = 'http://www.youtube.com/watch?v=';
app.use('mp3', express.static(__dirname + '/mp3'));
app.get('/stream/:id', (req, res) => {
console.log('video url >> ', videoID + req.params.id);
-- search vectors column and create index
alter table movie_scripts add "document_vectors" tsvector;
create index idx_fts_doc_vector on movie_scripts using gin(document_vectors);
-- update the search vectors column with script
update
movie_scripts
set
document_vectors = (to_tsvector('english', names) || to_tsvector('english', script));
@adrienshen
adrienshen / scrape_imsdb.R
Created December 5, 2019 16:25
Web scraping film scripts using R and PostgreSQL
# source and credits: https://www.mikejohnpage.com/blog/web-scraping-r-s-data-table-and-writing-to-postgresql-and-mysql/
library(tidyverse)
library(robotstxt)
library(data.table)
library(rvest) # scraping library
library(stringi)
library(tidytext)
library(RPostgreSQL)
@adrienshen
adrienshen / amazon_islands_search.py
Created September 6, 2019 02:57
Amazon islands interview problem, 1 solution and demo of stack overflow
'''
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
Example 1:
11110
11010
11000
00000
{
"arrivalDate": "2016-01-15 05:15:00",
"departDate": "2016-01-14 22:00:00",
"origin": "Gombak",
"destination": "Jerteh",
"pickUpPoints": [
{
"pickupPointName": "Asam Pedas Shell MRR2",
"pickupPointId": null,
"departureTime": "2016-01-14 22:00:00",
{
"arrivalDate": "2016-01-15 05:15:00",
"departDate": "2016-01-14 22:00:00",
"origin": "Gombak",
"destination": "Jerteh",
"pickUpPoints": [
{
"pickupPointName": "Asam Pedas Shell MRR2",
"pickupPointId": null,
"departureTime": "2016-01-14 22:00:00",