Skip to content

Instantly share code, notes, and snippets.

View lemonlatte's full-sized avatar

Jim Yeh lemonlatte

  • Taipei, Taiwan
  • 03:53 (UTC +08:00)
View GitHub Profile
@lemonlatte
lemonlatte / addUser.sh
Created July 9, 2012 03:22
Login authentication from a LDAP server
#!/bin/sh
dn='dc=math,dc=nccu,dc=edu,dc=tw'
username='jim.yeh'
uid='jim.yeh'
gid='student'
cat << EOF > user_example.ldif
dn: cn=$username,ou=users,ou=login,$dn
@lemonlatte
lemonlatte / iftop.sh
Last active July 24, 2025 07:27
Amazon Linux install iftop
amazon-linux-extras install epel -y
yum-config-manager --enable epel
yum install iftop
@lemonlatte
lemonlatte / pydantic_errors_zh.py
Created May 9, 2024 01:23
pydantic error 翻譯
# import inspect
# from pydantic import errors
# gpt_translate(
# {
# k: v.msg_template
# for k, v in dict(inspect.getmembers(errors, inspect.isclass)).items()
# if issubclass(v, errors.PydanticValueError) and hasattr(v, "msg_template")
# }
# )
PYDANTIC_ERROR_MSG_TEMPLATE_ZH: dict[str, str] = {
@lemonlatte
lemonlatte / streaming-csv-generator.py
Created March 27, 2024 12:11
streaming-csv-generator
def streaming_csv_data(supplier_id: str):
buffer = io.StringIO()
with CSVWriter(buffer) as writer:
for row in _iter_data():
writer.writerow(row)
buffer.seek(0)
yield buffer.read()
buffer.seek(0)
buffer.truncate(0)
@lemonlatte
lemonlatte / setup.sh
Created February 24, 2024 05:29
Install tensorflow over mac m1
brew install miniconda
conda init (basename "$SHELL")
conda create -n tensorflow-env-39 python=3.9
conda install -c apple tensorflow-deps
conda install scikit-learn pandas jupyter
pip install tensorflow-macos
@lemonlatte
lemonlatte / receipt5.md
Created December 22, 2019 04:13
How to make a Raspberry Pi an RTSP streamer and how to consume this?

How to make a Raspberry Pi an RTSP streamer and how to consume this?

You should perform the following steps on a new SD card. Don't mess with existing solutions. It is not worth the $5 to loose something working.

I'm used to use Raspbian, so my suggestion is to go to https://www.raspberrypi.org/downloads/raspbian/ and download the latest Raspbian Stretch Lite. Flash it to your SD card. Mine have usually 16 GB, but maybe smaller work too. I'm using Etcher on macOS, a great tool for flashing.

After successful flashing enable ssh and prepare a running Wifi configuration.

A Wifi adapter should be attached to your Pi of course.

@lemonlatte
lemonlatte / openssl.sh
Last active January 16, 2024 05:59
Make HTTPS requests by openssl
openssl s_client -connect example.com:443 -ign_eof
POST /your-endpoint HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: <LengthOfYourJSONData>
{"key1":"value1", "key2":"value2"}
@lemonlatte
lemonlatte / Caddyfile
Created December 11, 2023 01:13
Simple Caddyfile
https://localhost:8888 {
tls /usr/local/etc/ssl/localhost.pem /usr/local/etc/ssl/localhost-key.pem
handle_path /api* {
rewrite /api/ /
reverse_proxy localhost:8000
}
reverse_proxy /* localhost:8080
}
celeryd -I q2_tasks -l info -Q tasks
celeryd -I q2_tasks -l info -Q count
@lemonlatte
lemonlatte / ingress.yaml
Created April 6, 2021 09:31
ingress nginx www redirect
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($host = "www.example.com") {
return 308 https://example.com$request_uri;
}
name: example-www