Skip to content

Instantly share code, notes, and snippets.

@n1snt
n1snt / Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md
Last active April 23, 2024 17:16
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

@MarkZhangTW
MarkZhangTW / curl.time.sh
Last active April 10, 2020 06:03
Curl format for displaying time infomation.
#!/usr/bin/env bash
# Reference: https://stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl
curl_format="\
%{time_namelookup}:\
%{time_connect}:%{time_appconnect}:\
%{time_pretransfer}:%{time_redirect}:\
%{time_starttransfer}:%{time_total}"
curl_result=$(echo "$curl_format" | curl -s -o /dev/null -w @- $@)
IFS=':' read -r -a array <<< "$curl_result"
from itertools import product
from functools import reduce
class Number():
def __init__(self):
self.num = 0
def succ(self):
self.num += 1
return self
@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@w0rd-driven
w0rd-driven / passwords.txt
Created November 18, 2016 20:19
BFG Repo-Cleaner --replace-text example
PASSWORD1 # Replace literal string 'PASSWORD1' with '***REMOVED***' (default)
PASSWORD2==>examplePass # replace with 'examplePass' instead
PASSWORD3==> # replace with the empty string
regex:password=\w+==>password= # Replace, using a regex
regex:\r(\n)==>$1 # Replace Windows newlines with Unix newlines
@jagrosh
jagrosh / Github Webhook Tutorial.md
Last active April 21, 2024 22:56
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings
@windows98SE
windows98SE / api.py.patch
Created May 23, 2015 15:18
[fix] LINE API function login ( api.py ) / new examples
@@ -55,7 +55,21 @@
After login, make `client` and `client_in` instance
to communicate with LINE server
"""
- raise Exception("Code is removed because of the request of LINE corporation")
+
+ self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
+ self.transport_in = THttpClient.THttpClient(self.LINE_HTTP_IN_URL)
+
+ self.transport.setCustomHeaders(self._headers)
@trendels
trendels / rsync_daemon_over_ssh.md
Last active November 13, 2023 03:26
Rsync daemon mode over ssh

rsync daemon mode over ssh

There are several common ways to do rsync backups of hosts over ssh:

  1. As a non-root user. Upsides: very secure. Downside: cannot back up sensitive files.
  2. As root, with a public key. Downsides: Whoever has the private key has full root access to the host being backed up.
  3. As root, with a public key and a "forced command". Upsides: Restricts access to the server. Downsides: Requires either careful matching of rsync options (which might change over time), or "validator" scripts. Neither idea sounds very appealing to me.
  4. Running rsync in daemon mode on the host being backed up. Upsides: Lots of useful options, like read-only mode, running as a different user if required, server-side excludes/includes, etc. Downsides: Opens up a TCP port that has full filesystem read access and is hard to secure (Ideally you could make the rsync daemon use a unix socket instead, that could be secured by filesystem permissions, but I haven't found a way to do that).

Here is another option t

@ericdouglas
ericdouglas / super-tip.txt
Last active February 25, 2024 10:09
Change 4 spaces to 2 spaces indentation and change tab to spaces - Vim tip
// 4 spaces to 2 spaces
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
// Tab to 2 spaces
:%s/\t/ /g
@rozifus
rozifus / Python SimpleHTTPServer with SSL
Last active October 9, 2022 22:40
Python SimpleHTTPServer with SSL
# useful for running ssl server on localhost
# which in turn is useful for working with WebSocket Secure (wss)
# copied from http://www.piware.de/2011/01/creating-an-https-server-in-python/