Skip to content

Instantly share code, notes, and snippets.

@kentliau
kentliau / prezto.sh
Last active December 5, 2023 05:47 — forked from arvind-iyer/prezto.sh
Install prezto on ubuntu
#!/bin/bash
prezto.sh(){
#clear
#sudo apt-get install -y git
#sudo apt-get update && sudo apt-get install -y zsh
# Get prezto
#git clone --recursive https://github.com/sorin-ionescu/prezto.git ~/.zprezto
# Backup zsh config if it exists
@kentliau
kentliau / ssh_without_pem
Created August 19, 2023 04:10 — forked from kevinjam/ssh_without_pem
Access EC2 Linux box over ssh without .pem file SHELL SSH AWS AMAZON LINUX EC2 BASH You may be in the situation where you need to access your EC2 instance from any machine, not necessarily your own. It's a pain to carry around your .pem file and a bad idea to leave it on someone elses machine too. Here's a solution to let you login to your insta…
1. Login to your EC2 instance using your .pem file
ssh -i your_pem_file.pem ubuntu@ec2-________.compute-1.amazonaws.com
2. Create a new user that will access the instance using a password:
$ sudo useradd -s /bin/bash -m -d /home/USERNAME -g root USERNAME
where:
-s /bin/bash : use /bin/bash as the standard shell
-m -d /home/USERNAME : create a home directory at /home/USERNAME
@kentliau
kentliau / ascii_box.sublime-snippet
Last active March 29, 2023 05:11
Sublime snippet for drawing ascii box
<snippet>
<content><![CDATA[
https://en.wikipedia.org/wiki/Box-drawing_character
┌─┬─┐
│ │ │
├─┼─┤
│ │ │
└─┴─┘
╔═╦═╗
@kentliau
kentliau / object_flattener_recursive.js
Last active March 24, 2023 01:56
Recursively go through an object with Javascript, made for exposing tailwind colors object to a flatten CSS/SCSS variables list
let deeplyNestedObject = {
'foo1': 'bar1',
'lorem1': 'ipsum1',
'dolor1': {
'foo2': 'bar2',
'lorem2': 'ipsum2',
'dolor2': {
'foo3': 'bar3',
'lorem3': 'ipsum3',
'dolor3': {
@kentliau
kentliau / tailwind.config.js
Last active March 24, 2023 01:56
Tailwind Config with plugin to expose color as css var and generate a SCSS var file
/** @type {import('tailwindcss').Config} */
const fs = require('fs');
const path = require('path');
const colors = require('tailwindcss/colors');
module.exports = {
prefix: 'tw-',
content: [
'./src/**/*.{html,vue}',
],
@kentliau
kentliau / AppButton.js
Created May 26, 2022 16:45
Quick Vue and Tailwind Template
export default {
template: `
<button class="bg-gray-200 hover:bg-gray-400 border rounded px-5 py-2 disabled:cursor-not-allowed" :disabled="processing">
<slot />
</button>
`,
data() {
return {
processing: true
@kentliau
kentliau / type_inference.swift
Last active June 12, 2021 15:48
Type Inference in Swift’s Closure
// Credit: Stanford’s Developing iOS8 App with Swift Course (Available via iTunes U Course via Apple Swift Portal)
// This function itself accept a closure, and return nothing
func performOperation(operation: (Double, Double) -> Double) {
println(operation(20.0,10.0))
}
// Thanks to type inference, we can further simplify the following
// function call that accept a well defined closure as argument
performOperation({ (op1: Double, op2: Double) -> Double in
return op1 * op2
017-2854711,019-3740079,010-3073238,017-2854711,012-9145123,019-2695443,019-2645195,019-2695443,017-2854711,017-2854711,019-6428238,016-2491135,013-3588761,012-2043531,019-3320076,019-4698145,019-2695443,019-3320076,019-2695443,016-2491135
013-2615416,019-2584307,019-2695443,012-9145123,017-3729633,013-3588761,013-3586224,013-3586224,011-12199847,012-2043531,017-2854711,019-3789605,019-6901018,010-8676446,019-4209702,019-3320076,013-3588761,019-2584307,016-9645676
012-3452454,019-6428238,012-3452454,016-9645676,012-3452454,012-3539704,019-2584307,019-6901018,019-6901018,019-2695443,012-3539704,010-8676446,019-3789605,019-2695443,019-2645195,019-3320076,017-9922343,012-3628991,016-2491135
019-2695443,019-2645195,013-2615416,019-2695443,019-2695443,017-2854711,013-3588761,013-3586224,017-2854711,017-9922343,019-6901018,017-3729633,013-3586224,019-6428238,010-8676446,013-3586224,012-9145123,012-2720926,019-2584307
019-3320076,013-3586224,017-9922343,019-2104383,017-2854711,013-2615416,016-9645676,019-2194442
@kentliau
kentliau / styles.css
Created January 1, 2017 10:21
QLMarkdown Github Flavored Markdown Style
@font-face {
font-family: octicons-link;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm1ozezUeLEaUjhaDSuXHwVRgvLJn1tQ7xiuVv/ocTRF42mNgZGBgYGbwZOBiAAFGJBIMAA
@kentliau
kentliau / backup_script.js
Last active August 30, 2023 08:12
OneTab backup script
function backup() {
function downloadBlob(filename, blobUrl) {
var element = document.createElement('a');
element.setAttribute('href', blobUrl);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}