Skip to content

Instantly share code, notes, and snippets.

View vyshane's full-sized avatar
💻
Coding

Vy-Shane Xie vyshane

💻
Coding
View GitHub Profile
@vyshane
vyshane / quick-xcodeproj.sh
Created November 4, 2019 16:27
Quickly generate a new Xcode project using Swift Package Manager, and open the project's main.swift in the Xcode editor
#!/bin/sh
#
# Quickly generate a new Xcode project using Swift Package Manager,
# and open the project's main.swift in the Xcode editor.
pwd=$(pwd)
mkdir $1
cd $1
swift package init
@vyshane
vyshane / FoundationDbDockerTestKit.scala
Last active February 12, 2019 14:22
docker-it-scala trait that provides a FDBDatabase via the foundationdb/foundationdb Docker image
// Copyright 2019 Vy-Shane Xie
package mu.node.sample.fdb
import com.apple.foundationdb.record.provider.foundationdb.FDBDatabaseFactory
import com.spotify.docker.client.messages.PortBinding
import com.whisk.docker.testkit.ContainerState.{HasId, Ready}
import com.whisk.docker.testkit.{
BaseContainer,
ContainerCommandExecutor,
@vyshane
vyshane / haproxy-esp-cors.cfg
Last active February 1, 2018 06:30
GCP's Extensible Service Proxy cannot do Cross-Origin Resource Sharing. We put a HAProxy in front of it to handle CORS.
# Add CORS headers when Origin header is present
capture request header origin len 128
http-response set-header Access-Control-Allow-Origin %[capture.req.hdr(0)] if { capture.req.hdr(0) -m found }
http-response set-header Access-Control-Allow-Methods GET,\ HEAD,\ OPTIONS,\ POST,\ PUT if { capture.req.hdr(0) -m found }
http-response set-header Access-Control-Allow-Credentials true if { capture.req.hdr(0) -m found }
http-response set-header Access-Control-Allow-Headers Origin,\ Accept,\ X-Requested-With,\ Content-Type,\ Access-Control-Request-Method,\ Access-Control-Request-Headers,\ Authorization if { capture.req.hdr(0) -m found }
# Google Cloud Platform ESP does not support CORS
# We want to return a 204 regardless
http-response set-status 204 if { capture.req.hdr(0) -m found } METH_OPTIONS
@vyshane
vyshane / generate-self-signed-ssl-assets.sh
Created June 14, 2016 14:35
Utility script to generate self-signed SSL certificate assets
#!/bin/bash
set -e
function print_usage {
cat << EOF
Usage: $0 hostname destination_directory
Generate self-signed SSL certificate assets for hostname, placing the files in the destination_directory
The following files will be created:
@vyshane
vyshane / gist:e77b44ab9d0d20dca642
Created October 3, 2015 12:11
Recursively set permissions for directories to 755 and files to 644
chmod -R u+rwX,go+rX,go-w /path/to/dir
@vyshane
vyshane / buildandrun.sh
Last active August 29, 2015 14:07
Example Docker build and run script
#!/usr/bin/env bash
org=kojai
app=web-services
branch=`git rev-parse --abbrev-ref HEAD`
if [ "$branch" == master ]; then
branch=latest
fi
@vyshane
vyshane / elixir_notes.md
Last active August 29, 2015 14:03
Elixir Notes #1: Built-in Types