Skip to content

Instantly share code, notes, and snippets.

View orbingol's full-sized avatar

Onur R. Bingol orbingol

View GitHub Profile
@orbingol
orbingol / dynamic_attributes.py
Last active December 11, 2023 12:30
Creating dynamic attributes in Python via overriding "__getattr__" and "__setattr__" magic methods
# Illustrates creating dynamic attributes in Python
#
# For implementation details of the dynamic attributes, please see the following methods:
# - GPSPosition.__getattr__
# - GPSPosition.__setattr__
#
class GPSPosition(object):
__slots__ = ('_coords', '_attribs', '_iter_index')
@orbingol
orbingol / copy_deepcopy.py
Last active April 27, 2022 21:50
Python copy & deepcopy with dicts and slots
import copy
from itertools import chain
class CopyTestClass(object):
def __init__(self, q, w):
self._a = q
self._b = w
self._cache = {}
@orbingol
orbingol / generate_knot_vector.py
Created April 20, 2018 21:49
Generates a uniform knot vector for NURBS evaluations
import numpy as np
def generate_knot_vector(degree, num_ctrlpts, **kwargs):
""" Generates a uniform knot vector.
Example
-------
>>> generate_knot_vector(3, 7, datatype=np.float32)
array([0. , 0. , 0. , 0. , 0.25, 0.5 , 0.75, 1. , 1. , 1. , 1. ], dtype=float32)
@orbingol
orbingol / NURBS-Python - Bezier Surface.ipynb
Last active August 9, 2022 10:10
Creating a Bezier surface patch using NURBS-Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbingol
orbingol / sm-annotated.html
Created March 22, 2018 00:43 — forked from hdragomir/sm-annotated.html
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@orbingol
orbingol / glinterop.py
Created March 22, 2018 00:22 — forked from sklam/glinterop.py
Numba, PyCUDA, OpenGL interop. Adapted from https://wiki.tiker.net/PyCuda/Examples/GlInterop
# GL interoperability example, by Peter Berrington.
# Draws a rotating teapot, using cuda to invert the RGB value
# each frame
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL.ARB.vertex_buffer_object import *
from OpenGL.GL.ARB.pixel_buffer_object import *