Skip to content

Instantly share code, notes, and snippets.

View belous's full-sized avatar

Sergei Belous belous

View GitHub Profile
@belous
belous / Regex Cheat Sheet.md
Created February 20, 2017 11:35
Regex Cheat Sheet
  • Any metacharacter can be escaped using a backslash, \. This turns it back into a literal. So the regular expression c\.t means "find a c, followed by a full stop, followed by a t".
  • The backslash is a metacharacter, which means that it too can be escaped using a backslash. So the regular expression c\\t means "find a c, followed by a backslash, followed by a t".
  • The regular expression c[aeiou]t means, "find a c followed by a vowel followed by a t". In a piece of text, this will find cat, cet, cit, cot and cut.
  • The regular expression [0123456789] means "find a digit".
  • The regular expression [a] means the same as a: "find an a".
  • The regular expression [ ] means "find a space".
  • \[a\] means "find a left square bracket followed by an a followed by a right square bracket".
  • [\[\]ab] means "find a left square bracket or a right square bracket or an a or a b".
  • [\\\[\]] means "find a backslash or a left square bracket or a right square bracket". (Urgh!)
  • [b-f] is the same as `[bc
@belous
belous / PDB Snippet.sublime-snippet
Last active July 25, 2022 11:32
Using pdb with redirect input/output to another terminal
<snippet>
<content><![CDATA[
# tty
# while true; do sleep 10000; done
f1 = open('/dev/pts/${1:1}', 'r')
f2 = open('/dev/pts/${1:1}', 'w')
import pdb
pdb.Pdb(stdin=f1, stdout=f2).set_trace()]]>
</content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
#lang racket/gui
;list with nought's moves ((1 1)(2 2)(3 3)(4 4))
(define noughts '())
(define (addNewNought x y)
(set! noughts (append noughts (list (append (cons x '())
(cons y '()))))))
;list with cross's moves
(define crosses '())
(define (addNewCross x y)