Skip to content

Instantly share code, notes, and snippets.

View zh4n7wm's full-sized avatar
🎯
Focusing

Hydra zh4n7wm

🎯
Focusing
View GitHub Profile
@zh4n7wm
zh4n7wm / decent_request.py
Created December 21, 2023 05:27 — forked from laixintao/decent_request.py
Send HTTP requests using python-requests with timeout, tcp reuse(session) and retry.
from requests.adapters import HTTPAdapter, Retry
from requests import Session
retries = Retry(
total=5, backoff_factor=1, status_forcelist=[502, 503, 504]
)
session = Session() # reuse tcp connection
session.mount("http://", HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))
@zh4n7wm
zh4n7wm / GitConfigHttpProxy.md
Created December 22, 2022 02:21 — forked from evantoli/GitConfigHttpProxy.md
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

package main
import (
"fmt"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)
@zh4n7wm
zh4n7wm / tls-ca.go
Created April 23, 2022 09:41 — forked from ashee/tls-ca.go
golang tls with self-signed cert
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net/http"
)
@zh4n7wm
zh4n7wm / verify-aws-ec2-key-pair-fingerprint.md
Created December 30, 2020 13:57 — forked from msoe/verify-aws-ec2-key-pair-fingerprint.md
Verifying AWS EC2 Key Pair's Fingerprint

If you created your key pair using AWS, you can use the OpenSSL tools to generate a fingerprint as follows:

$ openssl pkcs8 -in path_to_private_key -inform PEM -outform DER -topk8 -nocrypt | openssl sha1 -c

If you created a key pair using a third-party tool and uploaded the public key to AWS, you can use the OpenSSL tools to generate the fingerprint as follows:

$ openssl rsa -in path_to_private_key -pubout -outform DER | openssl md5 -c
@zh4n7wm
zh4n7wm / apt-fast
Created November 18, 2020 03:19 — forked from voyeg3r/apt-fast
apt-fast with aria2c
#!/bin/sh
# Last Change: 2011/10/06
# apt-fast v0.02 by Matt Parnell http://www.mattparnell.com, this thing is fully open-source
# if you do anything cool with it, let me know so I can publish or host it for you
# contact me at admin@mattparnell.com
# Special thanks to Travis/travisn000 from the PCLinux Forums for making improvements that allow
# for more complex apt-get commands. See the thread: http://www.pclinuxos.com/forum/index.php/topic,66385.0.html
# adicionar suporte aos metalinks no aria2: http://ubuntuforums.org/showthread.php?t=1493421
# veja também apt-metalink: http://github.com/tatsuhiro-t/apt-metalink
@zh4n7wm
zh4n7wm / nginx-tuning.md
Created April 8, 2020 03:12 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@zh4n7wm
zh4n7wm / README.md
Created January 11, 2020 02:59 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@zh4n7wm
zh4n7wm / disable.sh
Created November 22, 2019 07:25
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@zh4n7wm
zh4n7wm / copy.py
Created May 4, 2019 03:59 — forked from vpontis/copy.py
Copy to clipboard from iPython on Mac OS X
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%copy hello world
# will store "hello world"