Skip to content

Instantly share code, notes, and snippets.

View clsung's full-sized avatar

Cheng-Lung Sung clsung

View GitHub Profile
from langchain.callbacks.base import BaseCallbackHandler
import azure.cognitiveservices.speech as speechsdk
import os
import base64
import time
class StreamDisplayHandler(BaseCallbackHandler):
def __init__(self, container, initial_text="", display_method='markdown'):
self.container = container
self.text = initial_text
self.display_method = display_method
@weihanglo
weihanglo / rust-vs-go.md
Last active April 28, 2024 01:21
【譯】Rust vs. Go

【譯】Rust vs. Go

本文譯自 Julio Merino 2018 年七月撰寫的 Rust vs. Go 一文。Julio Merino 是 G 社僱員,在 G 社工作超過 8 年,無論工作內外,都接觸開發不少 Go 語言,並撰寫 [Rust 點評][rust-review]系列文,來聽聽他對 Rust 與 Go 的想法吧。

Thanks Julio Merino for this awesome article!


@hungte
hungte / megadecrypter.py
Last active March 16, 2024 15:50
A tool to decrypt mega encrypted link, inspired from https://github.com/denysvitali/megadecrypter/ because installing Crystal-lang is not an easy thing for most people.
#!/usr/bin/env python
# Copyright 2018 Hung-Te Lin. All rights reserved.
# Use of this source code is governed by MIT license.
"""A program to decrypt mega://enc2?.... link.
Inspired from https://github.com/denysvitali/megadecrypter
"""
import base64
import binascii
@kurlov
kurlov / mkv embed soft subtitles
Created December 16, 2017 23:41
ffmpeg command to add .srt based subtitles to an .mkv file
ffmpeg -i in.mkv -f srt -i in.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt out.mkv
@leonardofed
leonardofed / README.md
Last active May 3, 2024 01:24
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


@gene1wood
gene1wood / 01_get_account_id_for_user_ec2instance_role_or_lambda.py
Last active November 9, 2022 16:40
Method to determine your AWS account ID using boto3 for either a user or an ec2 instance or lambda function
import boto3
print(boto3.client('sts').get_caller_identity()['Account'])
@lucemia
lucemia / gist:4a2e7a854caa7d6ec81f
Last active October 14, 2015 23:28
run mapreduce in bigquery
function mapper(row, emit) {
if(row.comment) {
keywords = row.comment.split(' ');
for(var i=0; i<keywords.length; i++) {
emit({keyword: keywords[i], count: 1});
}
}
}
function reducer(row, emit) {

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@bahayman
bahayman / gist:9369651
Created March 5, 2014 15:38
tcpdump http monitor
Use TCPDUMP to Monitor HTTP Traffic
1. To monitor HTTP traffic including request and response headers and message body:
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
2. To monitor HTTP traffic including request and response headers and message body from a particular source:
tcpdump -A -s 0 'src example.com and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
3. To monitor HTTP traffic including request and response headers and message body from local host to local host: