Skip to content

Instantly share code, notes, and snippets.

View zelark's full-sized avatar

Aleksandr Zhuravlёv zelark

View GitHub Profile
@zelark
zelark / jekyll.md
Last active May 10, 2020 15:24
#jekyll
$ bundle exec jekyll serve
https://jekyllrb.com/docs/installation/macos/#on-mojave-1014

sudo gem install bundler
sudo gem install -n /usr/local/bin/ jekyll
@zelark
zelark / postgres
Last active November 21, 2016 19:47
#links
https://postgrespro.ru/education/demodb
Full text search
http://qualcode.ru/article/postgresql-full-text-search/
https://github.com/piotrl/understand-full-text-search
http://stackoverflow.com/questions/10875674/any-reason-not-use-postgresqls-built-in-full-text-search-on-heroku
https://habrahabr.ru/users/rdruzyagin/topics/
https://gocardless.com/blog/zero-downtime-postgres-migrations-the-hard-parts/
@zelark
zelark / clojure
Last active January 27, 2017 16:59
#links
https://clojuredocs.org/quickref
http://clojurecourse.by/
http://mishadoff.com/blog/clojure-design-patterns/
http://www.braveclojure.com
http://www.braveclojure.com/core-functions-in-depth/#A_Vampire_Data_Analysis_Program_for_the_FWPD
@zelark
zelark / 01-just-locks.sql
Last active October 17, 2016 10:12
locks in postgres #nc
select
lock.locktype,
lock.relation::regclass,
lock.mode,
lock.transactionid as tid,
lock.virtualtransaction as vtid,
lock.pid,
lock.granted
from pg_catalog.pg_locks lock
left join pg_catalog.pg_database db
# Возвращает замкнутое лямбда-выражение
# в котором n - свазянная переменная,
# а x и y - свободные, захваченные из внешнего контекста.
def make_pair(x, y):
"""Создаёт пару из двух элементов x и y."""
return lambda n: x if n == 0 else y
# API:
def head(pair):
"""Возвращает голову пары, первый элемент."""
@zelark
zelark / calc.py
Last active August 29, 2015 14:26
Let’s Build A Simple Interpreter
# Token types
# EOF (end-of-file) token is used to indicate that
# there is no more input left for lexical analysis
INTEGER, PLUS, MINUS, MUL, DIV, EOF = 'INTEGER', 'PLUS', 'MINUS', 'MUL', 'DIV', 'EOF'
class Token(object):
def __init__(self, type, value):
# token type: INTEGER, PLUS, MINUS, or EOF
self.type = type
@zelark
zelark / minesweeper.py
Last active August 29, 2015 14:25
All you need to play with it is Python 3
from random import sample
class Cell:
BOMB = 'B'
FLAG = 'F'
def __init__(self):
self.status = 0
self.content = 0
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
create or replace function parsetid(tid) returns text as $$
select (regexp_matches($1::text, '\((\d+),\d+\)'::text))[1];
$$ language sql immutable strict;
create or replace function getgraph(idxname text) returns text as $$
declare
nblocks bigint;
blkno bigint;
i bigint;
t text;