Skip to content

Instantly share code, notes, and snippets.

View khanha2's full-sized avatar
💭
I may be slow to respond.

Khanh Nguyen khanha2

💭
I may be slow to respond.
View GitHub Profile
@adtac
adtac / Dockerfile
Last active May 28, 2024 01:38
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@mikeckennedy
mikeckennedy / turnstile.py
Last active April 6, 2024 03:10
Python code for server-side Cloudflare validation (paired with client-side Cloudflare code)
# See details about Turnstile at https://blog.cloudflare.com/turnstile-private-captcha-alternative/
from typing import Optional
import pydantic
import requests
cloudflare_secret_key: Optional[str] = None
@rubikill
rubikill / export_log.sh
Last active November 7, 2023 16:03
Build psql report RDS using pgbadger
# sh export_log.sh db_identifier
# If any of this commands fail, stop script.
set -e
db_identifier=$1
date=$(date -v-7H +'%Y-%m-%d-%H')
log_file=~/Desktop/postgresql.log.$date
report_file=~/Desktop/out.$date.html
page_size=100000
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@abearman
abearman / resnet50.py
Last active June 21, 2020 16:45
Showing that a simple ResNet50 Keras network run on CIFAR10 does not have reproducible validation loss with learning rate = 0
import keras
import numpy as np
from keras.datasets import cifar10
from keras.applications.resnet50 import ResNet50
from keras.layers import GlobalAveragePooling2D, Dense
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Model
from skimage.transform import resize
from IPython import embed
@cdiggins
cdiggins / react-best-practices.md
Created January 25, 2018 16:20
React Best Practices
@philiph
philiph / using-asdf.md
Last active April 9, 2024 12:54
Using asdf to manage ruby, erlang, elixir, node.js, Postgres

Note: this assumes you are using ZSH shell.

Installation

Install asdf:

$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.4.0
$ echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
@ibraheem4
ibraheem4 / postgres-brew.md
Last active June 28, 2024 18:57 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 3, 2024 12:57
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: