Skip to content

Instantly share code, notes, and snippets.

View xiaoronglv's full-sized avatar
💭
😊

Ryan Lyu xiaoronglv

💭
😊
View GitHub Profile
@nerdalert
nerdalert / Netfilter-IPTables-Diagrams.md
Last active April 9, 2024 09:18
Linux NetFilter, IP Tables and Conntrack Diagrams

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

upstream app_name {
server unix:///tmp/app_name.sock;
}
server {
listen 80;
server_name example.com; # change to match your URL
root /rails/app/folder/public; # change to match your rails app public folder
@luugiathuy
luugiathuy / nginx_configuration
Last active April 6, 2018 18:58
nginx configuration
upstream app_name {
server unix:///tmp/app_name.sock;
}
server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
@LordZamy
LordZamy / mergesort.go
Created October 14, 2014 02:48
Merge sort in Golang
package main
import (
"fmt"
)
func main() {
A := []int{3, 5, 1, 6, 1, 7, 2, 4, 5}
fmt.Println(sort(A))
}
@jmoiron
jmoiron / 01-curl.go
Last active December 16, 2022 10:34
io.Reader & io.Writer fun
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func init() {
@kovacshuni
kovacshuni / hmac-sha1.rb
Last active March 12, 2022 15:05
Ruby HMAC-SHA1 digest creation
require 'base64'
require 'cgi'
require 'openssl'
base = 'POST&https%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.json&include_entities%3Dtrue%26oauth_consumer_key%3Dxvz1evFS4wEEPTGEFPHBog%26oauth_nonce%3DkYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1318622958%26oauth_token%3D370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb%26oauth_version%3D1.0%26status%3DHello%2520Ladies%2520%252B%2520Gentlemen%252C%2520a%2520signed%2520OAuth%2520request%2521'
key = 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw&LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE'
puts CGI.escape(Base64.encode64("#{OpenSSL::HMAC.digest('sha1', key, base)}\n"))
@jalquisola
jalquisola / gist:9b69e7468b826e81bd7a
Created June 4, 2014 02:33
LoadError: cannot load such file -- sidekiq/capistrano for sidekiq >= 3.0
#Add gem into Gemfile and do bundle install
gem "capistrano-sidekiq"
#replace "require 'sidekiq/capistrano'" in Capfile
require 'capistrano/sidekiq'
@Integralist
Integralist / Hash Keys to Symbols.rb
Last active September 2, 2020 08:50
Convert Ruby Hash keys into symbols
hash = { 'foo' => 'bar' }
# Version 1
hash = Hash[hash.map { |k, v| [k.to_sym, v] }]
# Version 2
hash = hash.reduce({}) do |memo, (k, v)|
memo.tap { |m| m[k.to_sym] = v }
end
@ivanoats
ivanoats / .railsrc
Last active August 11, 2020 09:33 — forked from gringocl/gist:8480696
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
@RaVbaker
RaVbaker / readme.md
Last active November 29, 2023 06:08
Reverse engineering Things SQLite tasks database

To open SQLite Things.app database run this command in Terminal.app:

$ sqlite3 ~/Library/Containers/com.culturedcode.things/Data/Library/Application\ Support/Cultured\ Code/Things/ThingsLibrary.db

In SQLite command-line type this query to get your tasks stats:

sqlite> .mode column
sqlite> .header on
sqlite> select zscheduler, zstatus, ztrashed, count(*) from ZTHING where z_ent = 13 group by  zstatus,ztrashed order by Z_pk desc;

ZSCHEDULER ZSTATUS ZTRASHED count(*)