Skip to content

Instantly share code, notes, and snippets.

@feelfreetofee
feelfreetofee / gaes.js
Created September 21, 2024 04:41
AES-256 Decrypt
function addRoundKey(block, words, round) {
const result = []
for (let i = 0; i < 16; i++)
result[i] = block[i] ^ words[round][i]
return result
}
const shift = [0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3]
function shiftRows(block) {
@feelfreetofee
feelfreetofee / index.js
Created September 10, 2024 15:06
Webview binding for Bun in JS https://github.com/webview/webview
import {JSCallback, CString} from 'bun:ffi'
import {encodeCString, default as lib} from './lib'
export class Webview {
static #instances = []
static unload() {
for (const instance of this.#instances)
instance.destroy()
lib.close()
}
#handle
@feelfreetofee
feelfreetofee / alphabet.js
Created September 9, 2024 18:29
Creates an array containing the alphabet
Array.from({length: 26}, (_, i) => String.fromCharCode(97 + i))
Array(26).fill().map((_, i) => String.fromCharCode(97 + i))
[...Array(26).keys()].map(i => String.fromCharCode(97 + i))
[...Array(26)].map((_, i) => String.fromCharCode(97 + i))
@feelfreetofee
feelfreetofee / twitch.js
Created July 20, 2024 00:04
Chatbot working on Browser and Bun
export class Twitch {
#event = new EventTarget
on(...data) {
this.#event.addEventListener(...data)
}
removeListener(...data) {
this.#event.removeEventListener(...data)
}
#capabilities = []
@feelfreetofee
feelfreetofee / led.lua
Created June 30, 2024 00:39
WiringPi Lua GPIO
local uv = require('uv')
local gpio = require('./wiringPi.lua')
gpio.wiringPiSetup()
local led = 2
local led_state = gpio.digitalRead(led)
gpio.pinMode(led, 1) -- OUTPUT
while true do
@feelfreetofee
feelfreetofee / libpilwgpio.lua
Created May 5, 2024 20:08
Raspberry Pi GPIO with Lua
local ffi = require('ffi')
local lib = ffi.load('libpilwgpio.so') -- https://github.com/besp9510/pi_lw_gpio
-- GPIO operation function prototypes:
ffi.cdef[[
int gpio_set(int p);
int gpio_clear(int p);
int gpio_read_level(int p);
int gpio_set_mode(int mode, int p);
int gpio_read_mode(int p);
@feelfreetofee
feelfreetofee / rps.js
Last active April 17, 2024 12:02
Infinite Rock Paper Scissors
function rps(game, a, b) {
if (a == b) return 0 // Tie
const r = game.indexOf(a) - game.indexOf(b)
// An even number will decide "A" winner for positive numbers, odd for negative
return r % 2 == (r < 0 ? 0 : 1)
}
// Game elements lenght must be an odd number
const games = [
[ // Original
const types = {
100(data, position) { // d
position[0]++
const dictionary = {}
while (data[position[0]] !== 101) dictionary[buffer(data, position)] = decode(data, position)
position[0]++
return dictionary
},
108(data, position) { // l
position[0]++
<style>
body {
background: #fff;
user-select: none;
overflow: hidden;
margin: 0;
}
#loading_box {
background: #252525;
padding: 0.5%;
@feelfreetofee
feelfreetofee / particles.lua
Created December 2, 2022 09:31
FiveM Particles Sync Event
-- Client
clientParticles = {}
RegisterNetEvent('ClientParticle')
AddEventHandler('ClientParticle', function(player, name, dictionary, pos, rot, bone, scale)
if pos then
local ped = GetPlayerPed(GetPlayerFromServerId(player))
RequestNamedPtfxAsset(dictionary)