Skip to content

Instantly share code, notes, and snippets.

@lananhbk168
lananhbk168 / kafka-cheat-sheet.md
Created April 20, 2020 21:40 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@lananhbk168
lananhbk168 / php-pools.md
Created March 4, 2020 10:46 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@lananhbk168
lananhbk168 / expecting.md
Created March 1, 2018 12:56 — forked from ksafranski/expecting.md
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@lananhbk168
lananhbk168 / heartbleed.py
Created August 16, 2017 16:05 — forked from eelsivart/heartbleed.py
Heartbleed (CVE-2014-0160) Test & Exploit Python Script
#!/usr/bin/python
# Modified by Travis Lee
# Last Updated: 4/21/14
# Version 1.16
#
# -changed output to display text only instead of hexdump and made it easier to read
# -added option to specify number of times to connect to server (to get more data)
# -added option to send STARTTLS command for use with SMTP/POP/IMAP/FTP/etc...
# -added option to specify an input file of multiple hosts, line delimited, with or without a port specified (host:port)
@lananhbk168
lananhbk168 / SimpleAuthServer.py
Created May 27, 2016 11:10 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
66.220.146.183 [2015-12-15T12:11:03+07:00] afamily1.vcmedia.vn "GET /k:thumb_w/600/l9XH2LNjGJq5BZeqyPfmGdT25EmQJ/Image/2015/12/hospital-christmas-decorations-6__605-770a7/giang-sinh.jpg HTTP/1.1" 206 93863 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" 0.673 "-" "OK" "MISS" "HIT" "-" "http" "image/jpeg"
173.252.88.87 [2015-12-15T12:11:03+07:00] video-thumbs.vcmedia.vn "GET /kenh14/0815r9k2G2vccccccccccccZKmJTw/2013/08/100813/rume-c270b.jpg HTTP/1.1" 200 15388 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" 0.004 "-" "OK" "MISS" "MISS" "-" "http" "image/jpeg"
173.252.120.101 [2015-12-15T12:11:03+07:00] k14.vcmedia.vn "GET /2015/ajefae-1450002400929.PNG HTTP/1.1" 206 279682 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" 1.725 "-" "OK" "MISS" "HIT" "-" "http" "image/png"
173.252.74.98 [2015-12-15T12:11:03+07:00] kenh14.vcmedia.vn "GET /d9baecf2c8/2015/11/11/ava2-049a2.jpg HTTP/1.1" 200 457983 "-" "facebookexternalhi
Lighttpd:
format = "%h %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %I %O %T %V"
VD:
98.197.217.239 [08/Jul/2015:12:00:50 +0700] "GET /8006cbba7a000b832b5ef3aefaf5771c/559cae7b/dev11001/0/015/118/0015118372.mp4?domain=vhosting.vcmedia.vn&name=afamily/hongquangminh/2014/08/cuong-2ce37.mp4 HTTP/1.1" 200 923101 "http://vscc.hosting.vcmedia.vn/embed/8fdedfc0e68c47febb7d13304737f883?layout=scroll&autostart=false" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36" 612 923358 6 nb1.vcmedia.vn
Nginx:
format: '$remote_addr $http_x_forwarded_for [$time_iso8601] $http_host "$request" $status $bytes_sent "$http_referer" "$http_user_agentt
" "$gzip_ratio" $request_time $request_completion $upstream_addr'
from datetime import datetime, time
def dateDiffInSeconds(date1, date2):
timedelta = date2 - date1
return timedelta.days * 24 * 3600 + timedelta.seconds
def daysHoursMinutesSecondsFromSeconds(seconds):
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
// Setting up an IRC server on Cent 6
// Create a user and group for this guy
$ groupadd ircadmin && useradd -m -g ircadmin -s /bin/bash ircadmin
// Make a working directory (/var/source/)
mkdir source && cd source
// Grab the latest versions of Anope and UnrealIRCd
$ wget http://www.unrealircd.com/downloads/Unreal3.2.9.tar.gz http://downloads.sourceforge.net/project/anope/anope-stable/Anope%201.8.7/anope-1.8.7.tar.gz
@lananhbk168
lananhbk168 / app.rb
Created September 11, 2013 02:56 — forked from troelskn/app.rb
require 'gollum/frontend/app'
require 'digest/sha1'
class App < Precious::App
User = Struct.new(:name, :email, :password_hash, :can_write)
before { authenticate! }
before /^\/(edit|create|delete|livepreview|revert)/ do authorize_write! ; end
helpers do