Skip to content

Instantly share code, notes, and snippets.

View thuai's full-sized avatar
🎯
Focusing

TT thuai

🎯
Focusing
View GitHub Profile
@YiuTerran
YiuTerran / seq-output.go
Created April 7, 2019 11:07
golang顺序输出
import (
"fmt"
"sync/atomic"
)
const (
total = 30
threads = 3
)
@TheHackerDev
TheHackerDev / 301.py
Created June 12, 2017 13:43
Simple 301 redirect server in Python
import SimpleHTTPServer
import SocketServer
# Redirect to Google.com
class Redirect(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
print self.path
self.send_response(301)
new_path = '%s%s'%('https://google.com', self.path)
self.send_header('Location', new_path)
@dtomasi
dtomasi / default
Last active December 8, 2023 04:20
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
@WeZZard
WeZZard / WWDC_2015_downloader.rb
Last active December 29, 2015 14:08
WWDC_2015_downloader.rb
require 'rubygems'
require 'mechanize'
if !((ARGV[0] == 'SD' || ARGV[0] == 'HD' || ARGV[0] == 'ALL') && ARGV.size == 1)
puts %q{Usage: ruby WWDC_2015_downloader.rb SD | HD | ALL}
puts %q{Example: ruby WWDC_2015_downloader.rb SD - to download all SD videos}
puts %q{Example: ruby WWDC_2015_downloader.rb HD - to download all HD videos}
puts %q{Example: ruby WWDC_2015_downloader.rb ALL - to download videos in all resolutions}
exit
end
@jtbandes
jtbandes / Function.h
Last active April 21, 2020 16:51
fun with Obj-C "generics"
@import Foundation;
NS_ASSUME_NONNULL_BEGIN
@interface Function<__contravariant InType, __covariant OutType> : NSObject
{
// interestingly, this does work here (though OutType & InType are not available in the @implementation)
OutType (^_block)(InType);
}
@kevinzhow
kevinzhow / vpnserver.sh
Last active March 19, 2019 12:59
OnClickVPNServer
#!/usr/bin/env bash
echo 'deb http://shadowsocks.org/debian wheezy main' >> /etc/apt/sources.list
# Pre-requisites
sudo apt-get -y update
sudo apt-get -y install pptpd
sudo apt-get -y install fail2ban
sudo apt-get -y install shadowsocks-libev
@simlegate
simlegate / custom-error-page
Created October 31, 2014 05:35
Nginx return custom json
error_page 400 404 405 =200 @40*_json;
location @40*_json {
default_type application/json;
return 200 '{"code":"1", "message": "Not Found"}';
}
error_page 500 502 503 504 =200 @50*_json;
location @50*_json {
@BennettSmith
BennettSmith / .gitignore
Last active July 2, 2024 06:49
Google Protobuf v2.6.0 Build Script for iOS
protobuf
protobuf-2.6.0
protobuf-2.6.1
protobuf-master
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 23, 2024 09:14
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@mattes
mattes / wp-cli-install-with-brew.sh
Created October 18, 2013 13:45
Installing WP-CLI under Mac OS with Homebrew
#!/usr/bin/env
# curl https://gist.github.com/mattes/7041760/raw/wp-cli-install-with-brew.sh | bash
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install wp-cli