Skip to content

Instantly share code, notes, and snippets.

use std::fs::{File, remove_file};
use std::io::{Read, Write};
use orion::hazardous::{
aead::xchacha20poly1305::{seal, open, Nonce, SecretKey},
mac::poly1305::POLY1305_OUTSIZE,
stream::xchacha20::XCHACHA_NONCESIZE,
};
use orion::hazardous::stream::chacha20::CHACHA_KEYSIZE;
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active May 10, 2024 02:42
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@repodevs
repodevs / macOS.sh
Created December 12, 2018 14:56
gpg: signing failed: Inappropriate ioctl for device macOS
❱ git config user.signingKey 38AF394C
❱ git config commit.gpgSign true
❱ echo "test" | gpg --clearsign
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
test
gpg: signing failed: Inappropriate ioctl for device
gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
@niksumeiko
niksumeiko / git.migrate
Last active May 10, 2024 02:41
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@lithium0003
lithium0003 / BitLinear.cpp
Last active May 10, 2024 02:40
BitNet b1.58 BitLinear layer's fast multiply weight
#ifdef __ARM_FEATURE_DOTPROD
if(lastdim % 16 == 0) {
for(int i = 0; i < outer_shape; i++) {
for(int k = 0; k < unit; k++) {
int64_t v = 0;
auto *xp = &x_quant[i * lastdim];
auto *wp = &q_weight[k * lastdim];
asm volatile(
"MOV x0, xzr\n"
"DUP v0.2d, x0\n"
@layneson
layneson / build.zig
Created April 15, 2020 15:33
Custom step in build.zig
const std = @import("std");
const Builder = std.build.Builder;
const Step = std.build.Step;
pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("hw", "hw.zig");
exe.setTarget(target);
@Kaapiii
Kaapiii / Instruction.md
Last active May 10, 2024 02:39
Ubuntu 20.04/20.10 Install TLP for Lenovo ThinkPad

Installation Instruction for TLP for Lenovo ThinkPads

Install & Start TLP & Check System Status

sudo apt install tlp tlp-rdw
sudo tlp start
sudo tlp-stat -s

Check status of battery features with

@ageis
ageis / .bashrc 02-25-2020
Last active May 10, 2024 02:34
@ageis's ~/.bashrc 🖥️ with numerous useful functions, aliases and one-liners. ⚠️ NOTE: many paths in sourced scripts and environment variables are specific to my system, but if you dig in I hope you'll find something you can use!
#!/bin/bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# kevin gallagher (@ageis) <kevingallagher@gmail.com>
# normally I divide this into separate files: .bashrc, .bash_profile, .bash_aliases and .bash_functions (also .bash_logout), but it's all concatenated here.
ulimit -s unlimited
export MYUID=$(id -u)
export USER="$(id -un)"
if [[ "$TILIX_ID" ]] || [[ "$VTE_VERSION" ]]; then
@konfou
konfou / mkvextract-helper.sh
Last active May 10, 2024 02:33
extract all tracks/attachments/chapters from an mkv file
#!/usr/bin/env bash
#
# Extract all tracks/attachments/chapters from an mkv file.
# depends
type -p mkvmerge &>/dev/null || exit 3
type -p mkvextract &>/dev/null || exit 3
# trap SIGINT
trap 'trap - INT; kill -s INT "$$"' INT
@fcoury
fcoury / id_rsa_encryption.md
Created December 5, 2015 19:20
Encrypt/Decrypt a File using your SSH Public/Private Key on Mac OS X

A Guide to Encrypting Files with Mac OS X

This guide will demonstrate the steps required to encrypt and decrypt files using OpenSSL on Mac OS X. The working assumption is that by demonstrating how to encrypt a file with your own public key, you'll also be able to encrypt a file you plan to send to somebody else using their private key, though you may wish to use this approach to keep archived data safe from prying eyes.

Too Long, Didn't Read

Assuming you've already done the setup described later in this document, that id_rsa.pub.pcks8 is the public key you want to use, that id_rsa is the private key the recipient will use, and secret.txt is the data you want to transmit…

Encrypting

$ openssl rand 192 -out key

$ openssl aes-256-cbc -in secret.txt -out secret.txt.enc -pass file:key