Skip to content

Instantly share code, notes, and snippets.

@oyang
oyang / asyncio_signal_handler.py
Created November 15, 2024 20:10 — forked from olned/asyncio_signal_handler.py
Handle a signal in an asyncio python app
import asyncio
import functools
import signal
async def my_task(task_num):
try:
while True:
print(f'Task {task_num}')
await asyncio.sleep(task_num + 1)
@oyang
oyang / xterm-256color.md
Created January 12, 2024 06:07 — forked from shawnbot/xterm-256color.md
Make OS X Terminal respect 256 colors in screen

1. Ensure that Terminal declares itself as "xterm-256color"

Under Terminal > Preferences... > (Profile) > Advanced, "Declare terminal as:" should be set to xterm-256color.

2. Build a version of screen that supports 256 colors

This is easy with homebrew:

brew install screen
@oyang
oyang / leetcode_retag.md
Created May 13, 2022 21:30 — forked from Windsooon/leetcode_retag.md
Retag most popular Leetcode problems

osjobs

海外兔

website

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@oyang
oyang / deploy.yaml
Created February 27, 2016 01:07 — forked from mblarsen/deploy.yaml
Solution for `git clone` using Ansible for repos with private submodules with github deploy keys
# Problem:
#
# If you use git submodules linking two private github repos, you'll need to create a separate deploy key for each.
# Multiple keys are not supported by Ansible, nor does ansible (when running git module) resort to your `.ssh/config` file.
# This means your ansible playbook will hang in this case.
#
# You can however use the ansible git module to checkout your repo in multiple steps, like this:
#
- hosts: webserver
vars:
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@oyang
oyang / s1.xml
Last active August 29, 2015 14:07 — forked from davybrion/s1.xml
<VirtualHost 109.74.199.47:80>
ServerAdmin davy.brion@thatextramile.be
ServerName thatextramile.be
ServerAlias www.thatextramile.be
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
#!/bin/sh
db2 "connect to sugarult"
# Not sure if the following is actually need if the database needs to be restarted
# because of the 'currently in use' issues. However it should disconnect all application
# connected to the database.
db2 "quiesce database immediate force connections"
db2 "unquiesce database"
# Run me with:
#
# $ nginx -p /path/to/this/file/ -c nginx.conf
#
# All requests are then routed to authenticated user's index, so
#
# GET http://user:password@localhost:8080/_search?q=*
#
# is rewritten to:
#