Skip to content

Instantly share code, notes, and snippets.

@lyoshenka
lyoshenka / .gitconfig
Last active March 9, 2021 12:42
current .gitconfig
[color]
diff = auto
status = auto
branch = auto
ui = auto
[core]
autocrlf = input
safecrlf = true
pager = cat
[alias]
@lyoshenka
lyoshenka / s3dir.html
Last active October 2, 2019 13:48
Upload this file to an s3 bucket with static website hosting enabled to get a directory listing of the bucket contents. Example: http://build.lbry.io
<!DOCTYPE html>
<html>
<head>
<title>Files</title>
</head>
<body>
<div id="navigation"></div>
<div id="listing"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
@lyoshenka
lyoshenka / 45-75.bookmarklet.js
Created January 25, 2019 17:01
Highlight the 45th through 75th character of a piece of text
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 b=c.target.innerText;c.target.innerHTML=b.substring(0,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
lyoshenka / clean-search-engines.js
Created October 30, 2018 19:10
Delete all non-custom search engines from chrome
// 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
settings.SearchEnginesBrowserProxyImpl.prototype.getSearchEnginesList()
.then(function(val) {
val.others.sort(function(a, b) { return b.modelIndex - a.modelIndex; });
val.others.forEach(function(engine) {
if (engine.keyword.includes(".")) {
settings.SearchEnginesBrowserProxyImpl.prototype.removeSearchEngine(engine.modelIndex);
}
@lyoshenka
lyoshenka / maintenance.html
Last active October 17, 2017 22:40 — forked from pitch-gist/gist:2999707
Simple Maintenance Page
<!doctype html>
<html><head>
<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
lyoshenka / tx.go
Created September 4, 2017 20:59
A simple, neat way to wrap code in an sql transaction with proper committing/rollbacking and error handling.
// 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
lyoshenka / asciiart.html
Last active August 13, 2017 19:01
Convert image to ASCII animation. This may not work through rawgit.com because of CORS, so check it out locally. Source: http://thecodeplayer.com/walkthrough/cool-ascii-animation-using-an-image-sprite-canvas-and-javascript
<html>
<head>
<style>
* {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; }
</style>
</head>
#!/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
lyoshenka / coding_maxims.md
Last active August 23, 2023 21:18
Keep this in mind
@lyoshenka
lyoshenka / api_doc.py
Created December 9, 2016 15:34
Minimalistic API documentation for Python
# -*- coding: utf-8 -*-
from __future__ import print_function
"""Minimal API documentation generation."""
#------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
import inspect