Skip to content

Instantly share code, notes, and snippets.

@afiodorov
afiodorov / instruction
Last active October 28, 2023 11:51
Run your own LLM & create an api endpoint for predictions
Docker Image : pytorch/pytorch
Image Runtype : jupyter_direc ssh_direc ssh_proxy
Environment : [["JUPYTER_DIR", "/"], ["-p 41654:41654", "1"]]
pip install torch bitsandbytes sentencepiece "protobuf<=3.20.2" git+https://github.com/huggingface/transformers flask python-dotenv Flask-HTTPAuth accelerate
!mv /opt/conda/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda116.so /opt/conda/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so
-- BASIC EASING FUNCIONS CHEAT CHEET
-- (most of them are based on glide by Jacob Albano https://github.com/jacobalbano/glide)
function ease_linear(t)
return t
end
function ease_cube_in(t)
return t * t * t
end
@YukiSnowy
YukiSnowy / main.cpp
Last active March 20, 2024 19:10
example SDL2 Vulkan application
// g++ *.cpp -o vulkan -lSDL2main -lSDL2 -lvulkan-1
// https://vulkan-tutorial.com/
#include <iostream>
using namespace std;
#include <SDL2/SDL.h>
SDL_Window *window;
char* window_name = "example SDL2 Vulkan application";
@SemanticDevice
SemanticDevice / allegro5_basic_game_loop.c
Created October 28, 2019 08:43
Basic game loops in Raylib, SDL2 and Allegro5
#include <allegro5/allegro5.h>
#include <allegro5/allegro_primitives.h>
#include <stdio.h>
#include <stdlib.h>
#define WIN_WIDTH_PX (800)
#define WIN_HEIGHT_PX (800)
#define FPS (60.0f)
static void Initialize();
#include <stdio.h>
#include <stdlib.h>
const int H = 40;
const int W = 80;
char map[H][W];
int rnd(int max) {
return rand() % max;
@munificent
munificent / generate.c
Last active May 14, 2024 05:30
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@sherjilozair
sherjilozair / sdl-sokol-sprite.c
Created June 9, 2018 14:05
Minimal sprite rendering example with SDL2 for windowing, sokol_gfx for graphics API using OpenGL 3.3 on MacOS
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
#define SOKOL_IMPL
#define SOKOL_GLCORE33
#include <sokol_gfx.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define CODE(...) #__VA_ARGS__
@tommyettinger
tommyettinger / mulberry32.c
Last active June 8, 2024 09:35
Mulberry32 PRNG
/* Written in 2017 by Tommy Ettinger (tommy.ettinger@gmail.com)
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>. */
#include <stdint.h>
@RickCarlino
RickCarlino / 00_forth.js
Last active February 23, 2022 00:25
Web Assembly Forth VM
var wasmCode = new Uint8Array([0,97,115,109,1,0,0,0,1,177,128,128,128,0,9,96,0,0,96,1,127,1,127,96,0,1,127,96,1,127,0,96,2,127,127,0,96,2,127,127,1,127,96,5,127,127,127,127,127,0,96,3,127,127,127,0,96,4,127,127,127,127,0,2,157,128,128,128,0,2,3,101,110,118,7,103,101,116,99,104,97,114,0,2,3,101,110,118,7,112,117,116,99,104,97,114,0,1,3,224,128,128,128,0,95,3,2,2,2,3,2,2,3,2,3,2,3,1,4,2,1,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,8,2,0,4,133,128,128,128,0,1,112,1,72,72,5,131,128,128,128,0,1,0,2,6,129,128,128,128,0,0,7,216,134,128,128,0,95,6,109,101,109,111,114,121,2,0,6,112,117,116,107,101,121,0,2,5,108,108,107,101,121,0,3,10,107,101,121,87,97,105,116,105,110,103,0,4,6,103,101,116,107,101,121,0,5,4,116,101,108,108,0,6,3,112,111,112,0,7,3,116,111,115,0,8,4,112,117,115,104,0,9,4,100,112,111,112,0,10,5,100,112,117,115,104,0,11,4,114,112,111,112,0,12,5,114,112,117,115,104,0,13,7,114,101,97,100,77,101,109,0
@baines
baines / freetype-atlas.c
Created July 15, 2016 13:32
minimal freetype texture atlas example
#include <stdio.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#define NUM_GLYPHS 128
struct glyph_info {
int x0, y0, x1, y1; // coords of glyph in the texture atlas