Skip to content

Instantly share code, notes, and snippets.

Avatar

Stanley Zheng stanzheng

View GitHub Profile
@stanzheng
stanzheng / filter.ps1
Created Jun 21, 2021
powershell spreadsheets
View filter.ps1
Import-CSV -Path .\pluto_21v1.csv |Where-Object {$_.borough -eq "BK" -and $_.zipcode -in @(11205, 11206, "11216", 11221, 11233, 11238) -and $_.bldgclass -like "V*"} | Export-Csv -Path .\vacant_bedstuy_brooklyn_pluto_21v1.csv
Import-CSV -Path .\pluto_21v1.csv |Where-Object {$_.borough -eq "BK" -and $_.zipcode -in @(11205, 11206, 11216, 11221, 11233, 11238) -and $_.bldgclass -like "V*"} | select -ExpandProperty zipcode
select -ExpandProperty bldgclass
Import-CSV -Path .\pluto_21v1.csv |Where-Object {$_.borough -eq "BK" -and $_.zipcode -in @(11205, 11206, "11216", 11221, 11233, 11238) -and $_.bldgclass -like "V*"} | select
Import-CSV -Path .\pluto_21v1.csv |Where-Object {$_.borough -eq "BK" -and $_.zipcode -match "11216" -and $_.bldgclass -like "V"} | Export-Csv -Path .\Processes.csv
@stanzheng
stanzheng / ssh rule
Last active Jun 5, 2020
Generate SSH IP Allow-list
View ssh rule
#!/bin/sh
set -- $(dig -t txt +short _cloud-netblocks.googleusercontent.com +trace)
included="" ip4=""
while [ $# -gt 0 ]; do
k="${1%%:*}" v="${1#*:}"
case "$k" in
include)
# only include once
@stanzheng
stanzheng / main.c
Created May 13, 2020 — forked from ColorfulCodes/main.c
This is the mt3620 blinky
View main.c
#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <applibs/storage.h>
#include <applibs/log.h>
#include <applibs/gpio.h>
@stanzheng
stanzheng / mastermind.py
Created Nov 5, 2019
Mastermind in Python!
View mastermind.py
## Mastermind
## Two Players
## 6 colors
## First Guess
TRYS = 10
MASTERMIND_CODE = ['r', 'g', 'r', 'b']
import getpass
View aggregations.sql
SELECT owner,
Count(DISTINCT( breed )) AS num_breeds,
Count(name) AS num_dogs
FROM dogs
GROUP BY owner
ORDER BY num_dogs DESC
LIMIT 3
@stanzheng
stanzheng / cloudSettings
Last active May 25, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2019-11-15T22:05:25.530Z","extensionVersion":"v3.4.3"}
@stanzheng
stanzheng / _0000trackpad
Last active Oct 9, 2019
X1 Carbon 7 linux setup
View _0000trackpad
#!/bin/sh
case "$1" in
resume)
DISPLAY=:0.0 su USER -c '/usr/bin/synclient TouchpadOff=0' ;;
esac
# /etc/pm/sleep.d/0000trackpad
@stanzheng
stanzheng / aws.txt
Last active Jul 16, 2019
Useful Cloud Commands
View aws.txt
# Authenticate ECR
eval $(aws ecr get-login --no-include-email | sed 's|https://||')
export AWS_PROFILE=aws-sand; eval $(aws ecr get-login --no-include-email --region us-east-1 --profile aws-sand | sed 's|https://||')
docker tag foobar:latest 399450685648.dkr.ecr.us-east-1.amazonaws.com/foobar:latest
# for each buckets
export BUCKET_PREFIX="s3://nfl-sandbox-datalake-"
array=( aws s3 ls $BUCKET_PREFIX* )
for i in "${array[@]}"
View gist:cecac459cceb20492499ba71150bd874
import unittest
def is_binary_search_tree(root):
# Determine if the tree is a valid binary search tree
stack = [(root, -float('inf'), float('inf'))]
while len(stack):
node, lower_bound, upper_bound = stack.pop()
if (node.value <= lower_bound) or (node.value >= upper_bound):
return False
View tricks.py
## https://docs.scipy.org/doc/numpy-1.13.0/user/basics.io.html
import np
## get all input
claims = [[int(sub_str) for sub_str in re.findall(r'-?\d+', line)] for line in inputz.split('\n')]
## populate an array
canvas = np.zeros((1000,1000))