Skip to content

Instantly share code, notes, and snippets.

@AnishN
AnishN / game_ids.txt
Last active September 27, 2022 19:51
Chess.com Downloaded Game Ids
This file has been truncated, but you can view the full file.
10530406319
8445250721
10777752031
10947360209
8621136599
10269722397
9059274837
8707612555
10515523805
10514845237
@AnishN
AnishN / gist:00a61cb454e9800ca162f432b277c167
Created February 28, 2022 08:56
Radix vs Qsort Benchmark
Num Items,u8 radix,u8 qsort,i8 radix,i8 qsort,u16 radix,u16 qsort,i16 radix,i16 qsort,u32 radix,u32 qsort,i32 radix,i32 qsort,u64 radix,u64 qsort,i64 radix,i64 qsort,f32 radix,f32 qsort,f64 radix,f64 qsort,str radix, str qsort
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
256,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
512,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
cpdef float _cost(int[:] path, int length, float[:, :] time, float[:, :] cost):
cdef:
float final_cost = 0
float time_sum = 0
int count = 0
int i = 0
int p1, p2
int p0
p0 = path[0]
@AnishN
AnishN / puzzle.py
Created April 24, 2020 16:54
Bughouse Single Board Puzzle Basic Validation
import chess
from chess.variant import CrazyhouseBoard, CrazyhousePocket
def bug_single_board_move(fen, san_move):
board = CrazyhouseBoard()
board.set_fen(fen)
try:
move = board.parse_san(san_move)
is_capture = board.is_capture(move)
capture_piece_type = None
@AnishN
AnishN / texture.pyx
Created October 2, 2017 08:43
Hackish and SLOW implementation to pass an unsigned int [:, :, :] memoryview to glTexImage2D (OpenGL)
import contextlib
cdef class Texture:
def __cinit__(self, Image image):
self.image = image
glGenTextures(1, &self.id_)
self.unit = 0
def __dealloc__(self):
@AnishN
AnishN / chipmunk.pxd
Created October 1, 2017 17:07
Partial cython wrapper for Chipmunk 2D physics library (alternative to cymunk)
from libc.stdint cimport uintptr_t, uint32_t
#Basic/Core Chipmunk Types
cdef extern from "chipmunk/chipmunk.h":
ctypedef double cpFloat
ctypedef struct cpVect:
cpFloat x,y
cpVect cpv(cpFloat x, cpFloat y)
#Body
@AnishN
AnishN / message-test.html
Created December 19, 2016 06:43
Demo to time python -> javascript -> python calls in CEF
<head>
<style>
html *
{
font-family: Arial;
font-size: 12px;
}
</style>
</head>
@AnishN
AnishN / desktop.py
Created December 12, 2016 04:33
Custom Webpage Desktop using Python + Gtk3
import gi
gi.require_version('WebKit', '3.0')
from gi.repository import WebKit, Gtk, Gdk
import os, urllib
class App:
def __init__(self):
win = Gtk.Window()
screen = win.get_screen()
@AnishN
AnishN / pyopengl-cef-demo.py
Created December 11, 2016 20:58
PyOpenGL + CEF Python Demo: Play with the controls to change some properties about the spinning triangle in the background! The triangle rendering uses PyOpenGL, while the UI rendering and input use CEF Python.
from cefpython3 import cefpython as cef
import sys
import pygame
from PIL import Image
from OpenGL.GL import *
from OpenGL.GLU import *
import inspect
import math
class CEFSettings: