Skip to content

Instantly share code, notes, and snippets.

View reorx's full-sized avatar
YOLO

Xiao Meng reorx

YOLO
View GitHub Profile
@reorx
reorx / remap-capslock-to-control-win10.md
Created January 17, 2022 05:28 — forked from joshschmelzle/remap-capslock-to-control-win10.md
Remap Caps Lock to Control on Windows 10

Ways to remap caps lock to control on Windows 10

These methods in this gist worked for me on my U.S.-based keyboard layouts. I am unsure about other layouts. If you have problems, revert your changes; delete the registry key you created (and reboot).

Update: you should probably scroll down to approach 4 where I suggest using Microsoft PowerToys Keyboard Manager.

Approach 1. Manually through regedit

Navigate to and create a new binary value in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout named Scancode Map.

@reorx
reorx / postgresql.md
Created June 15, 2016 09:39
PostgreSQL cheatsheet. Basic stuff, but I always forget it.

Create a new database cluster.

pg_ctl init -D /usr/local/var/postgres

Start, stop and restart the database.

pg_ctl -D /usr/local/var/postgres -l logfile start
pg_ctl -D /usr/local/var/postgres stop
pg_ctl -D /usr/local/var/postgres restart
@reorx
reorx / cidr2regex.py
Created January 12, 2016 04:36 — forked from waffle2k/cidr2regex.py
Convert CIDR notation to regex
#!/usr/bin/python
''' Not my script, found on the Internet, and rediscovered on my hard drive
'''
import sys
def cidr_to_regex(cidr):
ip, prefix = cidr.split('/')
base = 0
for val in map(int, ip.split('.')):
@reorx
reorx / rocket.md
Last active October 2, 2015 12:43 — forked from mattt/rocket.md
Rocket: a hybrid approach to real-time cloud applications

This document was originally posted on 8/1/2013.

a hybrid approach to real-time cloud applications

Rocket is a technique for building real-time functionality on top of REST web services that leverages web standards like [Server-Sent Events][SSE] and [JSON Patch][RFC6902]. Most importantly, it fits comfortably with how you're already building applications.

A Tale of Two Paradigms

Just as light can act as both a particle and a wave, so information can be thought as both a document and a stream.

Each approach has its particular strengths and weaknesses:

@reorx
reorx / tmux-cheatsheet.markdown
Last active August 29, 2015 14:26 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
---
# Python 简介
@su27 and @menghan
---

What is Python?

Python: 优雅而健壮的编程语言

  • 高级

  • 易学易读易维护

#!/bin/bash
#
BASE=/tmp
PID=$BASE/app.pid
LOG=$BASE/app.log
ERROR=$BASE/app-error.log
PORT=11211
LISTEN_IP='0.0.0.0'
MEM_SIZE=4
" }}}2 字串長度(column 數) {{{2
function StrWidth(str)
if exists('*strwidth')
return strwidth(a:str)
else
let strlen = strlen(a:str)
let mstrlen = strlen(substitute(a:str, ".", "x", "g"))
if strlen == mstrlen
return strlen
@reorx
reorx / xiami_decode.py
Created November 17, 2012 19:17 — forked from dndx/xiami_decode.py
Xiami URL Decoder
import urllib2
def xiami_decode(s):
s = s.strip()
if not s:
return False
result = []
line = int(s[0])
rows = len(s[1:]) / line
extra = len(s[1:]) % line