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 (hrishioa@gmail.com) (@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 / mock_multiprocess_pool.md
Last active January 2, 2023 22:41
mocking multiprocess pool for unittest

Mocking multiprocess pool apply_async method

It seems python multiprocessing interface relies on pickling, and mock library and pickling don't go well together.

write mock of multiprocess class for pytest

module code

pool = Pool(cpu_count())
pool.apply_async(func=myfunc)
@tuantranf
tuantranf / create-aws-ecr-authentication-cronjob.md
Created September 16, 2019 03:22
A Kubernetes cronjob to refresh ECR authentication

A Kubernetes cronjob to refresh ECR authentication

Create AWS secret

kubectl create secret generic aws-secret --from-literal=AWS_ACCOUNT= --from-literal=AWS_ACCESS_KEY_ID= --from-literal=AWS_SECRET_ACCESS_KEY= --from-literal=AWS_DEFAULT_REGION= --from-literal=AWS_REGION=

Create cronjob

@tuantranf
tuantranf / keybase.md
Last active September 12, 2019 06:13

Keybase proof

I hereby claim:

  • I am tuantranf on github.
  • I am miketmt (https://keybase.io/miketmt) on keybase.
  • I have a public key ASCwpkdAFsIa5uo76zNzBlg8Z6UcoSJX96aKZjHw4u61qgo

To claim this, I am signing this object: