Skip to content

Instantly share code, notes, and snippets.


Alex Grin lyoshenka

View GitHub Profile
lyoshenka / .gitconfig
Last active Nov 13, 2020
current .gitconfig
View .gitconfig
diff = auto
status = auto
branch = auto
ui = auto
autocrlf = input
safecrlf = true
pager = cat
lyoshenka / s3dir.html
Last active Oct 2, 2019
Upload this file to an s3 bucket with static website hosting enabled to get a directory listing of the bucket contents. Example:
View s3dir.html
<!DOCTYPE html>
<div id="navigation"></div>
<div id="listing"></div>
<script type="text/javascript" src=""></script>
lyoshenka / 45-75.bookmarklet.js
Created Jan 25, 2019
Highlight the 45th through 75th character of a piece of text
View 45-75.bookmarklet.js
javascript:!function(){var a=document.createElement("style");a.type="text/css";a.innerHTML="p:hover, li:hover, dt:hover, dd:hover, h1:hover, h2:hover, h3:hover, h4:hover, h5:hover, h6:hover { outline: 2px solid red; }";document.body.appendChild(a);var d=function(c){var;,45)+"<span style='color: red;'>"+b.substring(45,75)+"</span>"+b.substring(75);document.removeEventListener("click",d);a.parentNode.removeChild(a)};document.addEventListener("click",d)}();
lyoshenka / clean-search-engines.js
Created Oct 30, 2018
Delete all non-custom search engines from chrome
View clean-search-engines.js
// DANGER: this will delete all search engines that don't have a `.` in their keyword
// Go to chrome://settings/searchEngines and put this in the console
.then(function(val) {
val.others.sort(function(a, b) { return b.modelIndex - a.modelIndex; });
val.others.forEach(function(engine) {
if (engine.keyword.includes(".")) {
lyoshenka / maintenance.html
Last active Oct 17, 2017 — forked from pitch-gist/gist:2999707
Simple Maintenance Page
View maintenance.html
<!doctype html>
<meta charset="utf-8" />
<title>Site Maintenance</title>
<style type="text/css">
body { padding: 50px 30px 30px; font: 20px Helvetica, sans-serif; color: #222; line-height: 1.4 }
h1 { font-size: 40px; }
article { text-align: left; max-width: 650px; margin: 0 auto; }
a { color: #dc8100; padding: 3px }
a:hover { color: #fff; background-color: #dc8100 }
lyoshenka / tx.go
Created Sep 4, 2017
A simple, neat way to wrap code in an sql transaction with proper committing/rollbacking and error handling.
View tx.go
// TxFunc is a function that can be wrapped in a transaction
type TxFunc func(tx *sql.Tx) error
// WithTx wraps a function in an sql transaction. After the function returns, the transaction is
// committed if there's no error, or rolled back if there is one.
func WithTx(db *sql.DB, f TxFunc) (err error) {
tx, err := db.Begin()
if err != nil {
return err
lyoshenka / asciiart.html
Last active Aug 13, 2017
Convert image to ASCII animation. This may not work through because of CORS, so check it out locally. Source:
View asciiart.html
* {margin: 0; padding: 0;}
body { text-align: center; }
#ascii { font-family: monospace; font-size: 11px; line-height: 70%; }
#sprite { display: none; }
#container { overflow: hidden; display: inline-block; }
#!/usr/bin/env bash
set -euo pipefail
#set -x
if [ "$(uname)" == "Darwin" ]; then
echo "macOS install coming soon"
exit 1
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
echo "Starting linux install"
lyoshenka /
Last active Oct 12, 2020
Keep this in mind

Coding Maxims

numbered for ease of reference, not for ranking

  1. code is debt (and bad code is an unhedged call option)
    • cant have 0-days or bugs if I dont write any code
    • our users dont care about the code
    • every line of code has costs (your time, readability, maintainability, complexity)
      • its like owning a house with lots of rooms. its nice when your friends come over once a month, but you pay rent every day
    • dont add features unless you're sure it is necessary
lyoshenka /
Created Dec 9, 2016
Minimalistic API documentation for Python
# -*- coding: utf-8 -*-
from __future__ import print_function
"""Minimal API documentation generation."""
# Imports
import inspect
You can’t perform that action at this time.