Skip to content

Instantly share code, notes, and snippets.

View ulidtko's full-sized avatar
🤔
What it feels like, to live in a collapsing civilization?

Maxim Ivanov ulidtko

🤔
What it feels like, to live in a collapsing civilization?
View GitHub Profile

I use a cordless mouse, and it's powered by a pair of alkaline LR6 batteries (the ubiquitous 1.5 V ones). It's been frustrating to have to replace them every few months once they drain, often in a middle of an activity (such as gaming online). Even though I try to recycle the used batteries, having to go out for fresh ones is an inconvenience.

So, instead of obtaining a stock of alkalines, I [bought][dx 14500] a few rechargable LiPo batteries in the 14500 form factor, and a lithium-polymer charger. The nice thing about this form-factor is that it matches AA: mechanically, you can insert 14500 in whatever AA holder your device has got. The bad thing is that the voltage is different. Single LiPo cell has 3.1–4.2 range (with 3.7 V nominal), while alkalines produce 1.0–1.5. A pair of alkalines, however, is usually required for the common 3.3 V digital logic; so, with trivial modifications to the holder, I was able to go like this:

14500 photo

@ulidtko
ulidtko / libusbx debug log
Last active August 29, 2015 14:03
Heimdall SGS5 USB capture
Heimdall v1.4.1
Copyright (c) 2010-2014 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/
This software is provided free of charge. Copying and redistribution is
encouraged.
If you appreciate this software and you would like to support future
development please consider donating:
@ulidtko
ulidtko / git-debtag
Created August 13, 2014 17:54
External Git command for autotagging Debian package repos via debian/changelog blaming
#!/bin/sh
pkgname=$(dpkg-parsechangelog | sed -n 's/^Source: //p')
git blame -ltf debian/changelog \
| awk '/^[0-9a-f]+ .+ (\([^)]*\)) '$pkgname'/{gsub("[()]", "", $8); print $8, $1}' \
| head -n 50 | xargs -l1 git tag -f
@ulidtko
ulidtko / mahjong-tileset.html
Last active December 21, 2015 03:58
A quick page with the full set of 136 click-dissolvable Mahjong tiles. Be sure to use Unicode (⩾5.1) –compliant fonts.
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Mahjong tile set</title>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<style>
body {
@ulidtko
ulidtko / traverse.hs
Created April 26, 2016 12:24
Imperative tree traversal sample
{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Data.Foldable
import Data.Traversable
import Data.IORef
data BinTree a = Leaf a | Node (BinTree a) (BinTree a)
deriving (Functor, Foldable, Traversable, Show)
@ulidtko
ulidtko / aes-z3-excercise.py
Created September 5, 2017 14:26
aes128 cbc/ctr static IV attack with z3
from z3 import *
from binascii import unhexlify, hexlify
from itertools import chain
"""
Up for an excercise huh?
https://www.reddit.com/r/crypto/comments/y7c3m/key_recovery_on_aes_ctr_with_static_iv/
> The trivial version of this attack can be done when you that ciphertext_0 is the encryption of known plaintext plaintext_0. Then, to decrypt ciphertext_n you take ciphertext_n xor ciphertext_0 which equals plaintext_n xor plaintext_0. Since you know plaintext_0 already, you can compute (plaintext_n xor plaintext_0) xor plaintext_0 which cancels out the plaintext_0s leaving you with plaintext_n.
@ulidtko
ulidtko / kmod-fridge-cleanup.conf
Created June 30, 2019 12:24
Keep Arch Linux fully functional after kernel updates
# /etc/tmpfiles.d/kmod-fridge-cleanup.conf
#Type Path Mode User Group Age Argument
D! /lib/modules/fridge 0755 root root -
#-- Inspired by #archlinux IRC & this thread:
# https://www.reddit.com/r/archlinux/comments/4zrsc3/keep_your_system_fully_functional_after_a_kernel/
#
#-- ulidtko, June 2019 [File 3/3]
@ulidtko
ulidtko / transdeps.hs
Last active October 28, 2019 17:33
Yum dependency walker script
{-# LANGUAGE ViewPatterns, LambdaCase, FlexibleContexts #-}
module Main where
import Control.Applicative
import System.Environment
import System.Exit
import System.IO
import System.Process
import Data.List (nub, sort)
# -*- coding: utf-8 -*-
import urwid
from urwid import MainLoop, ExitMainLoop
from urwid import Text, Edit, Button
from urwid import Frame, Pile, Padding, Filler, LineBox, Columns, Divider
from urwid import SolidFill, BoxAdapter
LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
def on_keypress(key):