Skip to content

Instantly share code, notes, and snippets.

@shinkou
shinkou / unescape.py
Created May 12, 2022 18:22
A snippet which does what the unescape function does in Javascript
#!/usr/bin/env python3
# vim: fileencoding=utf-8 ff=unix lcs=tab\:>. list noet sw=4 ts=4 tw=0
#
# How to use:
# $ unescape.py 'Line 1\nLine 2\nLine 3\n' 'いち\nに\nさん\n'
#
import sys
def unescape(s):
return s.encode('raw_unicode_escape').decode('unicode_escape')
@shinkou
shinkou / McrouterTest.java
Last active April 22, 2021 14:36
Test connectivity of memcached clusters backed by Mcrouter
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Chun-Kwong Wong
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
@shinkou
shinkou / emoji_detector.py
Last active May 22, 2020 01:56
A Python 3 snippet which detects if input parameters have any emoji
#!/usr/bin/env python3
# vim: fenc=utf-8 ff=unix lcs=tab\:>. list noet ru sw=4 ts=4 tw=0
#
# How to use:
# $ emoji_detector.py 'sentence with emoji <INSERT EMOJI HERE>' ...
#
import re, sys
# [\u00a9\u00ae\u203c-\u2b55\u3030\u303d\u3297\u3299\U0001f004-\U0001fad6] # Emoji
# [\U0001f3fb-\U0001f3ff] # EMod
@shinkou
shinkou / EmojiDetector.java
Last active April 29, 2020 01:58
A Java snippet which detects if input parameters have any emoji
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Chun-Kwong Wong
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is