This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "sha512.h" | |
#define ROR64(x, c) (((x) >> (c)) | ((x) << (64 - (c)))) | |
#define LOAD64_BE(p) \ | |
( ((uint64_t)((p)[7]) << 0) \ | |
| ((uint64_t)((p)[6]) << 8) \ | |
| ((uint64_t)((p)[5]) << 16) \ | |
| ((uint64_t)((p)[4]) << 24) \ | |
| ((uint64_t)((p)[3]) << 32) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <sys/random.h> | |
int x25519_keygen(uint8_t secret[32], uint8_t public[32]); | |
void x25519_secret_to_public(const uint8_t secret[32], uint8_t public[32]); | |
int x25519(const uint8_t secret[32], const uint8_t public[32], uint8_t out[32]); | |
/* | |
* RFC7748 X25519 Elliptic Curve Diffie-Hellman (ECDH) with Curve25519. | |
* Montgomery curve y² = x³ + 486662x² + x over GF(p) = GF(2^255 - 19). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TARGET="${1:-./narnia}" | |
narnia() { | |
base64 -d <<EOF | |
f0VMRgIBAQAAAAAAAAAAAAMAPgABAAAAeABAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAOAAB | |
AEAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAApgAAAAAAAACmAAAAAAAAAAAQ | |
AAAAAAAAMf9XampqaVgPBVhfDwVIuC9iaW4vc2gASInmUEiJ50itSIk+SI1UxghqO1gPBQ== | |
EOF | |
} | |
if ! narnia | cmp -s "$TARGET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Show battery information similar to `acpi -b` | |
if [ -n "${*:-$BAT}" ]; then for BAT in "${@:-$BAT}"; do echo "$BAT"; done | |
else find /sys/class/power_supply/ -maxdepth 1 -name 'BAT*' | LC_ALL=C sort | |
fi | while IFS= read -r BAT; do | |
if [ ! -r "$BAT" ] || [ ! -r "$BAT/uevent" ]; then | |
printf '%s unreadable\n' "$BAT" >&2 | |
continue | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TOTP() { | |
TOTP_SECRET="${1:-GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ}" | |
TOTP_DIGITS="${2:-6}" | |
TOTP_STEP="${3:-30}" | |
TOTP_TIME="${4:-"$(date '+%s')"}" | |
TOTP_COUNTER="$((TOTP_TIME / TOTP_STEP))" | |
printf '%016x' "${5:-$TOTP_COUNTER}" | xxd -r -p \ | |
| openssl dgst -sha1 -hmac "$(printf '%s' "$TOTP_SECRET" | base32 -d)" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stddef.h> | |
#include <stdint.h> | |
#define LOAD32_LE(p) \ | |
( ((uint32_t)((p)[0]) << 0) \ | |
| ((uint32_t)((p)[1]) << 8) \ | |
| ((uint32_t)((p)[2]) << 16) \ | |
| ((uint32_t)((p)[3]) << 24) \ | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dynamic window title with zsh shell. | |
# Shows current directory and running (multi-line) command. | |
case "$TERM" in (rxvt|rxvt-*|st|st-*|*xterm*|(dt|k|E)term) | |
local term_title () { print -n "\e]0;${(j: :q)@}\a" } | |
precmd () { | |
local DIR="$(print -P '[%c]%#')" | |
term_title "$DIR" "zsh" | |
} | |
preexec () { | |
local DIR="$(print -P '[%c]%#')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rb_tree.h" | |
#define PARENT_BIT 1 | |
#define COLOR_BIT 2 | |
#define PARENT_MASK (PARENT_BIT | COLOR_BIT) | |
#define rb_is_red(n) ((n) != (void *)0 && ((n)->parent & COLOR_BIT)) | |
#define rb_is_black(n) ((n) == (void *)0 || !((n)->parent & COLOR_BIT)) | |
#define rb_set_red(n) ((n)->parent |= COLOR_BIT) | |
#define rb_set_black(n) ((n)->parent &= ~COLOR_BIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// rustc -O makeuniq.rs | |
// cat .bash_history | ./makeuniq > .bash_history_uniq | |
use std::io::{self, Write}; | |
use std::io::prelude::BufRead; | |
use std::collections::HashSet; | |
fn main() { | |
let mut uniqs = HashSet::new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use irc::command::{IrcCommand}; | |
use futures::stream::{self, Stream}; | |
use futures::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; | |
use futures::{future, Future}; | |
use tokio_core::net::TcpStream; | |
use tokio_core::reactor::Handle; | |
use tokio_io::{io, AsyncRead}; |
NewerOlder