Skip to content

Instantly share code, notes, and snippets.

View phuang07's full-sized avatar

Ray Huang phuang07

View GitHub Profile
@phuang07
phuang07 / map.html
Created June 22, 2024 14:16
Google map api example
<!-- AIzaSyCgopc33y7c2axwfdoU3XDc6jjXwJ0cuVU -->
<!DOCTYPE html>
<html>
<head>
<title>Road Trip Map</title>
<script src="https://maps.googleapis.com/maps/api/js?key={YOUR_OWN_KEY}"></script>
<script>
function initMap() {
// Create a map object and specify the DOM element for display.
from sklearn import preprocessing
from sklearn import utils
df = pd.read_csv('../data/nyrr/racer_races_3_3_6.csv')
# x = df[df.columns.difference(['fitness_score'])]
x = df[['mean']]
y = df['fitness_score']
#convert y values to categorical values
lab = preprocessing.LabelEncoder()
@phuang07
phuang07 / db.sql
Last active August 25, 2022 16:18
Physical Schema for db project
-- MySQL Script generated by MySQL Workbench
-- Thu Aug 25 12:17:47 2022
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
@phuang07
phuang07 / webtopdf.sh
Last active March 5, 2020 22:41
A script to download webpage as pdf file
#!/bin/bash
# wget --no-parent --wait=20 --limit-rate=20K -r -p -U Mozilla https://walkccc.github.io/CLRS/
list=$(lynx -dump -listonly https://walkccc.github.io/CLRS/ | grep -I --color 'CLRS/Chap' | awk '{print $2}')
# list=$(wget --spider --force-html --no-parent --timestamping -r -l1 https://walkccc.github.io/CLRS/ 2>&1 | ag -v 'Saving to' | ag 'CLRS/Chap[0-9]+(0-9|-|\.|.)*/$' | awk '{print $3}')
for link in $list
do
#echo $link
filename=$(echo $link | sed "s/-/_/g" | sed "s/\./_/g" | awk 'BEGIN { FS = "/" } ; {print $(NF-1)}')
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --print-to-pdf=$filename.pdf $link 2>&1
@phuang07
phuang07 / gist:f28ca16efe56db13e5dcd3c52abd3b51
Created November 21, 2017 22:08
Tomcat - Restrict access by hostname
<!--- Add the following filter to the ${TOMCAT_HOME}/conf/web.xml --->
<filter>
<filter-name>Remote Host Filter</filter-name>
<filter-class>org.apache.catalina.filters.RemoteHostFilter</filter-class>
<init-param>
<param-name>allow</param-name>
<param-value>atv\.elab\.io\|sub2\.elab.\io</param-value>
</init-param>
</filter>
@phuang07
phuang07 / gist:725b8c8effba98bab5493c0f3b4d5c94
Created November 1, 2017 02:41
Add the following to includes/common.inc for function drupal_http_request() so self-signed certificate can work
<?php
// https://www.drupal.org/node/2780147
$context = stream_context_create(['ssl' => [
'ciphers' => 'TLSv1',
'SNI_enabled' => FALSE,
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]]);
@phuang07
phuang07 / gist:3a72a3ea3a3e212623b1fba9b11fb225
Created August 28, 2017 15:51
Use curl to check file existen
#!/bin/bash
url=http://www.elab.io/test.pdf
if curl --output /dev/null --silent --head --fail "$url"; then
echo "URL exists: $url"
echo "Just a test from a sendbox" | mail -s "File still there" {your_email}
else
echo "URL does not exist: $url"
echo "Just a test from a sendbox" | mail -s "File just got deleted" {your_email}
fi
@phuang07
phuang07 / gist:a9f353a7a4a966cabc820138e12a7e33
Last active January 16, 2025 18:49
Upgrade openssl on Mac
Ref: http://stackoverflow.com/questions/15185661/update-openssl-on-os-x-with-homebrew
```
1. Make sure openssl is installed via homebrew
homebrew install openssl
2. if /usr/local/bin is not already the first item in the $PATH, modify the PATH variable
set -gx PATH /user/local/bin $PATH
3. Make symlink to the binary
@phuang07
phuang07 / drupal_files_rm
Created January 20, 2017 16:32
Remove un-images files
#!/bin/bash
drush cc all
rm -rf sites/default/files/less
find .sites/default/files -type f -name '*.ppt' -print0 | xargs -0 sudo /bin/rm -f
find .sites/default/files -type f -name '*.doc' -print0 | xargs -0 sudo /bin/rm -f
find .sites/default/files -type f -name '*.pdf' -print0 | xargs -0 sudo /bin/rm -f
@phuang07
phuang07 / total_size.sh
Created January 20, 2017 16:08
Find total size of certain file type
# Reference: http://unix.stackexchange.com/questions/41550/find-the-total-size-of-certain-files-within-a-directory-branch
find sites/default/files/ -type f -name '*.pdf' -exec du -ch {} +