Skip to content

Instantly share code, notes, and snippets.

View gheja's full-sized avatar
🤘

Gabor Heja gheja

🤘
View GitHub Profile
@thygrrr
thygrrr / CameraZoomAndPan.gd
Last active July 27, 2024 20:40
CameraZoomAndPan.gd - Smooth, cursor-centric 2D Zoom for Godot
# SPDX-License-Identifier: Unlicense or CC0
extends Node2D
# Smooth panning and precise zooming for Camera2D
# Usage: This script may be placed on a child node
# of a Camera2D or on a Camera2D itself.
# Suggestion: Change and/or set up the three Input Actions,
# otherwise the mouse will fall back to hard-wired mouse
# buttons and you will miss out on alternative bindings,
# deadzones, and other nice things from the project InputMap.
RSA Private-Key: (6969 bit, 69 primes)
modulus:
01:01:57:5a:5e:73:6f:8f:02:77:e3:27:6e:c6:bd:
97:cf:32:95:de:59:a7:32:7e:64:84:e3:3e:e8:17:
f3:8c:07:5c:1e:74:7a:40:33:86:7b:45:bc:e0:b6:
c8:6c:e3:fa:5a:1c:65:18:1a:5c:fc:3c:8a:c4:f5:
6f:63:60:32:cc:cd:03:b5:c9:54:29:d5:b2:c1:24:
54:81:0b:f4:40:53:84:e5:14:2c:58:70:98:7f:36:
6b:ef:df:13:5e:8f:07:05:f1:42:25:cf:30:82:94:
9a:11:df:49:9a:76:51:ad:6e:d7:46:2d:b8:ed:39:
@marcan
marcan / rpi_cam_auth.py
Created January 25, 2019 07:48
Raspberry Pi Camera V2 DRM authentication example
import hmac, hashlib
# Data from I²C trace at https://hackaday.io/project/19480-raspberry-pi-camera-v21-reversed/log/52547-i2c-logic-analyzer-trace
# Secret key from VideoCore blob
# serial[8], serial[7:4], serial[3:0]
serial = bytes.fromhex("EE8C196D8301230B59")
# rPi -> camera random number
numIn = bytes.fromhex("5805F3C898C3133154498E082F2E703516F2DBD1")
from math import *
# a performant solution would store a prefix sum of line lengths to
# a sidechannel and then use that to do a bsearch; on the GPU,
# you'd do a sum tree / histopyramid as a preprocessing step
def find_point(points, d):
d = d
for i in range(1, len(points)):
x0,y0 = points[i-1]
x1,y1 = points[i]
@stecman
stecman / Makefile
Last active June 27, 2024 20:48
DS18B20 1-Wire implementation for Atmel AVR
DEVICE = atmega328p
CLOCK = 16000000
PROGRAMMER = -c arduino -P /dev/ttyUSB0 -b57600
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
SOURCES = $(shell find . -name '*.c')
OBJECTS = $(SOURCES:.c=.o)
# Automatic dependency resolution
@xem
xem / readme.md
Last active July 14, 2024 10:15
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@subzey
subzey / gist:b18c482922cd17693d65
Last active August 29, 2015 14:06
Few Tricks on Compressing Js13k Entry

Few Tricks on Compressing Js13k Entry

Most important detail: in js13k entry 13k stands for zipped entry size. And this detail makes js13k differ from other code golfing compos.

Last year winner entry uncompressed size was about 70k. 70 kilobytes! In js1k you have a month to minify 1k, so how much time would it take to minify 70k? Nope, you have only 1 month. So it's very unlikely one will manually golf the entry. And this is the other thing that makes js13k special: no hardcore manual "hell yeah I've stripped one byte!" golfing.

@subzey
subzey / dson.js
Last active August 29, 2015 14:02
DSON shim
var DSON = DSON || {
parse: function(v) {
return JSON.parse(v.replace(/"(\\"|[^"])*"|[a-z]+/gi, function(v) {
return {
such: '{',
wow: '}',
is: ':',
so: '[',
many: ']',
next: ',',
@kdzwinel
kdzwinel / trilateration.js
Created January 3, 2014 09:35
Simple trilateration algorithm implementation in JavaScript.
function getTrilateration(position1, position2, position3) {
var xa = position1.x;
var ya = position1.y;
var xb = position2.x;
var yb = position2.y;
var xc = position3.x;
var yc = position3.y;
var ra = position1.distance;
var rb = position2.distance;
var rc = position3.distance;
@raveren
raveren / cryptographically_secure_random_strings.php
Last active November 21, 2023 12:35
Generate cryptographically secure random strings. Based on Kohana's Text::random() method and this answer: http://stackoverflow.com/a/13733588/179104
function random_text( $type = 'alnum', $length = 8 )
{
switch ( $type ) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':