Skip to content

Instantly share code, notes, and snippets.

@gubbu
gubbu / finding_primes.ipynb
Created January 19, 2022 17:08
Find Prime Numbers efficiently + RSA
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gubbu
gubbu / _G.d.ts
Last active January 17, 2022 19:52
typescript to minetest https://typescripttolua.github.io/
interface NodeDefinition{
description?: string,
// assign one texture OR assign one texture to each face of the cube.
tiles?: [string] | [string, string, string, string, string, string]
//TODO: add Node Box support https://dev.minetest.net/Node_Drawtypes
drawtype?: "normal"|"airlike"|"allfaces"|"allfaces_optional"|"glasslike"|"glasslike_framed"|"glasslike_framed_optional"|"liquid"|"flowingliquid"|"torchlike"|"signlike"|"plantlike"|"plantlike_rooted"|"raillike"|"fencelike"|"firelike"|"nodebox"|"mesh"
visual_scale?: number, //default is 1
drop?: string,
on_punch?: (this: void, pos: Position, node: Node, player: ObjectRef)=>void
//Returning true in on_timer will cause the timer to run again for the same interval
@gubbu
gubbu / Fibbonacci Spiral.ipynb
Created January 5, 2022 22:28
Fibbonacci Spiral
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gubbu
gubbu / integer_rasterization.ipynb
Created October 2, 2021 17:52
Rasterizing Lines with python.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gubbu
gubbu / survailance_camera.py
Created August 30, 2021 08:57
survailance camear python webcam, motion detection.
import imutils
import cv2
from time import sleep
from imutils import resize
from datetime import datetime
cv2.startWindowThread()
cap = cv2.VideoCapture(0)
avg = None
@gubbu
gubbu / main.rs
Created August 5, 2021 23:12
macroquad = "0.3.2" tictactoe
extern crate macroquad;
const FOREGROUND: macroquad::color::Color = macroquad::color::LIGHTGRAY;
const TEXTCOLOR: macroquad::color::Color = macroquad::color::RED;
const BACKGROUND: macroquad::color::Color = macroquad::color::DARKBLUE;
const TEXTFADEOUT_SECONDS: f64 = 1.5;
const TEXTSIZE: f32 = 30.0;
mod tictactoe {
// X = -1
@gubbu
gubbu / main.rs
Created August 5, 2021 23:08
macroquad = "0.3.2" snowsim
extern crate macroquad;
const WIDTH_HEIGHT: usize = 60;
const WIDTH_HEIGHT_FLOAT: f32 = WIDTH_HEIGHT as f32;
const SECONDS_PER_TICK: f64 = 0.15;
const FOREGROUND_COLOR: macroquad::color::Color = macroquad::color::WHITE;
const FOREGROUND_COLOR2: macroquad::color::Color = macroquad::color::LIGHTGRAY;
struct SnowFlakeSim {
snow_bars: [usize; WIDTH_HEIGHT],
@gubbu
gubbu / ExtrudeMeshInstanceFromImage.gd
Created July 3, 2021 06:52
godot: generate 3D (vertex colored) mesh from uncompressed image
tool
extends MeshInstance
export (Texture) var texture = null setget extrude_mesh_from_image
# a cube made out of 6 quads, a quad is made out of 2 triangles
const TRIANGLECUBE = [
{
@gubbu
gubbu / main.rs
Created May 5, 2021 00:41
rust image png encoding/decoding to/from url
extern crate base64;
extern crate image;
fn main() {
println!("hello world");
let testimage = image::RgbImage::from_fn(32, 32, |x, y| {
let sum = x / 4 + y / 4;
if sum % 2 == 0 {
return image::Rgb([0; 3]);
}
@gubbu
gubbu / workingmem.py
Created January 4, 2021 00:52
Python human memory working memory test graphical user interface.
import tkinter
import random
from threading import Thread
from time import sleep
sign_pool = "abcdefghijklmnopqrstuvwxyz0123456789".upper()
number_of_items = 5
pause_time_peritem_seconds = 1
reverse = True