Skip to content

Instantly share code, notes, and snippets.

View GiveMeSomething's full-sized avatar
🌴
Chilling~

Minh Hoàng Tiến GiveMeSomething

🌴
Chilling~
  • undefined
  • Hanoi, Vietnam
View GitHub Profile
#!/bin/bash
if ! command -v forge >/dev/null 2>&1
then
echo "forge could not be found. Aborting deployment..."
exit 1
else
echo "forge found"
echo
fi
#!/bin/bash
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-rpc|--rpc-url)
RPC_URL="$2"
shift
shift
@GiveMeSomething
GiveMeSomething / run.sh
Created February 16, 2024 08:20
fault-tolerance docker run template
if ! [ $(docker ps -f "name=${CONTAINER_NAME}" --format '{{.Names}}') == "${CONTAINER_NAME}" ]; then
if [ $(docker ps -a -f "status=exited" -f "name=${CONTAINER_NAME}" --format '{{.Names}}') == "${CONTAINER_NAME}" ]; then
docker rm ${CONTAINER_NAME}
fi
docker run --name ${CONTAINER_NAME} \
-e POSTGRES_USER=${DB_USER} \
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
-e POSTGRESS_DB=${DB_NAME} \
-p "${DB_PORT}":5432 \
{"name":"minh","settings":"{\"settings\":\"{\\n \\\"files.eol\\\": \\\"\\\\n\\\",\\n \\\"workbench.iconTheme\\\": \\\"material-icon-theme\\\",\\n \\\"workbench.colorCustomizations\\\": {\\n \\\"tab.activeBorder\\\": \\\"#42A5F5\\\",\\n \\\"list.activeSelectionBackground\\\": \\\"#42A5F5\\\",\\n \\\"list.inactiveSelectionForeground\\\": \\\"#42A5F5\\\"\\n },\\n \\\"workbench.statusBar.visible\\\": true,\\n \\\"workbench.sideBar.location\\\": \\\"left\\\",\\n \\\"workbench.startupEditor\\\": \\\"none\\\",\\n \\\"workbench.editor.showTabs\\\": \\\"multiple\\\",\\n \\\"editor.tokenColorCustomizations\\\": {\\n \\\"[Material Theme Palenight]\\\": {\\n \\\"textMateRules\\\": [\\n {\\n \\\"scope\\\": [\\\"comment\\\", \\\"comment punctuation.definition.comment\\\"],\\n \\\"settings\\\": {\\n \\\"foreground\\\": \\\"#FFDF7D\\\"\\n }\\n }\\n ],\\n \\\"keywords\\\": \\\"#76E4F7\\\",\\n \\\"types\\\": \\\"#3EA76A\\\"\\n }\\n
@GiveMeSomething
GiveMeSomething / time.ts
Last active November 28, 2023 15:10
TypeScript `sleep()` function
export const sleep = async (ms: number): Promise<void> => {
return new Promise((resolve) => setTimeout(resolve, ms));
};
@GiveMeSomething
GiveMeSomething / terminal.sh
Created August 24, 2023 17:46
Patch Kibana low watermark
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"transient": {
"cluster.routing.allocation.disk.watermark.low": "30mb",
"cluster.routing.allocation.disk.watermark.high": "20mb",
"cluster.routing.allocation.disk.watermark.flood_stage": "10mb",
"cluster.info.update.interval": "1m"
}
}
'
@GiveMeSomething
GiveMeSomething / eslintrc.json
Last active July 13, 2023 08:54
eslint-plugin-react avoid leaked render
{
rules: [
"react/jsx-no-leaked-render": ["error", { "validStrategies": ["coerce"] }]
]
}
using System.Text.Json;
namespace YourProject
{
public class Json
{
public static string Stringify<T>(T input)
{
return JsonSerializer.Serialize<T>(input);
}
@GiveMeSomething
GiveMeSomething / protobuf_sharing.cs
Created March 12, 2023 15:13
Protobuf file sharing endpoint
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/_proto/", async ctx =>
{
ctx.Response.ContentType = "text/plain";
using var fs = new FileStream(Path.Combine(env.ContentRootPath, "Proto", "your.proto"), FileMode.Open, FileAccess.Read);
using var sr = new StreamReader(fs);
while (!sr.EndOfStream)
{
var line = await sr.ReadLineAsync();
#### Open Powershell and run the following commands to install oh-my-posh and posh-git
```
Set-ExecutionPolicy Bypass -Scope Process -Force
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
```
#### Open Notepad to config Powershell profile