Skip to content

Instantly share code, notes, and snippets.

View tjunxiang92's full-sized avatar

Tan Jun Xiang tjunxiang92

View GitHub Profile
@tjunxiang92
tjunxiang92 / ws_client.py
Created June 8, 2024 06:21
Converting Websocket to SSE Protocol with Python with websockets, fastapi, sse-starlette
import json
from fastapi import FastAPI, Request
from sse_starlette.sse import EventSourceResponse
import asyncio
import uvicorn
from websockets.client import connect
app = FastAPI()
async def connect_websockets():
@tjunxiang92
tjunxiang92 / _steps.md
Last active November 24, 2023 16:36
Gradio-Blocks / ViTPose deployment on Runpod

Spaces

  • Docker Repo registry.hf.space/gradio-blocks-vitpose:latest
  • Start Command python -c "import time; time.sleep(86400)" Sleep required to edit the files via web console
// https://pytorch.org/get-started/previous-versions/
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113

wget https://gist.githubusercontent.com/tjunxiang92/5e9f5b003030f2c1b4d29968a2ef73a5/raw/d6f31a7f30899ffc08125572ac40c5cdb427a063/site_packages_builder.py
mv site_packages_builder.py /home/user/.local/lib/python3.10/site-packages/mmdet/datasets/builder.py
@tjunxiang92
tjunxiang92 / check_hash.js
Created August 17, 2019 03:42
Telegram Web Login JS Check Hash
var CryptoJS = require("crypto-js");
var bot_token = "xxxxxxxxx:xxxxxxxxxxxxx";
// TODO: split the web response into the following fields
var hash = "xxx";
var data = {
"username": "xxxx",
"auth_date": "xxxx",
"first_name": "xxxxxx",
"id": "xxxxxxx",
@tjunxiang92
tjunxiang92 / sample.md
Created November 16, 2018 02:15
Getting a small sample from a large dataset

Generate your CSV

head -n1000 dataset.csv > small.csv

Generate a subset of train.csv taking random samples from the dataset

tail -n +2 nyc_taxi_train_dataset.csv | gshuf -n 100000 > processed.csv
head -n1 nyc_taxi_train_dataset.csv | cat - processed.csv > temp && mv temp processed.csv
@tjunxiang92
tjunxiang92 / AndroidManifest.xml
Last active April 22, 2024 19:14
Flutter: Receiving Shared Data from other Apps
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Add This intent-filter -->
<intent-filter>
<action android:name="android.intent.action.SEND" />
0x03230350c925d80b08FdE6c6Fa4D7c9004543eC6
@tjunxiang92
tjunxiang92 / theme.liquid
Created July 27, 2017 06:01
Infinite Scroll for Shopify
<!-- Add this to the bottom of theme.liquid -->
<script>
var isActive = false;
var index = 1;
var maxPages = 0;
function ScrollExecute() {
if(!isActive && $(document).height() - 800 < ($(document).scrollTop() + $(window).height())) {
isActive = true;
scrollURL = $('.next a:eq(0)').last().attr('href');
@tjunxiang92
tjunxiang92 / geodecode.js
Created April 21, 2017 21:19
Translate Address into lat lng
// Geocoding
// https://developers.google.com/maps/documentation/geocoding/intro
const API_KEY = "Fetch from google: https://developers.google.com/maps/documentation/javascript/get-api-key";
const address = "Here is your address";
const decodeLatLng = address => {
return new Promise((resolve, reject) => {
request(`https://maps.googleapis.com/maps/api/geocode/json?address=${address}&key=${API_KEY}`,
(error, response, body) => {
if (error) reject(error);
http://blog.romainpellerin.eu/tips-for-ffmpeg.html
# Fast Forward Video Only
ffmpeg -i test.mp4 -filter:v "setpts=0.1*PTS" -an vid10xnosound.mp4
# Fast Forward Video and Sound by 2
ffmpeg -i test.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" outputff.mp4
# Remove Sound from Video
ffmpeg -i test.mp4 -c copy -an nosound.mp4
@tjunxiang92
tjunxiang92 / ocr_bot.py
Created June 12, 2016 23:32 — forked from heejune/ocr_bot.py
telegram bot example uses the tesseract to process OCR request
import sys
import asyncio
import random
import telepot
from telepot.delegate import per_chat_id
from telepot.async.delegate import create_open
import os
import traceback