Skip to content

Instantly share code, notes, and snippets.

@rahulwa
rahulwa / restaurant_website.py
Created July 16, 2017 16:54
github.com/lobrown/Full-Stack-Foundations/master/Lesson-2/Objective-5-Solution/webserver.py
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import cgi
# import CRUD Operations from Lesson 1 ##
from database_setup import Base, Restaurant, MenuItem
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# Create session and connect to DB ##
engine = create_engine('sqlite:///restaurantmenu.db')
@rahulwa
rahulwa / postgres_queries_and_commands.sql
Last active September 18, 2018 19:09 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
## credit: http://fabian-affolter.ch/blog/the-lineinfile-module-of-ansible/
---
- hosts: alpine_install
user: root
tasks:
# - name: create a complete empty file
# command: /usr/bin/touch /test/test.conf
- name: create a new file with lineinfile
We couldn’t find that file to show.
@rahulwa
rahulwa / ELK_stack.md
Last active May 5, 2021 02:45
TODO in production for ELK stack

TODO in production -

Elasticsearch

  • select large memory instance
    • A machine with 64 GB of RAM is the ideal sweet spot, but 32 GB and 16 GB machines are also common. Less than 8 GB tends to be counterproductive (you end up needing many, many small machines), and greater than 64 GB has problems.
    • In general, it is better to prefer medium-to-large boxes.
  • create swap using instance store disk, not EBS.
  • Disks should be ssd and iops
  • cfq (default I/O Scheduler in *nix) is inefficient for SSD, however, since there are no spinning platters involved. Instead, deadline or noop should be used instead. The deadline scheduler optimizes based on how long writes have been pending, while noop is just a simple FIFO queue.