Skip to content

Instantly share code, notes, and snippets.

@elranu
elranu / README.md
Last active September 2, 2026 13:27
Omarchy/Hyprland: cycle keyboard layouts and announce the result on the native OSD (works with fcitx5 and docked external keyboards)

hypr-keyboard-layout-cycle

Switch keyboard layouts in Omarchy / Hyprland with a keybind, and get a native OSD card telling you which one you landed on.

It comes out of a concrete setup: a ThinkPad with kb_layout = "us,latam", fcitx5 as the input method, and a dock with an external USB keyboard. In that setup both of the obvious approaches fail, in ways you don't see.

The problem

@elranu
elranu / README.md
Created September 2, 2026 01:28
Swap the active workspaces of two monitors in Hyprland (0.55+ Lua dispatcher API)

hypr-swap-monitor-workspaces

Swap the active workspaces of two monitors in Hyprland: whatever is on one screen right now moves to the other and vice versa, windows included.

Hyprland already ships the swap itself — hl.dsp.workspace.swap_monitors — but it takes two monitor names. This script works out which two, so a single keybind keeps working when a monitor is plugged in or unplugged.

@elranu
elranu / encryption.ts
Created August 23, 2023 19:59 — forked from ChaoLiangSuper/encryption.ts
Stronger Encryption and Decryption in typescript
import crypto from 'crypto';
const ALGORITHM = 'aes-256-cbc';
const ENCODING = 'hex';
const IV_LENGTH = 16;
const KEY = process.env.ENCRYPTION_KEY!;
export const encrypt = (data: string) => {
const iv = crypto.randomBytes(IV_LENGTH);
const cipher = crypto.createCipheriv(ALGORITHM, new Buffer(KEY), iv);
@elranu
elranu / KmsSigner.ts
Created January 11, 2023 15:26 — forked from dangdennis/KmsSigner.ts
Typescripts ethers Signer using AWS KMS
// Code taken from https://gist.github.com/miguelmota/092da99bc8a8416ed7756c472dc253c4
import {
GetPublicKeyCommand,
KMSClient,
SignCommand,
} from "@aws-sdk/client-kms";
import { BigNumber, ethers, Signer, UnsignedTransaction } from "ethers";
import * as asn1 from "asn1.js";
import { AlchemyProvider } from "@ethersproject/providers";
@elranu
elranu / KmsSigner.js
Created January 11, 2023 15:26 — forked from miguelmota/KmsSigner.js
JavaScript ethers Signer using AWS KMS
const { BigNumber, Signer } = require('ethers')
const { keccak256, recoverAddress, joinSignature, resolveProperties, serializeTransaction, hashMessage, arrayify, defineReadOnly } = require('ethers/lib/utils')
const { KMSClient, GetPublicKeyCommand, SignCommand } = require('@aws-sdk/client-kms')
const asn1 = require('asn1.js')
const EcdsaPubKey = asn1.define('EcdsaPubKey', function () {
this.seq().obj(
this.key('algo').seq().obj(
this.key('a').objid(),
this.key('b').objid()
import { Injectable } from '@angular/core';
import * as firebase from 'firebase/app';
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from 'angularfire2/firestore';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/take';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/switchMap';
@elranu
elranu / IHasAdmin.sol
Created June 21, 2019 20:49
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&gist=
pragma solidity 0.5.4;
contract IHasAdmin {
function isAdmin(address accountAddress) public view returns (bool);
}

Keybase proof

I hereby claim:

  • I am elranu on github.
  • I am elranu (https://keybase.io/elranu) on keybase.
  • I have a public key ASBtfIH0jSptVZCe2rjL_q7t3zZalnoH1eqfohC2u4P4Fgo

To claim this, I am signing this object:

@elranu
elranu / upsert-pr.ps1
Created February 13, 2019 17:50
github PR upsert
$Token = 'username:token89898989';
$Base64Token = [System.Convert]::ToBase64String([char[]]$Token);
$Headers = @{ AUTHORIZATION= "Basic $Base64Token" };
$Body = '{
"title": "Title",
"body": "Please merge this PR",
"head": "user:headBranch",
"base": "baseBranch"
@elranu
elranu / profile.ps1
Created January 2, 2019 17:56
Git submodules helper
function git-checkout-b() {
git checkout -b $args[0]
$cmd = 'git checkout -b ' + $args[0]
git submodule foreach $cmd
}
function git-checkout() {
git checkout $args[0]
$cmd = 'git checkout ' + $args[0]
git submodule foreach $cmd