Skip to content

Instantly share code, notes, and snippets.

View wynemo's full-sized avatar
🤣
快落的时光总那么少

Nemo.Zhang wynemo

🤣
快落的时光总那么少
View GitHub Profile
import socket
LOCAL_IP = "0.0.0.0"
LOCAL_PORT = 34197
REMOTE_IP = "myserverintheweb.xyz"
REMOTE_PORT = 20000
if __name__ == "__main__":
sock = socket.socket( socket.AF_INET,
@vasanthk
vasanthk / System Design.md
Last active May 1, 2024 16:16
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@jiaaro
jiaaro / _INSTRUCTIONS.md
Last active January 22, 2024 17:47
Using Swift libraries in Python

Using Swift libraries in Python

So... this is obviously totally, 100%, like for. real. not. supported. by. Apple. …yet?

But still... I thought it was pretty badass. And, seeing how there's already a Swift buildpack for Heroku you could move some slow code into Swift can call it as a library function. But, you know, not in production or anything. That would be silly, right?

Now, having said that, the actual Python/Swift interop may have bugs. I'll leave that as an exercise to the reader.

How to get Python code calling Swift functions:

@baskaran-md
baskaran-md / rsyslog.sh
Last active August 17, 2023 11:42
Install/Update Rsyslog - CentOs
yum install -y wget
wget http://rpms.adiscon.com/v8-stable/rsyslog.repo
mv rsyslog.repo /etc/yum.repos.d/rsyslog.repo
yum info rsyslog --skip-broken
yum install -y rsyslog
rsyslogd -version
@trentmswanson
trentmswanson / autopart.sh
Last active December 3, 2022 08:22
Linux bash script to partition and format all data disks in azure
#!/bin/bash
# An set of disks to ignore from partitioning and formatting
BLACKLIST="/dev/sda|/dev/sdb"
# Base directory to hold the data* files
DATA_BASE="/media"
usage() {
echo "Usage: $(basename $0) <new disk>"
}
@Integralist
Integralist / 1. TCO description.md
Last active January 20, 2020 13:32
JS Tail Call Optimisation

The problem

If a function calls itself recursively then the JavaScript engine has to create a new 'stack' (i.e. allocate a chunk of memory) to keep track of the function's arguments.

Let's look at an example of this happening:

function sum(x, y) {
    if (y > 0) {
      return sum(x + 1, y - 1);
@yyx990803
yyx990803 / nl.sh
Last active March 5, 2024 01:24
npm list only top level modules.
alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"
@FredLoney
FredLoney / logging_helper.py
Last active April 24, 2024 17:07
Prints the current stack to a logger.
import inspect
import logging
HEADER_FMT = "Call stack at %s, line %d in function %s, frames %d to %d of %d:"
"""The log header message formatter."""
STACK_FMT = "%s, line %d in function %s."
"""The log stack message formatter."""
def log_stack(logger=None, limit=None, start=0):