Skip to content

Instantly share code, notes, and snippets.

View SamyBencherif's full-sized avatar

Samie Bee SamyBencherif

View GitHub Profile
@SamyBencherif
SamyBencherif / prange.py
Created April 27, 2023 19:09
Practical range in Python
# unlike range, prange works automatically with reverse ranges, floats, and 0 steps
# prange(0,-10) --> 0, -1, -2, -3, -4, -5, -6, -7, -8, -9
# prange(1,2,.1) --> 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9
# prange(0,1,0) --> 0, 0, 0, ...
# prange(a,b,c) --> range(a,b,c) # when a,b,c are positive integers and a<b
# prange stands for practical range
def prange(start, stop=None, step=1):
if stop is None:
@SamyBencherif
SamyBencherif / fyiwd.html
Created May 3, 2022 18:43
smol prog for drawing--standalone html
<script>
ce=(t)=>document.createElement(t);
c=ce("canvas"); u=ce("canvas");
b=document.body=ce("body")
b.style.margin=0
p=(c)=>{
c.width = innerWidth; c.height = innerHeight;
c.style.width="100%"; c.style.height="100%";
c.style.position = "absolute"; c.style.top=0;
b.append(c)
" ";import os;_=0######
" ";import math; sin=0x0 or \
math.sin; cos=math.cos;######
" ";a=0; b=0;height=24; width=80;###
" ";clear=["clear","cls".strip()][(os).\
name!="posix"]; os.system(clear);s=sin
while 1: #####################################
z = [0 for DONUT in range(4*height*width)]####
screen = [' ' for O in range(height*width)]#####
j=0################## ##################
@SamyBencherif
SamyBencherif / kbcipher.py
Created May 23, 2020 00:29
Swipe around with your finger on the keyboard and use this program to display the result. (CLI stdio)
import readline
LAYOUT = """
` 1 2 3 4 5 6 7 8 9 0 - =
q w e r t y u i o p [ ] \\
a s d f g h j k l ; '
z x c v b n m , . /
"""[1:-1]
def h(c):
return ''.join([[' ', x][x==c or x=='\n'] for x in LAYOUT])
def U(s1, s2):
@SamyBencherif
SamyBencherif / ifsearch.py
Created May 22, 2020 07:52
Intuitive file search written in Python
import sys
import os
def usage():
print("""python ifsearch.py --list <path>
python ifsearch.py --dump <path>
python ifsearch.py --search <term> <path>""")
indention = 0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Camera))]
[ExecuteInEditMode]
public class RaymarchCamera : MonoBehaviour
{
[SerializeField]
public Shader _shader;
@SamyBencherif
SamyBencherif / rmpd.c
Created March 3, 2020 20:35
Pixelated 2d lighting with shadows in Raylib, software accelerated
/********************************************************************************************
@filename: rmpd.c
@title: Real Pixel Lighting RAMP DEMO
@description: Simple gradient demo of RPL with shadows
@author: Samy Bencherif
Copyright (C) 2020 Samy Bencherif (@deathstallion)
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
@SamyBencherif
SamyBencherif / README.md
Last active January 29, 2020 00:37
SCRIPT-8
@SamyBencherif
SamyBencherif / README.md
Last active January 25, 2020 18:47
SCRIPT-8
@SamyBencherif
SamyBencherif / README.md
Created January 24, 2020 21:09
SCRIPT-8