Skip to content

Instantly share code, notes, and snippets.

@vsajip
vsajip / README.md
Last active February 20, 2025 12:53
Run a logging socket receiver in a production setting with logging from an example webapp

This set of files is to help you set up a socket listener for Python logging in a production environment.

The other files are:

Filename Purpose
prepare.sh A Bash script to prepare the environment for testing.
supervisor.conf The Supervisor configuration file, which has entries for the listener and a multi-process web application.
ensure_app.sh A Bash script to ensure that Supervisor is running with the above configuration.
log_listener.py The socket listener program which receives log events and records them to a file.
@nhthai2005
nhthai2005 / Autocomplete_ssh_scp.md
Last active January 7, 2025 10:17
Autocomplete server names for SSH and SCP for Git Bash

Autocomplete server names for SSH and SCP for Git Bash

For ssh

1. Make a file with name ssh as following content:

_ssh() 
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@ozbillwang
ozbillwang / Git_Behind_Proxy.md
Last active January 19, 2025 09:30
Configure Git to use a proxy (https or SSH+GIT)
@fpagyu
fpagyu / select_demo.py
Created October 10, 2018 06:30
python 中select,poll, epoll 使用例子
# coding: utf-8
import select
import socket
import queue
def select_demo():
server = socket.socket()
server.bind(('127.0.0.1', 9000))
server.listen(5)
@coin8086
coin8086 / using-proxy-for-git-or-github.md
Last active January 24, 2025 07:47
Use Proxy for Git/GitHub

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocol you use. And there're two common protocols: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocol. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@dgrammatiko
dgrammatiko / chrome.css
Last active December 14, 2020 22:30
Default UA stylesheets
// https://chromium.googlesource.com/chromium/blink/+/master/Source/core/css/html.css
/*
* The default style sheet used to render HTML.
*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@aprilmintacpineda
aprilmintacpineda / Using Multiple SSH keys - Beginner Friendly.md
Last active May 4, 2025 01:27
Beginner Friendly: Using Multiple SSH keys

How to follow this guide

The problem

I have one computer and two different github accounts. One is for work, the other is for my personal stuff. I can't use the same ssh key twice, so I have to use different ssh key for each of my accounts. How do I do that? How do I switch between these ssh keys?

@mayufo
mayufo / 验证中国身份证 前6位对应地区码
Created January 16, 2018 10:12
验证中国身份证 前6位对应地区码
var GB2260 = {
"110000": "北京市",
"110100": "北京市市辖区",
"110101": "北京市东城区",
"110102": "北京市西城区",
"110103": "北京市崇文区",
"110104": "北京市宣武区",
"110105": "北京市朝阳区",
"110106": "北京市丰台区",
"110107": "北京市石景山区",
@demisang
demisang / AesCipher.java
Last active December 9, 2024 10:20
AES/CBC/PKCS5Padding encrypt/decrypt PHP and JAVA example classes
import android.support.annotation.Nullable;
import android.util.Base64;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;