Skip to content

Instantly share code, notes, and snippets.

View maximivanov's full-sized avatar

Max Ivanov maximivanov

View GitHub Profile
@Nav-Appaiya
Nav-Appaiya / reset-phpstorm.sh
Last active October 1, 2023 12:07
Purge PHPStorm 9.x Settings on OSX Yosemite
# PHPStorm v9.0
rm -rf ~/Library/Application\ Support/WebIde90
rm -rf ~/Library/Cache/WebIde90
rm -rf ~/Library/Preferences/WebIde90
# PHPStorm v10.0
rm -rf ~/Library/Application\ Support/WebIde100
rm -rf ~/Library/Cache/WebIde100
rm -rf ~/Library/Preferences/WebIde100
@joewiz
joewiz / post-mortem.md
Last active September 3, 2023 11:57
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
@seeebiii
seeebiii / LambdaConstants.java
Last active February 9, 2024 04:17
Available default environment variables in AWS Lambda. Just copy&paste into your Node or Java project.
public class Constants {
/**
* Contains the path to your Lambda function code.
*/
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT");
/**
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function:
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10
@jonjack
jonjack / add-update-refresh-github-access-token-on-mac.md
Last active July 6, 2024 22:04
Adding & Updating GitHub Access Token on Mac

Using an Access Token for the first time

Follow the instructions on Github to Create an Access Token in Github

Configure Git to use the osxkeychain

By default, git credentials are not cached so you need to tell Git if you want to avoid having to provide them each time Github requires you to authenticate. On Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account.

You can tell Git you want to store credentials in the osxkeychain by running the following:-

@ukayani
ukayani / movestate.sh
Created January 8, 2019 20:51
Terraform/Terragrunt wrapper module state move
#!/bin/bash
# Lets say we have all resources under state /A using module A
# We decide to wrap all the resources of the module into a inner module B
# So now all resources that were orignally top level in A are now top level in B
# Normally if we try to plan our changes, terraform will want to delete all resources originally under A and create new ones under B
# However, we may not want that (what if our resources are vpc level resources that we cant afford to delete)
# Terraform provides a state move command
# We can list all the resources in a module via `terraform state list`
# We can pipe this list to xargs and for each resource we can move it to the new prefix, ie. under inner module B.