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 / 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);
}
@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 / open-chrome-tabs-in-safari.scpt
Last active July 16, 2023 15:52 — forked from paulirish/open-chrome-tabs-in-safari.scpt
open all chrome tabs of all windows in safari
tell application "Google Chrome"
set window_list to every window
repeat with the_window in window_list
# For each Window in Chrome, create a new Window in Safari respectively
tell application "Safari"
make new document
activate
@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 / 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 / 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 / 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
@kentliau
kentliau / JSONView.css
Last active July 6, 2019 21:31
JSONView dark theme (Google Chrome Extension)
body {
white-space: pre;
font-family: 'Ubuntu Mono';
font-size: 16px;
line-height:20px;
color: white;
background-color: #2B2A27;
}
.property {