Skip to content

Instantly share code, notes, and snippets.

View gideongrinberg's full-sized avatar

Gideon Grinberg gideongrinberg

View GitHub Profile
@gideongrinberg
gideongrinberg / fxmanifest.lua
Created September 25, 2021 14:44
Enable the Cayo Perico map on FiveM
fx_version 'cerulean'
games { 'gta5' }
client_script "script.lua"
@gideongrinberg
gideongrinberg / powMod.ts
Created June 9, 2021 01:25
Modular exponentiation in AssemblyScript/Typescript.
/**
Modular exponentiation in AssemblyScript/TypeScript. Computes `a^b %n`.
Note that you'll likely need to change the int type. I'm using
the u128 (128-bit unsigned integer) from as-bignum.
@param a The base.
@param b The power.
@param n The modulus.
*/
export function powMod(a: u128, b: u128, n: u128): u128 {
@gideongrinberg
gideongrinberg / README.md
Last active March 28, 2023 21:41
BNF Grammars

BNF Grammars

I'm using this gist to collect a bunch of BNF grammars I've written, extracted, or found across the web. All of them are representations of existing languages. I found them useful, someone else might as well

Languages:

C c-grammar.bnf - An incomplete representation of the C language in BNF (from 1988, all newer versions I could find were EBNF or PEG. Let me know if you have a better one.)

Adapted from The C Programming Language, 2nd edition, by Brian W. Kernighan and Dennis M. Ritchie,Prentice Hall, 1988.

Python Wiggle Walk

This is a turtle simulation of a random wiggle walk.

Steps

  1. Create 20 turtles of a random color
  2. Move forward 10 steps
  3. Turn randomly (from 0 to 360 in rounded.py, and any multiple of 90 in straight.py)
@gideongrinberg
gideongrinberg / PID-Gyro.py
Last active September 29, 2019 16:06
An EV3dev2 Python Script that uses a PID algorithm to correct drift.
from ev3dev2.sensor.lego import GyroSensor
gyro = GyroSensor()
gyro.mode = GYRO-ANG
def gyroPID(ki,kp,kd,target,wheel,speed,distance)
while True:
error = target - gyro.mode
integral = integral + error
error - last_error = derivative
integralResult = integral*ki