Skip to content

Instantly share code, notes, and snippets.

View KhodeN's full-sized avatar

Artem Berezin KhodeN

View GitHub Profile
SELECT
array_agg(s),
rn
FROM (SELECT
s,
((row_number()
OVER ()) - 1) / 10 + 1 AS rn
FROM generate_series(1, 100) s) g
GROUP BY rn
ORDER BY rn;
for (const k of ['key', 'code', 'which', 'keyCode', 'charCode']) {
console.log('e.' + k + '=', e[k]);
}
console.log();
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC;
package main
import (
"encoding/json"
"fmt"
)
type Sale struct {
Description string
}
/// <reference path="./index.d.ts"/>
import { MockUtils } from './MockUtils';
import 'ngMockE2E';
let moduleName = 'stMocks';
angular.module(moduleName, ['ngMockE2E'])
.service('$mockUtils', MockUtils)
.constant('mockDelay', 0)
@KhodeN
KhodeN / squid_fake_auth.py
Last active May 16, 2016 01:51
``` auth_param basic program /usr/local/squid/libexec/fake auth_param digest realm SquidAuth auth_param digest children 10 acl auth_users proxy_auth REQUIRED ```
#!/usr/bin/python
import sys
import socket
import logging
logging.basicConfig(filename="/tmp/squid_auth.log", level=logging.DEBUG)
"""USAGE:The function returns True if the user and passwd match False otherwise"""
def matchpasswd(login,passwd):
# Write your own function definition.
# static server
server {
listen 80;
server_name beta.sociotex.com;
location /.well-known {
root /usr/share/nginx/html;
}
rewrite ^ https://$server_name$request_uri?;
}
server {
@KhodeN
KhodeN / apidoc_watch.sh
Created February 26, 2016 12:50
fswatch example
#!/bin/bash
apidoc
fswatch -0 -o -l 1 web | xargs -0 -n 1 -I {} apidoc

Вертикальное выравнивание

Несколько модифицированная версия метода CSS-Tricks css-tricks.com/centering-in-the-unknown для вертикального центрирования элементов с динамическими размерами. Работает красиво и не требует дополнительных не-семантических элементов HTML.

@mixin ghostVerticalAlign(){
  &:before {
    content: '';
    display: inline-block;
 vertical-align: middle;
@KhodeN
KhodeN / dump.sh
Created January 28, 2016 09:37
dump psql by cron
#!/bin/bash
now=$(date +"%Y-%m-%d_%H:%M")
cd /projects/datamarket
pg_dump -U postgres dm | gzip > backups/dm_dump_$now.sql.gz
# use this row to backup every hour
# crontab -e
# * */1 * * * /projects/datamarket/dump.sh