Skip to content

Instantly share code, notes, and snippets.

View hoangbits's full-sized avatar
🏝️
Working from earth

Le Gia Hoang hoangbits

🏝️
Working from earth
  • Thanh Hoa, Vietnam
  • 23:57 (UTC +07:00)
View GitHub Profile
@hoangbits
hoangbits / init_db.sh
Last active July 5, 2021 14:29
wait for mysql and create schemas
#!/bin/bash
# Initialize MySQL database.
# ADD this file into the container via Dockerfile.
# Assuming you specify a VOLUME ["/var/lib/mysql"] or `-v /var/lib/mysql` on the `docker run` command…
# Once built, do e.g. `docker run your_image /path/to/docker-mysql-initialize.sh`
# Again, make sure MySQL is persisting data outside the container for this to have any effect.
set -e
set -x
from sqlalchemy import (String,
Integer,
engine_from_config,
Column)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base_1 = declarative_base()
Base_2 = declarative_base()
@hoangbits
hoangbits / package.json
Created June 6, 2021 07:14
liveview_package.json
{
"repository": {},
"description": " ",
"license": "MIT",
"scripts": {
"deploy": "webpack --mode production",
"watch": "webpack --mode development --watch"
},
"dependencies": {
"@tailwindcss/forms": "^0.2.1",
@hoangbits
hoangbits / git-pull-all
Created June 5, 2021 10:36 — forked from grimzy/git-pull-all
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@hoangbits
hoangbits / UserListBulkAction.tsx
Created June 1, 2021 23:09
useObservableState
import * as React from "react";
import { FC, useEffect } from "react";
import { BulkDeleteButton, BulkExportButton, Loading } from "react-admin";
import { useSelector } from "react-redux";
import { useQuery } from "react-query";
import { reservationAPI } from "@/api";
import { ReservationStatus } from "@/utils/typing/reservation";
import { GetListResult } from "ra-core/esm/types";
import { forkJoin, from, Observable, of } from "rxjs";
import { csDataProvider, User } from "@/utils";
import React from "react";
import logo from "./logo.svg";
import { useState } from "react";
import "./App.css";
function App() {
const [number, setNumber] = useState();
const highestPrime = (num: number) => {
for (let i = num; i > 2; i--) {
pylint --rcfile=.pylintrc backend/**/*.py -r y
@hoangbits
hoangbits / gen.sh
Last active April 4, 2021 04:45
generate ECDSA (ES384)
# ref:
# https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations
# https://stackoverflow.com/questions/15686821/generate-ec-keypair-from-openssl-command-line
# openssl ec help
# 1.1 generate private key in EC format:
openssl ecparam -name secp384r1 -genkey -noout -out auth-private.ec.key
# 1.2 convert EC format to a non-encrypted PKCS8 format:
openssl pkcs8 -topk8 -nocrypt -in auth-private.ec.key -out auth-private.pem
@hoangbits
hoangbits / nginx.conf
Last active April 2, 2021 11:29
nginx reverse config
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
@hoangbits
hoangbits / webpack.config.js
Created March 11, 2021 08:56
typescript, scss module react webpackt
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const LinkTypePlugin = require("html-webpack-link-type-plugin")
.HtmlWebpackLinkTypePlugin;
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const Dotenv = require("dotenv-webpack");