Skip to content

Instantly share code, notes, and snippets.

@dqtweb
dqtweb / install_pyenv.md
Created September 22, 2024 04:52 — forked from trongnghia203/install_pyenv.md
Install pyenv
#!/usr/bin/env python3
'''
always getting the most recent frame of a camera
================================================
Usage:
------
freshest_camera_frame.py
@dqtweb
dqtweb / algo-fisher-yates.java
Created August 20, 2024 01:46
Fisher-Yates algorithm (or Knuth Shuffle)
public static List<Object> shuffleList(List<Object> list) {
Random rand = new Random();
// convert to array
Object[] array = list.toArray();
for (int i = array.length - 1; i > 0; i--) {
// generate random number in range 0 to i
int j = rand.nextInt(i + 1);
// swap array[i] with array[j]
Object temp = array[i];
@dqtweb
dqtweb / install-nvm-zsh.txt
Created January 10, 2024 10:33 — forked from mike-casas/install-nvm-zsh.txt
install nvm on mac with zsh shell
After install zsh
- brew update
- brew install nvm
- mkdir ~/.nvm
after in your ~/.zshrc or in .bash_profile if your use bash shell:
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
@dqtweb
dqtweb / http-benchmark.md
Created January 2, 2024 04:47 — forked from denji/http-benchmark.md
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@dqtweb
dqtweb / client.js
Created March 3, 2023 22:48 — forked from naoki-sawada/client.js
Simple socket.io room and auth example
const io = require('socket.io-client');
const socket = io('http://localhost:3000', {
transportOptions: {
polling: {
extraHeaders: {
'Authorization': 'Bearer abc',
},
},
},
@dqtweb
dqtweb / jupyter.service
Created April 26, 2020 10:30 — forked from r-darwish/jupyter.service
Jupyterlab as a systemd service
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
ExecStart=/home/roeyd/Notebook/.env/bin/jupyter lab --port 9090
WorkingDirectory=/home/roeyd/Notebook
[Install]
WantedBy=default.target
@dqtweb
dqtweb / utf8csv.py
Created April 10, 2020 02:31
Add UTF-8 support to csv content file
# so that you can open with excel
def addUTF8Bom(filename):
f = codecs.open(filename, 'r', 'utf-8')
content = f.read()
f.close()
f2 = codecs.open(filename, 'w', 'utf-8')
f2.write(u'\ufeff')
f2.write(content)
f2.close()
@dqtweb
dqtweb / gist:dffc0d141b6efe4cdc2760ff435866a6
Created April 7, 2020 03:57
javascript: sort array of objects
// example, we want to sort list of objects based on an object's attribute. ex: "age"
var peopleList = [{"name": "Laura", "age":5}, {"name": "Peppa", "age": 40}, {"name": "Josh", "age":22}];
var comparision = function(a, b) { return a.age > b.age ? 1 : -1; };
SELECT
type
, count(*)
, count(DISTINCT u)
, count(CASE WHEN plat=1 THEN u ELSE NULL END)
, count(DISTINCT CASE WHEN plat=1 THEN u ELSE NULL END)
, count(CASE WHEN (type=2 OR type=6) THEN u ELSE NULL END)
, count(DISTINCT CASE WHEN (type=2 OR type=6) THEN u ELSE NULL END)
FROM
t