Skip to content

Instantly share code, notes, and snippets.

View ranjian0's full-sized avatar
🎯
Focusing

Ian Karanja ranjian0

🎯
Focusing
  • Nairobi, Kenya
  • 23:26 (UTC +03:00)
View GitHub Profile
@folz
folz / genetics.py
Created January 28, 2011 02:36
Genetic programming in python
#!/usr/bin/env python
from random import random, randint, choice
from copy import deepcopy
from math import log
TAB = " "
### classes ##
@myusuf3
myusuf3 / uninstall.sh
Created April 21, 2011 03:06
how to cleanly uninstall python packages installed with python setup.py
# Next time you need to install something with python setup.py -- which should be never but things happen.
python setup.py install --record files.txt
# This will cause all the installed files to be printed to that directory.
# Then when you want to uninstall it simply run; be careful with the 'sudo'
cat files.txt | xargs sudo rm -rf
anonymous
anonymous / download-git-by-http.sh
Created October 23, 2011 18:48
Download big git repositories over HTTP (using curl now, might want to replace with corresponding wget...)
#!/bin/bash
link=$1
to=$2
echo "Link $link"
echo "To $2"
function createdirs {
echo "createdirs Arg $1"
for dir in $(curl $link$1 | grep "href=" | sed 's/^.*href="//' | sed 's/">.*$//' | grep -v '/git' | grep -v '^\?' | grep '/$')
@MorganBorman
MorganBorman / main.py
Created December 9, 2012 04:33
A short example of how to use vertex array objects in PyOpenGL
import OpenGL.GL as GL
import OpenGL.GL.shaders
import ctypes
import pygame
import numpy
vertex_shader = """
#version 330
in vec4 position;
@gdementen
gdementen / mt.py
Last active May 29, 2021 14:13
Example of multithreading a numba function by releasing the GIL through ctypes
import ast
from timeit import repeat
import threading
from ctypes import pythonapi, c_void_p
import math
import numpy as np
try:
import numexpr as ne
nthreads = ne.ncores
@rossant
rossant / raytracing.py
Last active June 25, 2024 20:58
Very simple ray tracing engine in (almost) pure Python. Depends on NumPy and Matplotlib. Diffuse and specular lighting, simple shadows, reflections, no refraction. Purely sequential algorithm, slow execution.
"""
MIT License
Copyright (c) 2017 Cyrille Rossant
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 without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@Madsy
Madsy / gist:6980061
Last active June 1, 2024 08:57
Working multi-threading two-context OpenGL example with GLFW 3.0.3 and GLEW 1.8
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <vector>
#include <cmath>
#include <cstdio>
#include <limits>
#include <chrono>
#include <thread>
#include <mutex>
@koute
koute / opengl3_hello.c
Created November 9, 2013 23:16
Minimal SDL2 + OpenGL3 example.
/*
Minimal SDL2 + OpenGL3 example.
Author: https://github.com/koute
This file is in the public domain; you can do whatever you want with it.
In case the concept of public domain doesn't exist in your jurisdiction
you can also use this code under the terms of Creative Commons CC0 license,
either version 1.0 or (at your option) any later version; for details see:
http://creativecommons.org/publicdomain/zero/1.0/
@meylingtaing
meylingtaing / llist.c
Last active July 11, 2024 16:24
A generic linked list library for C
/* llist.c
* Generic Linked List implementation
*/
#include <stdlib.h>
#include <stdio.h>
#include "llist.h"
llist *llist_create(void *new_data)
{