Skip to content

Instantly share code, notes, and snippets.

@hotsyk
hotsyk / keybase.md
Last active September 9, 2019 20:35

Keybase proof

I hereby claim:

  • I am hotsyk on github.
  • I am hotsyk (https://keybase.io/hotsyk) on keybase.
  • I have a public key whose fingerprint is C89F 6A44 3E9B E20B 1EA7 7763 4064 F790 B2A6 B2A6

To claim this, I am signing this object:

@hotsyk
hotsyk / elasticsearch-cheatsheet.txt
Created May 24, 2018 23:49 — forked from stephen-puiszis/elasticsearch-cheatsheet.txt
Elasticsearch Cheatsheet - An Overview of Commonly Used Elasticsearch API Endpoints and What They Do
# Elasticsearch Cheatsheet - an overview of commonly used Elasticsearch API commands
# cat paths
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/indices
/_cat/indices/{index}
@hotsyk
hotsyk / postgres_queries_and_commands.sql
Last active April 26, 2017 19:59 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@hotsyk
hotsyk / tree.md
Created May 26, 2012 19:32 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@hotsyk
hotsyk / mongolyze.py
Created February 22, 2012 13:41 — forked from sergray/mongolyze.py
Python script for automated analysis of slow queries in mongodb
"""
Script for automated analysis of profiling data in MongoDB,
gathered by Mongo with db.setProfilingLevel(1).
See <http://www.mongodb.org/display/DOCS/Database+Profiler>
TODO: pass collection and database with profiling data in arguments
TODO: make thread-safe
"""
from collections import defaultdict
@hotsyk
hotsyk / gist:1885208
Created February 22, 2012 13:41
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+X delete line
Ctrl+↩ insert line after
Ctrl+⇧+↩ insert line before
Ctrl+⇧+↑ move line (or selection) up
@hotsyk
hotsyk / gist:1074423
Created July 10, 2011 09:49
Way to avoid pyflakes error in the settings.py
try:
import local_settings
for param in dir(local_settings):
if not '__' in param:
setattr(sys.modules[__name__], param,\
getattr(local_settings, param))
except ImportError:
pass
@hotsyk
hotsyk / gist:727636
Created December 3, 2010 22:07
Script to dump db and upload dump file to S3
#!/bin/bash
myfilename=$(date "+%Y-%m-%d_%H:%M")
pg_dump -U dbuser -w dbname | gzip > /var/www/dbbackups/dbname-$myfilename.dump.gz
/var/www/s3/s3-put -S -k <your-key> -s /var/www/dbbackups/secret.key -T /var/www/dbbackups/dbname-$myfilename.dump.gz /dbname-dbbackups/dbname/$myfilename-dbname.dump.gz
##you will need to get http://s3-bash.googlecode.com/files/s3-bash.0.02.tar.gz
##to ensure that secret file is 40 bytes, use
##echo -n your-secret-ket > secret.key
execve("/var/www/idhooks-root/env2/bin/pip", ["pip", "install", "-E", ".", "-r", "./releases/20100803183012/requir"...], [/* 24 vars */]) = 0
brk(0) = 0x85c6000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f84000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=26370, ...}) = 0
mmap2(NULL, 26370, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f7d000
close(3) = 0
open("/usr/lib/libpython2.5.so.1.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260\306\1\0004\0\0\0"..., 512) = 512
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._