Skip to content

Instantly share code, notes, and snippets.

View chenkovsky's full-sized avatar

Chongchen Chen chenkovsky

  • Fudan
  • Shanghai
View GitHub Profile
@chenkovsky
chenkovsky / fastapi_websocket_redis_pubsub.py
Created April 29, 2024 08:00 — forked from timhughes/fastapi_websocket_redis_pubsub.py
FastAPI Websocket Bidirectional Redis PubSub
"""
Usage:
Make sure that redis is running on localhost (or adjust the url)
Install uvicorn or some other asgi server https://asgi.readthedocs.io/en/latest/implementations.html
pip install -u uvicorn
Install dependencies
@chenkovsky
chenkovsky / Toast.tsx
Created April 11, 2024 06:45 — forked from davidjbeaver/Toast.tsx
SolidJS Toast Tutorial - types.ts
import { For } from "solid-js";
import store from "./store";
import { ToastObject, ToastType } from "./types";
const Toast = () => {
return (
<div class="toast-container">
<For each={store.toastStore.toasts}>
{(toast: ToastObject) => (
<div class="toast" className={toast.toastType}>
@chenkovsky
chenkovsky / client.rb
Created February 23, 2023 12:25 — forked from rjungemann/client.rb
Simplistic Ruby message queue
STDOUT.sync = true
require 'queue'
start_time = Time.now.to_i
msg = 0
queue = Queue.new("testing")
queue.subscribe do |obj|
msg += 1
@chenkovsky
chenkovsky / latency.markdown
Created July 25, 2019 09:11 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@chenkovsky
chenkovsky / cracking.md
Created May 17, 2018 03:01
Commands to license your version of Sublime Text 3.

Sublime Text 3 is a very popular text editor among developers. It is provided for free, but every few saves, you get a popup asking you to purchase Sublime Text for $80.

The Popup

Now this is a wonderful piece of software, but not everyone has the $80+ to purchase a license for Sublime Text. However, I strongly recommend to eventually buy a license if you have the money to spare to support the development of ST.

Now, let's get into the cracking

Note: At the license prompt for MacOS, enter in any garbage, even a single letter and click Use License.

@chenkovsky
chenkovsky / fasttext_lid_training.sh
Created January 12, 2018 04:44 — forked from loretoparisi/fasttext_lid_training.sh
FastText Language Detection - Training on macOS
#!bin/bash
# grab labeled dataset
wget http://downloads.tatoeba.org/exports/sentences.tar.bz2
bunzip2 sentences.tar.bz2
tar xvf sentences.tar
# macos only for gshuf
brew install coreutils
awk -F"\t" '{print"__label__"$2" "$3}' < sentences.csv | gshuf > all.txt

Ref: https://gist.github.com/vertexclique/9839383

For 3143 build 2017.09.14

VERSION PLATFORM OFFSET ORIGINAL CRACKED
3143 macOS 0x65D4 55 C3
3143   macOS   0x6219 55       C3    
3143 macOS   0x75214 55 48 89 E5 41 57 41 56 48 C7 C0 01 00 00 00 C3
@chenkovsky
chenkovsky / web-servers.md
Created November 17, 2017 07:21 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
"""Kernel K-means"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, ClusterMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.utils import check_random_state
@chenkovsky
chenkovsky / .htaccess
Last active August 29, 2015 14:06 — forked from snrbrnjna/.htaccess
#### Jekyll Layout: /_layouts/.htaccess
# Apache Configuration File
{% if ((page.auth_dir.users != empty) or (page.auth_dir.groups != empty)) %}
AuthName "Privater Bereich"
AuthType Basic
# => mehrere Require Blocks werden geodert: http://d43.me/blog/1157
AuthzUserAuthoritative Off
AuthUserFile {{ page.auth_remote_user_file }}