Skip to content

Instantly share code, notes, and snippets.

View onjin's full-sized avatar

Marek Wywiał onjin

View GitHub Profile
@onjin
onjin / hints
Created June 27, 2018 22:01
display hints from devhints.io
#!/usr/bin/env bash
type wget >/dev/null 2>&1 || { echo >&2 "I require wget but it's not installed."; exit 1; }
type mdless >/dev/null 2>&1 || { echo >&2 "I require mdless but it's not installed. sudo gem install mdless"; exit 1; }
TOOL=${1:?Usage: $0 <toolname> [--refresh]}
REFRESH=${2:-no}
RAW_MD_URL="https://raw.github.com/hazeorid/devhints.io/gh-pages/${TOOL}.md"
@onjin
onjin / digital_root.py
Created April 10, 2018 20:17
Calculate digital root with modulo arithmetic.
#!/usr/bin/env python
def root(n):
"""Calculate digital root with modulo arithmetic."""
return n % 9 or n and 9
if __name__ == "__main__":
for i in range(9):
Every message has 3 ids, MessageId, CorrelationId, CausationId.
When you are responding to a message (either a command or an event)
you copy the CorrelationId of the message you are responding to to your message.
The CausationId of your message is the MessageId of the message you are responding to.
@onjin
onjin / ponyc
Created January 10, 2018 10:00
bash script to run pony language compiler using docker
#!/bin/bash
# run pony compiller using docker
# requires realpath programm - apt-get install realpath
path=$(realpath "$@")
/usr/bin/docker run --rm -v ${path}:/src/main ponylang/ponyc
@onjin
onjin / postgres_queries_and_commands.sql
Created September 29, 2017 08:27 — 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%'
@onjin
onjin / fb.css
Created August 2, 2017 08:26
usercss / fb
body, #contentCol {
background-color: #fff !important;
}
#blueBarDOMInspector > div > div {
background-color: orange;
border-bottom: 0px;
}
#pagelet_ego_pane,
#pagelet_canvas_nav_content,
#pagelet_ticker {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Simple json server.
echo '{"data": "some"}' > p1.json
python -m jsonserver
curl http://localhost:8000/p1
"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import namedtuple
import requests
import logging
import json
import enum
class ApiInteraction(enum.Enum):
@onjin
onjin / specification.py
Created February 6, 2017 10:03 — forked from palankai/specification.py
Python Specification Pattern
class Specification:
def __and__(self, other):
return And(self, other)
def __or__(self, other):
return Or(self, other)
def __xor__(self, other):
return Xor(self, other)
START: [URL …or… mobile OS + app]
STEPS:
1. [list the exact steps it takes to reproduce the problem]
2. [use numbers to show each step in order]
3. [include multiple apps if necessary]
4. [write it so a 10 year old could reproduce]
ACTUAL: [identify the thing that is broken, screenshots help]
EXPECTED: [explain what you expected to see]
URGENCY: [only for critical production issue reports]
Example: