Skip to content

Instantly share code, notes, and snippets.

View lh0x00's full-sized avatar
💭
do something, something great 📝

Hieu Lam lh0x00

💭
do something, something great 📝
View GitHub Profile
@lh0x00
lh0x00 / nginx-tuning.md
Created May 18, 2020 04:16 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@lh0x00
lh0x00 / sysctl.conf
Created May 18, 2020 11:45 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@lh0x00
lh0x00 / index.html
Created August 8, 2021 04:51 — forked from kapral18/index.html
Native AsyncAwait vs babel regenerator vs promises (http://jsbench.github.io/#bb78a677c5850d0830ff7d818d5ac4cd) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Native AsyncAwait vs babel regenerator vs promises</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@lh0x00
lh0x00 / index.html
Last active August 8, 2021 04:53 — forked from kapral18/index.html
promises vs async / await vs generator
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Native AsyncAwait vs babel regenerator vs promises</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@lh0x00
lh0x00 / Component.js
Created September 11, 2022 11:13 — forked from smontlouis/Component.js
React Native - Fixed header/footer disappearing on scroll
import React, { PropTypes, Component } from 'react'
import {
Animated,
ScrollView,
Text,
View,
} from 'react-native'
import EStyleSheet from 'react-native-extended-stylesheet'
const styles = EStyleSheet.create({
@lh0x00
lh0x00 / nonAccentVietnamese.js
Created November 19, 2022 16:42 — forked from jarvisluong/nonAccentVietnamese.js
Converting standard Vietnamese Characters to non-accent ones (Chuyển đổi ký tự tiếng Việt sang không dấu). Example: hải -> hai
// This function converts the string to lowercase, then perform the conversion
function toLowerCaseNonAccentVietnamese(str) {
str = str.toLowerCase();
// We can also use this instead of from line 11 to line 17
// str = str.replace(/\u00E0|\u00E1|\u1EA1|\u1EA3|\u00E3|\u00E2|\u1EA7|\u1EA5|\u1EAD|\u1EA9|\u1EAB|\u0103|\u1EB1|\u1EAF|\u1EB7|\u1EB3|\u1EB5/g, "a");
// str = str.replace(/\u00E8|\u00E9|\u1EB9|\u1EBB|\u1EBD|\u00EA|\u1EC1|\u1EBF|\u1EC7|\u1EC3|\u1EC5/g, "e");
// str = str.replace(/\u00EC|\u00ED|\u1ECB|\u1EC9|\u0129/g, "i");
// str = str.replace(/\u00F2|\u00F3|\u1ECD|\u1ECF|\u00F5|\u00F4|\u1ED3|\u1ED1|\u1ED9|\u1ED5|\u1ED7|\u01A1|\u1EDD|\u1EDB|\u1EE3|\u1EDF|\u1EE1/g, "o");
// str = str.replace(/\u00F9|\u00FA|\u1EE5|\u1EE7|\u0169|\u01B0|\u1EEB|\u1EE9|\u1EF1|\u1EED|\u1EEF/g, "u");
// str = str.replace(/\u1EF3|\u00FD|\u1EF5|\u1EF7|\u1EF9/g, "y");
@lh0x00
lh0x00 / docker-compose-v1.yml
Created November 21, 2022 11:16 — forked from markheath/docker-compose-v1.yml
Elasticsearch docker compose examples
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.1
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
var utc;
var navigator = { appName: "" };
var _global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
var exports = {};
(function (global, factory) {
factory(exports);
@lh0x00
lh0x00 / prompt_alpaca_lora.py
Created January 6, 2024 13:31 — forked from ahoho/prompt_alpaca_lora.py
Create a huggingface pipeline with a lora-trained alpaca
from typing import Optional, Any
import torch
from transformers.utils import is_accelerate_available, is_bitsandbytes_available
from transformers import (
AutoTokenizer,
AutoModelForCausalLM,
GenerationConfig,
pipeline,