Skip to content

Instantly share code, notes, and snippets.

View huangsam's full-sized avatar
🌱
Continuous learning

Samuel Huang huangsam

🌱
Continuous learning
View GitHub Profile
@huangsam
huangsam / app.conf
Last active January 24, 2019 17:24
Production-level Nginx configuration
resolver 8.8.8.8 8.8.4.4 valid=10s;
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
server {
listen 80;
listen [::]:80;
server_name _;
return 301 https://$server_name$request_uri;
}
@huangsam
huangsam / Aircrack Commands
Created January 6, 2018 08:34 — forked from victorreyesh/Aircrack Commands
Cracking WPA2 / WEP Wifi / Aircrack 10 seconds guide. For Mac OSX
//Install Macports.
//Install aircrack-ng:
sudo port install aircrack-ng
//Install the latest Xcode, with the Command Line Tools.
//Create the following symlink:
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
//Figure out which channel you need to sniff:
sudo airport -s
sudo airport en1 sniff [CHANNEL]
@huangsam
huangsam / check_urls.py
Last active May 29, 2018 17:59
Checks URLs with multithreading. Uses requests package.
#!/usr/bin/env python
from concurrent import futures
import multiprocessing as mp
import os
import json
import uuid
from bs4 import BeautifulSoup
from markdown import markdown
import requests
@huangsam
huangsam / package.json
Created January 18, 2018 14:34
Testing WebSockets locally and remotely
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"safe-buffer": {
@huangsam
huangsam / Vagrantfile
Last active June 11, 2021 11:13
Trying out Postgres replication for a two-node setup
# vi: set ft=ruby ts=2 :
Vagrant.configure("2") do |config|
config.vm.define "master", primary: true do |master|
master.vm.box = "geerlingguy/ubuntu1604"
master.vm.network "private_network", type: "static", ip: "172.28.128.3"
master.vm.hostname = "pgmaster"
config.vm.provider "virtualbox" do |vb|
vb.name = "pgmaster"
vb.memory = 2048
vb.cpus = 1
@huangsam
huangsam / README.md
Created March 5, 2018 23:47 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.

OP: @leonardofed founder @ plainflow.


@huangsam
huangsam / birds.js
Last active March 29, 2018 17:18
Simple Express app with router endpoint
var express = require('express')
var router = express.Router()
// middleware that is specific to this router
router.use(function timeLog (req, res, next) {
console.log('Time: ', Date.now())
next()
})
// define the home page route
router.get('/', function (req, res) {
@huangsam
huangsam / migrate.sh
Last active May 28, 2018 16:13
Postgres 9.6 to 10.4 migration
# Run postgres 9.6
docker exec -it db bash
gosu postgres psql
DB_STUFF=<<EOF
CREATE DATABASE critical_app
\c critical_app
CREATE TABLE guestbook (visitor_email text, vistor_id serial, date timestamp, message text);
INSERT INTO guestbook (visitor_email, date, message) VALUES ('[email protected]', current_date, 'This is a test.');
INSERT INTO guestbook (visitor_email, date, message) VALUES ('[email protected]', current_date, 'Another test.');
INSERT INTO guestbook (visitor_email, date, message) VALUES ('[email protected]', current_date, 'Final test.');
@huangsam
huangsam / mro.py
Created November 14, 2018 17:47
Method Resolution Order in Python
"""
Case 1: B, C are connected to A
"""
class A(object): pass
class B(A): pass
class C(A): pass
class D(B, C): pass
assert D.__mro__ == (D, B, C, A, object)