Skip to content

Instantly share code, notes, and snippets.

View erichsu's full-sized avatar

eric.hsu erichsu

  • Ubiquiti, Inc
  • Taipei, TW
View GitHub Profile

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

######################
# Options
######################
NULL=
REVEAL_ARCHIVE_IN_FINDER=false
FRAMEWORK_NAME="StreamingFramework"
#"${PROJECT_NAME}"
@erichsu
erichsu / Install_tmux
Last active November 18, 2016 06:39 — forked from simme/Install_tmux
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@erichsu
erichsu / A.LICENSE.md
Created June 12, 2017 15:07 — forked from gonzalezreal/A.LICENSE.md
Using Realm with Value Types

Copyright 2017 Guillermo Gonzalez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE U

Homebrew Permissions Denied Issues Solution

Installing and fixing node.JS


brew install node

@erichsu
erichsu / jq_group_by_count.sh
Created January 28, 2021 14:29 — forked from stefaneng/jq_group_by_count.sh
jq - Group by count
echo '[{"key": 1}, {"key": 2}, {"key": 1}]' | jq 'group_by (.key)[] | {key: .[0].key, length: length}'
@erichsu
erichsu / remove_old_builds.sql
Created September 30, 2021 20:29 — forked from david-zw-liu/remove_old_builds.sql
Keep 1000 builds per repos for DroneCI (sqlite3 version >= 3.25 required)
-- Thank @sbengo to figure out foreign_keys constraints is defaults to false in sqlite
-- Enable to delete logs by cascading delete
PRAGMA foreign_keys = ON;
WITH n_build_ids_per_repo as (
SELECT build_id
FROM (
SELECT
build_id,
build_repo_id,
@erichsu
erichsu / TypeErasure.swift
Created November 17, 2021 08:33 — forked from iwill/TypeErasure.swift
Code Snippet: Type Erasure for Protocol with AssociatedType, Self and static methods
// Type-Erasure
// - seealso: [AnyIterator](https://github.com/apple/swift/blob/2fe4254cb712fa101a220f95b6ade8f99f43dc74/stdlib/public/core/ExistentialCollection.swift.gyb#L45)
// MARK: remove `Equatable` if not needed
public protocol Protocol: Equatable {
// MARK: `Protocol` requirements
associatedtype AssociatedType
func methodOfProtocol() -> Self.AssociatedType
}
@ViewBuilder
private func build<#name#>(_ viewStore: ViewStoreType) -> some View {
}
@erichsu
erichsu / Contents.swift
Created May 9, 2022 23:07 — forked from sgr-ksmt/Contents.swift
JSONDecoder+keypath
//: Playground - noun: a place where people can play
import UIKit
var json: String = """
{
"result": {
"persons": [
{