Skip to content

Instantly share code, notes, and snippets.

View raykao's full-sized avatar
🇨🇦
¯\_(ツ)_/¯

Raymond Kao raykao

🇨🇦
¯\_(ツ)_/¯
View GitHub Profile
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@raykao
raykao / mongoid.rb
Last active May 17, 2024 03:33
Rails + Mongoid _id attribute to id and string
# config/initializers/mongoid.rb
# convert object key "_id" to "id" and remove "_id" from displayed attributes on mongoid documents when represented as JSON
module Mongoid
module Document
def as_json(options={})
attrs = super(options)
id = {id: attrs["_id"].to_s}
attrs.delete("_id")
id.merge(attrs)
@raykao
raykao / bootstrap_sass_bower_ember-cli.md
Created November 14, 2015 23:05
How to add boostrap-sass to your ember-cli project with bower

How to work with bootstrap-sass in Ember (ember-cli) using the bower package

Install package with bower

Run:

bower install --save bootstrap-sass
@raykao
raykao / post-receive
Last active April 29, 2016 16:30
An example of a git post-receive hook for deploying https://github.com/womenandtech/editor
#!/bin/bash
# load enviroment variables and other necessary itemes (e.g. node via nvm)
source ~/.bash_profile
# Set Directory locations:
#
# WORKING_DIR -> The directory that actually houses the working code
WORKING_DIR="/home/<username>/editor.womenandtech.com"
# GIT_DIR -> The git repo DIR
@raykao
raykao / example.nginx.config.file.com
Created April 29, 2016 16:23
An example nginx config file for ember deployment
server {
listen 80;
server_name yourdomain.com;
root /home/yourUserAccount/yourdomain.com/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
@raykao
raykao / install-mariadb.sh
Last active February 10, 2017 15:48
Scripted mariadb 10.1 install on Ubuntu without user interaction and auto password entry.
#!/usr/bin/env bash
export DEBIAN_FRONTEND="noninteractive"
export PASSWORD="H3ll0W0rld!"
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password password $PASSWORD"
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password_again password $PASSWORD"
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
@raykao
raykao / galera.cnf
Created February 10, 2017 19:10
Basic MariaDB Galera Cluster configuration file.
# /etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
@raykao
raykao / first-node.sh
Created February 10, 2017 19:58
Downloads the galera.cnf config file to the MariaDB config.d path, then replaces values with the current machine's info.
#!/usr/bin/env bash
sudo -i
cd /etc/mysql/conf.d
wget https://gist.githubusercontent.com/raykao/027e42847392a0eafb6c7b51c3291191/raw/a328e20eb13e2e129101dea460e1bd592d7f1c3b/galera.cnf
sed -i "s/first_ip/$(ip -4 addr ls eth0 | awk '/inet / {print $2}' | cut -d"/" -f1)/g" galera.cnf
{
"$schema": "http://schema.management.azure.com/schemas/2016-09-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"deploymentPrefix": {
"type": "string",
"metadata": {
"description": "Deployment Prefix name. Added to the beginning of each resource."
}
},
{
"$schema": "https://schema.management.azure.com/schemas/2016-09-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"deploymentPrefix": {
"type": "string"
},
"indexCount": {
"type": "int"
},