Skip to content

Instantly share code, notes, and snippets.

View avence12's full-sized avatar
😱
stackoverflow

MinHsien Chang (LightBlue) avence12

😱
stackoverflow
View GitHub Profile
#Inspired by https://www.facebook.com/will.fans/posts/pfbid024m6NRVTUQwcTVFoRtT1N8AS3gJMEbW1EkkxoSDDQRCTp18pcXDe3ZcAXEanmEBchl
#Visit https://colab.research.google.com/
!export FULL_PATH=/content/gdrive/MyDrive/${YOUR_EPUB_FILE}
#mount Google Drive
from google.colab import drive
drive.mount('/content/gdrive')
!git clone https://github.com/doggy8088/bilingual_book_maker
%cd bilingual_book_maker
@avence12
avence12 / kssh.sh
Created July 10, 2019 06:40
Interactive fzf UI for getting into kubernetes pods
#!/bin/bash
raw_selection=$(kubectl get pods | grep -v ^NAME | fzf --multi)
selection=()
arr=($raw_selection)
for ((i=0; i<${#arr[@]}; i+=5)); do
selection+=("${arr[$i]}")
done
package data
import (
"net/http"
"github.com/gin-gonic/gin"
)
// GetDataAPIHealthHandler GET /health-dataapi to expose heathy check result of data API
func GetDataAPIHealthHandler(c *gin.Context) {
// do something to check heathy of data API
package main
import (
dataapi "myproj/pkg/myapi/data"
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
@avence12
avence12 / sendgmail.py
Last active March 4, 2018 15:20
Script to send gmail with attachment
#!/usr/bin/env python
# USAGE: ./sendgmail.py path_to_filename [assigned_attachment_name]
# if not assign assigned_attachment_name, the attachment is named as original path_to_filename
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP
import smtplib
@avence12
avence12 / gitlab-backup.sh
Created February 2, 2017 15:26
A script to backup GitLab repositories.
#!/bin/bash
# A script to backup GitLab repositories.
GLAB_BACKUP_DIR=${GLAB_BACKUP_DIR-"gitlab_backup"} # where to place the backup files
GLAB_TOKEN=${GLAB_TOKEN-"YOUR_TOKEN"} # the access token of the account
GLAB_GITHOST=${GLAB_GITHOST-"gitlab.com"} # the GitLab hostname
GLAB_PRUNE_OLD=${GLAB_PRUNE_OLD-true} # when `true`, old backups will be deleted
GLAB_PRUNE_AFTER_N_DAYS=${GLAB_PRUNE_AFTER_N_DAYS-7} # the min age (in days) of backup files to delete
GLAB_SILENT=${GLAB_SILENT-false} # when `true`, only show error messages
GLAB_API=${GLAB_API-"https://gitlab.com/api/v3"} # base URI for the GitLab API
@avence12
avence12 / gb_fetch_gogs_repo.md
Created June 5, 2016 10:27
Use GB to manage Github and self-hosted private repository at the same time
//Example 1: new Runnable
Runnable run = new Runnable() {
public void run() {
System.out.println("run me!");
}
};
// one line lambda
Runnable run = () -> System.out.println("run me!");
// Exmaple 2: Iterate Map
/**
The example code is used to illustrate the method of updating stock price on Google Spreadsheet
See the post for details - https://www.lightblue.asia/realtime-tw-stockprice-in-google-spreadsheet
**/
function STOCK_() {
this.ticker = "";
this.name = "";
this.curPrice = 0.0;
this.high = 0.0;