Skip to content

Instantly share code, notes, and snippets.

View san81's full-sized avatar

Santhosh Gandhe san81

View GitHub Profile
@npearce
npearce / install-docker.md
Last active July 27, 2024 07:34
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@srinath-imaginea
srinath-imaginea / rundown.md
Last active December 10, 2015 05:22
Node.js rundown

When we read about Nodejs on the web, everybody start to say "In Node, everything runs in parallel except your code". We have hard time understanding this. What runs in parallel and what not? How does node gets additional thread to run something in parallel ? Who manages these threads? Once we get into a situation, where we have more than one thread, how does node achieve synchronization over the shared objects?

So this is a slightly tricky part of understanding Node's architecture. For all purposes, Node.js is single threaded and runs in a single process. That is the code you type is executed in a single thread. So if you do a while(block for 1 second), the entire process will be blocked. But this obviously isn't performant - if you have a couple of I/O requests to process for each HTTP request, it will block all further execution until that is complete.

Here is where node's async bit comes into play. For everything that is I/O intensive, Node.js automagically executes it in the background us

@ylegall
ylegall / Iterators.java
Last active February 24, 2017 09:54
Iterator of iterators
import java.util.Iterator;
public class Iterators<T> implements Iterator<T> {
private Iterator<T> current;
private Iterator<Iterator<T>> cursor;
public Iterators(Iterable<Iterator<T>> iterators) {
if (iterators == null) throw new IllegalArgumentException("iterators is null");
this.cursor = iterators.iterator();
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 27, 2024 16:50
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%'
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//