Skip to content

Instantly share code, notes, and snippets.


Lio李歐 lionello

View GitHub Profile
lionello / stashd.d
Last active Aug 7, 2022
Tool to find GIT stashes containing changes to specified file(s)
View stashd.d
#!/usr/bin/env rdmd
// Get rdmd from (or brew, nix, apt, yum)
// Copyright Lionello Lunesu. Placed in the public Domain.
import std.stdio : writeln;
int main(string[] args) {
import std.process : pipeProcess, wait, Redirect;
lionello / base64url
Last active Aug 6, 2022
base64url: wrapper script for base64
View base64url
#!/usr/bin/env bash
# Source:
while [ $# -gt 0 ]; do
lionello / writevt.c
Last active Aug 1, 2022
Forked writevt from console-tools
View writevt.c
* Mostly ripped off of console-tools' writevt.c
#include <stdio.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
lionello /
Created Jun 13, 2022 — forked from bgreenlee/
Automatic project versioning for Xcode using git commits & tags #xcode #git
# by Marc Hedlund
# Found at and slightly
# modified.
# To install:
lionello / cas128.c
Last active Apr 7, 2022
__sync_val_compare_and_swap for __uint128_t GCC built-in
View cas128.c
__sync_val_compare_and_swap that works with __uint128_t, by Lionello Lunesu.
Placed in the public domain
#undef NDEBUG
#include <assert.h>
inline __uint128_t InterlockedCompareExchange128( volatile __uint128_t * src, __uint128_t cmp, __uint128_t with )
__asm__ __volatile__
lionello / ModExp.sol
Last active Mar 17, 2022
Solidity wrapper for Ethereum Byzantium's BigInt `modexp` built-in contract 0x5
View ModExp.sol
pragma solidity ^0.4.17;
contract ModExp {
// Wrapper for built-in bigint_modexp (contract 0x5) as described here
function modexp(bytes memory _base, bytes memory _exp, bytes memory _mod) public view returns(bytes memory ret) {
uint256 bl = _base.length;
uint256 el = _exp.length;
uint256 ml = _mod.length;
lionello / ECMath.sol
Last active Mar 16, 2022
ECDSA verification and recovery for curve secp256r1
View ECMath.sol
MIT License
Copyright (c) 2018 Lionello Lunesu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
lionello / translatekeycodes.swift
Created Jan 18, 2022 — forked from ArthurYidi/translatekeycodes.swift
virtual key codes to unicode characters
View translatekeycodes.swift
private static func keyCodeToString(keyCode: CGKeyCode, eventModifiers: Int) -> String? {
let curKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()
let rawLayoutData = TISGetInputSourceProperty(curKeyboard, kTISPropertyUnicodeKeyLayoutData)
let layoutData = unsafeBitCast(rawLayoutData, to: CFData.self)
let keyboardLayoutPtr = unsafeBitCast(CFDataGetBytePtr(layoutData), to: UnsafePointer<UCKeyboardLayout>.self)
var deadKeyState: UInt32 = 0
var actualStringLength = 0
var unicodeString: [UniChar] = [0, 0, 0, 0]
View DefaultKeyBinding.dict
/* put this file in ~/Library/KeyBindings/ */
/* Home */
"\UF729" = "moveToBeginningOfLine:";
"^\UF729" = "moveToBeginningOfDocument:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"^$\UF729" = "moveToBeginningOfDocumentAndModifySelection:";
/* End */
View .emacs
(require 'package)
(add-to-list 'package-archives '("org" . ""))
(add-to-list 'package-archives '("melpa" . ""))
(add-to-list 'package-archives '("melpa-stable" . ""))
(setq package-enable-at-startup nil)