Skip to content

Instantly share code, notes, and snippets.

View mskian's full-sized avatar
🦕
Focusing

Santhosh Veer mskian

🦕
Focusing
View GitHub Profile
@mskian
mskian / post-mortem.md
Created December 19, 2018 17:46 — 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 *.

    • 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.)
  1. Added fs.file-max = 70000 to /etc/sysctl.conf
  2. Added `nginx soft nofile 1
@mskian
mskian / scrape_medium.py
Created September 30, 2018 13:28 — forked from yurivictor/scrape_medium.py
Scrape your @Medium post links into HTML list, if you want to add them to your site, or whatever
import requests
from pyquery import PyQuery as pq
USERNAME = 'ev' # change to your username
def get_medium_posts():
url = 'http://medium.com/@' + USERNAME + '/latest'
request = requests.get( url )
html = request.content
@mskian
mskian / createBearerToken.js
Created September 30, 2018 13:28
A Javascript file that requests a Twitter bearer token for application only authentication (https://dev.twitter.com/docs/auth/application-only-auth). Depends on mikeals request library (https://github.com/mikeal/request) (npm install request)
var request = require("request");
var key = process.env.TWITTER_CONSUMER_KEY;
var secret = process.env.TWITTER_CONSUMER_SECRET;
var cat = key + ":" + secret;
var credentials = new Buffer(cat).toString('base64');
var url = 'https://api.twitter.com/oauth2/token';
request({
@mskian
mskian / es7-async-await.js
Created September 28, 2018 06:57 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@mskian
mskian / async-await.js
Created September 4, 2018 15:43 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@mskian
mskian / install-postman.sh
Last active February 26, 2025 18:26 — forked from aviskase/Postman.desktop
Install Postman on Ubuntu via Shell script
#!/bin/bash
cd /tmp || exit
echo "Downloading Postman ..."
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz
tar -xzf postman.tar.gz
rm postman.tar.gz
echo "Installing to opt..."
if [ -d "/opt/Postman" ];then
sudo rm -rf /opt/Postman
@mskian
mskian / livecricketscore.sh
Last active April 7, 2018 12:50 — forked from arulrajnet/livecricketscore.sh
Shell script to get a Live cricket score from www.espncricinfo.com. Just run this shellscript then select your match. when ever you want to know score open that terminal and see. Just simple as Dhoni's helicopter shot :D
#!/bin/bash
# -----------------------------------------------------------------------------
# Info:
# author: Arulraj <https://arulraj.net/>
# Modified by Santhosh veer <https://santhoshveer.com>
# file: score.sh
# Orginal Gist: https://gist.github.com/arulrajnet/fb71169c35180f9d9abd
# Modified Gist: https://gist.github.com/mskian/1e660a1a205a3b69e698cb0b0256b083
# created: 24.03.2015