Skip to content

Instantly share code, notes, and snippets.

View yihyang's full-sized avatar
😰
kinda busy

Yih Yang yihyang

😰
kinda busy
View GitHub Profile
@yihyang
yihyang / post-mortem.md
Created August 11, 2022 02:58 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files)

2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

  1. * Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  2. Added fs.file-max = 70000 to /etc/sysctl.conf
@yihyang
yihyang / postgres_queries_and_commands.sql
Created July 27, 2021 16:06 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@yihyang
yihyang / README.md
Created September 27, 2020 13:54 — forked from nyancodeid/README.md
Make RESTful API with Google Apps Script and SpreadSheet
@yihyang
yihyang / AppServiceProvider.php
Created July 31, 2020 05:44 — forked from paulund/AppServiceProvider.php
Laravel Cache Auth::user(). Learn how to cache the logged in user at https://paulund.co.uk/laravel-cache-authuser
<?php
namespace App\Providers;
use App\Models\User;
use App\Observers\UserObserver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@yihyang
yihyang / git-deployment.md
Created May 4, 2020 08:37 — 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 local 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 deepl.io to act upon a Web-Hook that's triggered that service.

@yihyang
yihyang / change-ip-tables.sh
Created April 23, 2020 10:39 — forked from thekalinga/change-ip-tables.sh
AWS redirect port 80 -> 8080
iptables --insert INPUT --protocol tcp --dport 80 --jump ACCEPT
iptables --insert INPUT --protocol tcp --dport 8080 --jump ACCEPT
iptables --table nat --append PREROUTING --in-interface eth0 --protocol tcp --dport 80 --jump REDIRECT --to-port 8080
# run next line to have changes survive reboot
service iptables save
@yihyang
yihyang / golang_setup.md
Created December 14, 2017 04:08 — forked from sathiyaseelan/golang_setup.md
Basics to setup a golang project repo in your local

Simple Guide to setup Golang in your Mac and clone a repo.

Setup Go and workspace

Type go in terminal, to verify the installation.

  • Create a Go workspace and set GO PATH
@yihyang
yihyang / Responsive Spec Helpers With Meta tags
Created November 29, 2017 01:57 — forked from sathiyaseelan/Responsive Spec Helpers With Meta tags
Helpers for Responsive feature Specs in Capybara
The responsive helpers are to help the developer with writing responsive specs.
All you have to do is, add `responsive_helper.rb` to the spec support directory.
And tag the specs with :mobile, :tablet for mobile and tablet size respectively.
If you don't use any tag, it would render the desktop size.
@yihyang
yihyang / GIF-Screencast-OSX.md
Created August 18, 2017 07:57 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@yihyang
yihyang / rbenv-install.sh
Last active January 23, 2016 16:50 — forked from vincentlkl/rbenv-install.sh
Setting up guide on Microsoft Azure
# TO DO when there is warning message on locales
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales
export LC_ALL="en_US.UTF-8"
# Update, upgrade and install development tools:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential git-core libssl-dev libsqlite3-dev curl nodejs nginx libreadline-dev rbenv