Skip to content

Instantly share code, notes, and snippets.

View fongfan999's full-sized avatar
🏠
Working from home

Phong Phan fongfan999

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am fongfan999 on github.
  • I am fongfan999 (https://keybase.io/fongfan999) on keybase.
  • I have a public key ASAGuim3XRqDxYHLCi2OtkBsYUX0bCBNplitMOmCCtSY2Ao

To claim this, I am signing this object:

@fongfan999
fongfan999 / facebook-sdk.js
Last active December 2, 2018 08:13
Turbolinks 5 & Facebook SDK & ES6
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.1&appId=YOUR_APP_ID&autoLogAppEvents=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
document.addEventListener("DOMContentLoaded", () => {
let fbRoot;
@fongfan999
fongfan999 / _comment.html.slim
Created November 22, 2018 04:05 — forked from dbridges/_comment.html.slim
Stimulus.js and Rails remote forms with error handling
- # app/views/comments/_comment.html.slim
li data-controller="comment" data-action="click->comment#hello"
= "#{comment.message} by #{comment.user.email}"
@fongfan999
fongfan999 / rails_webpacker_bootstrap_expose_jquery.md
Created November 2, 2018 10:01 — forked from andyyou/rails_webpacker_bootstrap_expose_jquery.md
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collect all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@fongfan999
fongfan999 / git-deployment.md
Created October 2, 2018 10:56 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@fongfan999
fongfan999 / setup.sh
Created July 11, 2018 13:57 — forked from r00k/setup.sh
#!/bin/sh
# Set up Rails app. Run this script immediately after cloning the codebase.
# Exit if any subcommand fails
set -e
# Copy over configs
if ! [ -f .env ]; then
cp .sample.env .env
@fongfan999
fongfan999 / README-Template.md
Created July 2, 2018 16:46 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@fongfan999
fongfan999 / dokku.txt
Created June 9, 2018 14:52 — forked from Loschcode/dokku.txt
Dokku no space left on device solution
1) Stop docker: service docker stop. Verify no docker process is running ps faux
2) Double check docker really isn't running. Take a look at the current docker directory: ls /var/lib/docker/
2b) Make a backup - tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
3) Move the /var/lib/docker directory to your new partition: mv /var/lib/docker /mnt/pd0/docker
4) Make a symlink: ln -s /mnt/pd0/docker /var/lib/docker
5) Take a peek at the directory structure to make sure it looks like it did before the mv: ls /var/lib/docker/ (note the trailing slash to resolve the symlink)
6) Start docker back up service docker start
@fongfan999
fongfan999 / Gemfile
Created May 31, 2018 14:31 — forked from gvarela/Gemfile
web sockets with eventmachine and redis pub/sub
# A sample Gemfile
source "http://rubygems.org"
gem "redis"
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git'
gem "em-hiredis"
# gem "em-synchrony"
gem "em-websocket"
@fongfan999
fongfan999 / nginx-config-rails4-with-puma-ssl-version.conf
Created May 13, 2018 11:47 — forked from rkjha/nginx-config-rails4-with-puma-ssl-version.conf
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}