Skip to content

Instantly share code, notes, and snippets.

View gnilchee's full-sized avatar

Greg Nilchee gnilchee

  • Evernote
  • Woodinville, WA
View GitHub Profile
@creativepsyco
creativepsyco / gist:9322214
Last active August 29, 2015 13:56
Host Python Server in Current Directory.
#Python 2
python -m SimpleHTTPServer 8080
#Python 3
python3 -m http.server 8113
#!/bin/bash
# ------------------------------------------------------------------
# Author: Ryan C Koch - ryanckoch@gmail.com
# Purpose: CHECK TCP AND UDP CONNECTIVITY BETWEEN
# SOURCE AND DESTINATION HOSTS
# ------------------------------------------------------------------
SOURCE_FILE="source.hosts"
DESTINATION_FILE="destination.hosts"
LOG_VERBOSE="logs/verbose.log"
'''
Easy Mac
Copyright (2015) Sean Beck
Licensed under Creative Commons Attribution-ShareAlike 4.0 International
See: https://creativecommons.org/licenses/by-sa/4.0/
Easily change your MAC address on Linux using `ifconfig`
'''
#!/usr/bin/python2.7
@anti1869
anti1869 / parallel-script.py
Created December 21, 2015 19:28
How To Call Shell Commands From Python In Parallel With Asyncio
#!/usr/bin/env python
"""
Test parallel scripts running with asyncio executors.
Requires at least Python 3.4 to run.
"""
import asyncio
import os
@thisismitch
thisismitch / haproxy-www.tf
Last active March 6, 2020 02:22
How To Use Terraform with DigitalOcean
resource "digitalocean_droplet" "haproxy-www" {
image = "ubuntu-14-04-x64"
name = "haproxy-www"
region = "nyc2"
size = "512mb"
private_networking = true
ssh_keys = [
"${var.ssh_fingerprint}"
]
connection {
@jeremyj
jeremyj / haproxy rate limiting
Last active June 15, 2020 17:00
haproxy rate limiting
HTTP request limiting ===================================================================================================================
frontend ft_web
# Use General Purpose Couter (gpc) 0 in SC1 as a global abuse counter
# Monitors the number of request sent by an IP over a period of 10 seconds
stick-table type ip size 1m expire 10s store gpc0,http_req_rate(10s)
tcp-request connection track-sc1 src
# refuses a new connection from an abuser
tcp-request content reject if { src_get_gpc0 gt 0 }
@SIN-777
SIN-777 / mysql_total_memory_usage_calculation.sql
Created June 5, 2012 05:10
mysql total memory usage calculation query
-- copied from: http://mogmet.blog20.fc2.com/blog-entry-55.html
select @@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH as GLOBAL_BUFFER_SIZE, @@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFFER_SIZE + @@GLOBAL.READ_BUFFER_SIZE + @@GLOBAL.JOIN_BUFFER_SIZE + @@GLOBAL.READ_RND_BUFFER_SIZE as THREAD_BUFFER_SIZE, @@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH + (@@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFFER_SIZE + @@GLOBAL.READ_BUFFER_SIZE + @@GLOBAL.JOIN_BUFFER_SIZE + @@GLOBAL.READ_RND_BUFFER_SIZE) * @@GLOBAL.MAX_CONNECTIONS AS TOTAL_MEMORY_SIZE, (@@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH + (@@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFF
@dsuch
dsuch / haproxy.conf
Created June 26, 2013 22:18
HAProxy config for URL-based rate limiting
# At most 10 concurrent connections from a client
acl too_fast fe_sess_rate ge 10
# Matches any path beginning with a given prefix
acl bursts_inclined path_beg -i /client1
# Effectively working as a delay mechanism for clients that are too fast
tcp-request inspect-delay 1000ms
# Fast-path - accept connection if it's not this troublesome client
@z0mbix
z0mbix / tcpdump-es-capture
Created December 19, 2014 14:45
Capture Elasticsearch Queries
# tcpdump -A -nn -s 0 'tcp dst port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
14:32:33.525122 IP 127.0.0.1.49777 > 127.0.0.1.9200: Flags [P.], seq 313752908:313753888, ack 2465010394, win 257, options [nop,nop,TS val 2684167067 ecr 2684167066], length 980
E...^.@.@............q#...}L...............
..#...#.GET /index/_search HTTP/1.1
Host: 127.0.0.1:9200
Accept: */*
Content-Length: 845
Content-Type: application/x-www-form-urlencoded
@mestizo
mestizo / gist:9167834
Last active February 27, 2023 22:39
Completely disable IPv6 on OSX
#To Get List of Hardware
sudo networksetup -listallhardwareports
#To Disable IPv6 on Wifi Adapter
sudo networksetup -setv6off wi-fi
#To Disable IPv6 on Built-in Ethernet Adapter
sudo networksetup -setv6off Ethernet