Skip to content

Instantly share code, notes, and snippets.

View tuantranf's full-sized avatar
🎯
Focusing

Tuan (Mike) Tran tuantranf

🎯
Focusing
View GitHub Profile
@tuantranf
tuantranf / auth.go
Created August 9, 2023 01:29 — forked from ogazitt/auth.go
Auth0 PKCE flow for a CLI built in golang
package auth
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
@tuantranf
tuantranf / load_and_process_open_source_licenses.ts
Created May 9, 2023 07:45 — forked from hrishioa/load_and_process_open_source_licenses.ts
Simple Typescript file demonstrating chunked, chained LLM calls to process large amounts of text.
// Requires the gpt library from https://github.com/hrishioa/socrate and the progress bar library.
// Created by Hrishi Olickel ([email protected]) (@hrishioa). Reach out if you have trouble running this.
import { ThunkQueue } from '../../utils/simplethrottler';
import {
AcceptedModels,
Messages,
askChatGPT,
getMessagesTokenCount,
getProperJSONFromGPT,
@tuantranf
tuantranf / RunAProxyOnAmazonEC2VPC.md
Created January 10, 2023 11:11 — forked from webinista/RunAProxyOnAmazonEC2VPC.md
Create a proxy server on an Amazon EC2 (VPC) instance

This will create a proxy server in whatever your availability zone your VPC is in. For me, that's us-east-1b. For you, that may be something different. Steps 10+ should more or less work regardless of your provider since those steps cover the setup and configuration of TinyProxy.

  1. Click the Launch Instance button.
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type. This isn't strictly necessary. If you choose another OS, check its documentation for how to install new packages.
  3. On the Choose an Instance Type screen, select t2.micro. It's Free Tier eligible.
  4. Click the Next: ... buttons until you reach the Configure Security Group screen.
    • You may wish to reduce the amount of storage on the Add Storage screen. This is optional.
    • You may wish to add a tag on the Tag Instance screen. This is also optional.
  5. On the Configure Security Group screen:
  • Select Create a new security group.
#include <M5Stack.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
WiFiClientSecure client;
//WiFi設定
const char* ssid = "******";
const char* password = "*****";
@tuantranf
tuantranf / _jsonPuller.md
Created July 9, 2021 04:11 — forked from jalcantarab/_jsonPuller.md
A Google apps script to pull json from a spreadsheet

JSON Puller - Google Apps Script

Transforms the data of a given Spreadsheet Sheet to JSON.

  • The frozen rows are taken as keys for the JSON.
  • The data taken for the values is only that after the frozen rows

Set up:

exportJSON(Spreadsheet) - transforms the data in the given sheet to JSON.

@tuantranf
tuantranf / main.py
Created April 29, 2020 03:12 — forked from sirex/main.py
sqlalchemy joins with AS
import sqlalchemy as sa
import sqlparse
metadata = sa.MetaData()
tasks = sa.Table(
'tasks', metadata,
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('bot', sa.String(255), nullable=False),
sa.Column('task', sa.String(255), nullable=False),
@tuantranf
tuantranf / gist:92520a990c9503b7718d9b7e281a1838
Created June 29, 2019 02:04 — forked from loisaidasam/gist:2774350
One liner for counting unique IP addresses from nginx logs
# One liner for counting unique IP addresses from nginx logs
# Feel free to comment with better ideas - I'm sure it's not the best way of doing this (I'm no awk ninja!)
#
# Sample output:
#
# $ cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
# 66.65.145.220 49
# 92.63.28.68 126
cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
@tuantranf
tuantranf / README.md
Created June 19, 2019 09:51 — forked from dannguyen/README.md
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

@tuantranf
tuantranf / merger.py
Created November 29, 2018 07:03 — forked from ericmjl/merger.py
A Python script for merging PDF files together.
"""
Author: Eric J. Ma
Purpose: To merge PDFs together in an automated fashion.
"""
import os
from PyPDF2 import PdfFileReader, PdfFileMerger