Skip to content

Instantly share code, notes, and snippets.

View BbsonLin's full-sized avatar
🏚️
Working...

Bobson Lin BbsonLin

🏚️
Working...
View GitHub Profile
import 'package:flutter/material.dart';
class CustomActionPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Custom Action Page")),
body: Center(
child: CustomActionButton(
doAction: openDialog,
@BbsonLin
BbsonLin / celery_flowerd.sh
Last active December 25, 2018 09:27
Daemonize celery flower by `start-stop-daemon`, in pipenv's virtualenv
#!/bin/bash
NAME=flowerd
DESC="flower daemon"
PIDFILE=./$NAME.pid
PIPENV_VENV_PATH=`pipenv --venv`
FLOWER="$PIPENV_VENV_PATH/bin/celery flower"
import serial
FLAG = 0x7E
HEX_NUMBER = 0xFF
HEX_NUMBERS = [0xFF, 0x15]
# INT <---> STRING(hex)
print(FLAG, type(FLAG)) # 126 <class 'int'>
print(hex(FLAG), type(hex(FLAG))) # 0x7e <class 'str'>
print(int(hex(FLAG), 16)) # 126
@BbsonLin
BbsonLin / python3_filter_dict.py
Created November 14, 2018 08:10
How to filter dictionary key or value by list
d = {'Bobson': 20, 'Bob': 22, 'Lin': 33}
# filter by key
d2 = {k : v for k,v in filter(lambda t: t[0] in ['Bobson', 'Lin'], d.items())}
print('d2 = ', d2)
# filter by value
d3 = {k : v for k,v in d.items() if v in [22, 33]}
print('d3 = ', d3)
@BbsonLin
BbsonLin / .vimrc
Last active October 12, 2018 12:48
My .vimrc. Need to install https://github.com/junegunn/vim-plug first.
set nu
set bg=dark
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif
call plug#begin('~/.vim/plugged')

Setup for developer

  1. Install Basic
sudo apt install vim git tig htop
  1. Git cz-cli (Ref)
@BbsonLin
BbsonLin / python3_time_snippet.py
Created April 26, 2018 14:04
How time transfer is always being annoying, so I make this gist for record~
import time
from datetime import datetime, timedelta
print('------------------------------------')
# Get now timestamp & datetime
now_dt = datetime.today()
print('Now datetime is:', now_dt)
import time
import hashlib
serial = 'QQ0001'
if __name__ == '__main__':
now_time = time.time()
print(now_time)
h1 = hashlib.sha1()
h1.update((str(now_time) + serial).encode('utf-8'))
@BbsonLin
BbsonLin / dev_setup.md
Last active June 4, 2018 01:35
Backend System Develop Setup (Flask + Vuejs)

Backend Setup

Using the pipenv for a clean Python environment

1. Install pipenv

$ sudo apt-get install python3-pip
$ sudo pip3 install pipenv
@BbsonLin
BbsonLin / animate-pseudo.scss
Last active December 6, 2017 01:56
Animation with pseudo element
// html code
// <a href="#" class="btn btn--white">Button</a>
$color-grey-dark: #777;
$color-white: #fff;
$color-black: #000;
html {
// Let 1rem = 10px
font-size: 62.5%;