Skip to content

Instantly share code, notes, and snippets.

@cortical-iv
cortical-iv / annotated_calculator.cpp
Last active January 26, 2024 14:29
Way too annotated version of Stroustrup's calculator from Chapter 6 of Stroustrup's Principles and Practice book.
//Working version of calculator from Chapter 6 of stroustrup
//Contains way too many print statements so you can track what is going on.
//Each grammatical rule, and main, is annotated with attempt to explain what is happening.
//Note I prefer to use '#' instead of '8' to represent numbers because I'm not a monster (see: Stroop effect).
#include "std_lib_facilities.h"
//------------------------------------------------------------------------------
class Token {
@cortical-iv
cortical-iv / destiny2_api_intro.py
Last active March 17, 2023 03:55
Highly annotated introduction to the destiny2 api (Python)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Getting Started using the Destiny 2 Api
An annotated guide to some of the public endpoints available for examining a user's
characters, items, and clan using the Destiny 2 API. You will need to use your api key for
this to work. Just insert it as a string where it says <my_api_key> in the beginning.
It is broken into four parts:
0: Imports, variables, and fixed parameters defined
@cortical-iv
cortical-iv / bobp-python.md
Last active May 16, 2022 08:38 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@cortical-iv
cortical-iv / keyboard_toggle_working.py
Created February 19, 2020 23:16
keyboard toggle of complex stim...working!
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from panda3d.core import WindowProperties, ColorBlendAttrib, TransformState
from direct.showbase import ShowBaseGlobal
def sin_byte(X, freq = 1):
"""
Creates unsigned 8 bit representation of sin (T_unsigned_Byte).
"""
@cortical-iv
cortical-iv / keyboard_toggle.py
Last active February 19, 2020 20:36
dual card acting funny
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from panda3d.core import WindowProperties, ColorBlendAttrib, TransformState
from direct.showbase import ShowBaseGlobal
def sin_byte(X, freq = 1):
"""
Creates unsigned 8 bit representation of sin (T_unsigned_Byte).
"""
@cortical-iv
cortical-iv / keyboard_texture_toggle.py
Created February 10, 2020 01:27
correct keyboard toggle of textures
# fixed using rdb suggestion
import sys
import numpy as np
from direct.showbase.ShowBase import ShowBase
from direct.showbase import ShowBaseGlobal #global vars defined by p3d
from panda3d.core import Texture, CardMaker, TextureStage, KeyboardButton
from panda3d.core import WindowProperties
from direct.task import Task
@cortical-iv
cortical-iv / superimposed_textures.py
Created February 10, 2020 00:54
two textures superimposing rather than showing in series with 0/1 key press
import sys
import numpy as np
from direct.showbase.ShowBase import ShowBase
from direct.showbase import ShowBaseGlobal #global vars defined by p3d
from panda3d.core import Texture, CardMaker, TextureStage, KeyboardButton
from panda3d.core import WindowProperties
from direct.task import Task
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from panda3d.core import WindowProperties
def rgb_texture(texture_size = 512, rgb = (0, 0, 0)):
x = np.linspace(-texture_size/2, texture_size/2, texture_size)
y = np.linspace(-texture_size/2, texture_size/2, texture_size)
X, Y = np.meshgrid(x, y)
@cortical-iv
cortical-iv / destiny_api_basics.py
Created August 7, 2017 06:01
Basics of using public api for exploring characters, bungie account, and clan.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Some simple examples of the public endpoints available for examining users,
characters, and clans using the Destiny API.
You will need to put in your own api key to run it. To learn how go to:
http://destinydevs.github.io/BungieNetPlatform/docs/API-Key
"""
import requests
@cortical-iv
cortical-iv / tex_cube_panda.py
Created July 17, 2019 20:56
Interpolation Matplotlib, nonmoving panda3d, and moving panda3d
"""
cube of concentric sinusoids: one shown in matplotlib, then in panda3d statically, then
in task manager in sequence when they turn dark.
"""
import numpy as np
import matplotlib.pyplot as plt
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from direct.task import Task
from direct.showbase import ShowBaseGlobal #global vars defined by p3d