Skip to content

Instantly share code, notes, and snippets.

View joshteng's full-sized avatar

Joshua Teng joshteng

View GitHub Profile
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# or via wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# or via fetch:
# sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#
# As an alternative, you can first download the install script and run it afterwards:
_xamzrequire=function(){function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){return i(t[s][1][e]||e)},l,l.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}return e}()({115:[function(e,t,r){(function(r){(function(){var n=e("../core"),i=e("../region_config"),o={isArnInParam:function(e,t){var r=(e.service.api.operations[e.operation]||{}).input||{},i=r.members||{};return!(!e.params[t]||!i[t])&&n.util.ARN.validate(e.params[t])},validateArnService:function(e){var t=e._parsedArn;if("s3"!==t.service&&"s3-outposts"!==t.service&&"s3-object-lambda"!==t.service)throw n.util.error(new Error,{code:"InvalidARN",message:"expect 's3' or 's3-outposts' or 's3-object-lambda' in ARN service component"})},validateArnAccount:function(e){if(!
{
"name": "Josh"
}
@joshteng
joshteng / psql_encoding.markdown
Last active October 31, 2022 19:23 — forked from turboladen/psql_encoding.sql
This solves Postgresql's encoding issue (happened to me when running postgres on my vagrant box) The error happens when trying to create db "rake db:create": Error message: "encoding UTF8 does not match locale en_US; the chosen LC_CTYPE setting requires encoding LATIN1"
sudo su postgres
psql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate=true where datname='template1';
@joshteng
joshteng / dokku_setup.md
Last active May 12, 2022 14:38
Using Dokku to deploy a Rails Application

#Goal Deploy your Rails App super easily with Dokku on Digital Ocean cheap cheap!

##Notes

  • Follow 12 factor design (include the rails_12factor gem)
  • Don't forget your Procfile with the command to start up your application server
  • I prefer using external hosted logging services like Logentries (not in this guide)
  • Set up performance monitoring AppSignal or New Relic (not in this guide)
@joshteng
joshteng / app.py
Created March 30, 2020 10:02 — forked from seanbehan/app.py
Flask with Django ORM
'''
Run the following commands (bc. gists don't allow directories)
pip install flask django dj-database-url psycopg2
mkdir -p app/migrations
touch app/__init__.py app/migrations/__init__.py
mv models.py app/
python manage.py makemigrations
python manage.py migrate
@joshteng
joshteng / server.md
Last active April 5, 2020 12:52
server setup

Provision a Server and Access via SSH

Installing Essentials

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libbz2-dev libsqlite3-dev wget git
git config --global user.name ""
@joshteng
joshteng / rails_app_gems.rb
Last active June 10, 2018 18:52
My Crazy Gem List for Most Rails App
source 'https://rubygems.org'
ruby "2.0.0"
gem 'rails', '3.2.13'
# Gems used only for assets and not required
# in production environments by default.
group :production do
gem 'rack-google-analytics'
const property = { first: "Wes", last: "Side", address: { lines: ["first line", "second line"], city: "New York", state: "NY" }}

//to get the second line
const { address: { lines: [ , line2] } } = property
@joshteng
joshteng / html_timer.html
Created March 5, 2017 09:12
Simple HTML Timer to Demonstrate Javascript on a Browser
<html>
<head>
<style>
p#secondsLeft {
padding-top: 100px;
text-align: center;
font-size: 50px;
}
p.secondsLeftText {