View lorenz_many_particles.nb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SetDirectory[NotebookDirectory[]]; | |
\[Sigma] = 10; | |
\[Rho] = 28; | |
\[Beta] = 8/3; | |
Tmax = 10; | |
eqn = { | |
x'[t] == \[Sigma] (-x[t] + y[t]), | |
y'[t] == \[Rho]* x[t] - y[t] - x[t]*z[t], |
View coherent_incoherent_light.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Electromagnetic simulation at varying timescales - simulation code to make this animation: | |
# https://twitter.com/bencbartlett/status/1369396941730312193 | |
# | |
# Animation idea was inspired by u/cenit997's (Twitter: @__cenit) Reddit post: | |
# https://www.reddit.com/r/Python/comments/hxmhai/a_simulation_of_how_an_incoherent_light_source/ | |
#--- | |
using LinearAlgebra, Base.Threads, BenchmarkTools, LoopVectorization, CSV, DataFrames, Printf, Plots |
View ring_computer_animation.nb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SetDirectory[NotebookDirectory[]]; | |
\[Theta]0 = -.1 \[Pi]; \[Phi]0 = .35*\[Pi]; | |
\[Psi]0 = {Cos[\[Theta]0] Cos[\[Phi]0], Sin[\[Theta]0] Cos[\[Phi]0], | |
Sin[\[Phi]0]}; | |
Clear[BlochSphereVector]; | |
BlochSphereVector[\[Psi]_, imSize_ : 1000, color_ : Gray, | |
opacity_ : 1, \[Phi]view_ : \[Pi]/4, viewdist_ : 100] := Module[{ | |
tubeball, pointline, |
View hydrogen_orbitals.nb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<< MaTeX` | |
SetOptions[MaTeX, "Preamble" -> {"\\usepackage{color,txfonts}"}]; | |
SetDirectory[NotebookDirectory[]]; | |
Clear[drawLadder]; | |
drawLadder[n_, l_, m_, imsize_: 500] := Module[{maxrungs = 5, mag = 4}, | |
Graphics[{ | |
White, Opacity[1], Thickness[.02], Dashing[None], | |
Table[Line[{{0, k}, {1, k}}], {k, maxrungs}], (*draw n lines*) | |
View pulse.nb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<< MaTeX` | |
SetOptions[MaTeX, "Preamble" -> {"\\usepackage{color,txfonts}"}]; | |
SetDirectory[NotebookDirectory[]]; | |
c = 1; | |
\[Alpha] = .7; | |
\[Beta] = .05; | |
k0 = 7; | |
\[Omega]0 = 2 c; | |
vg = c; |
View ClassStringify.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
constructor() { | |
this.bar = "baz"; | |
} | |
} | |
console.log('' + Foo); | |
// > "class Foo {\n constructor()...z\";\n }\n\n}" |
View GlobalCache.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class $ { // $ = cash = cache... get it? :D | |
static set<T extends HasRef, K extends keyof T>(thing: T, key: K, | |
callback: () => (T[K] & (undefined | HasID | HasID[])), | |
timeout = CACHE_TIMEOUT): void { | |
const cacheKey = thing.ref + '$' + key; | |
if (!_cache.things[cacheKey] || Game.time > _cache.expiration[cacheKey]) { | |
// Recache if new entry or entry is expired | |
_cache.things[cacheKey] = callback(); | |
_cache.expiration[cacheKey] = getCacheExpiration(timeout, Math.ceil(timeout / 10)); |
View Hatchery.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {$} from '../caching/GlobalCache'; | |
export class Hatchery extends HiveCluster { | |
// constructor gets run only on ticks with build() phase | |
constructor(colony: Colony, headSpawn: StructureSpawn) { | |
super(colony, headSpawn, 'hatchery'); | |
this.memory = Mem.wrap(this.colony.memory, 'hatchery', HatcheryMemoryDefaults, true); | |
// Register physical structure components | |
this.spawns = colony.spawns; |
View MarkovText.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
normalizeLengths = True # Set the length of the two input sources to be equal. | |
# Generate transition matrix | |
A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " | |
charnums = len(A) | |
# Read through text and index transition matrix | |
trainingText = " ".join(open("KingJamesBible.txt",'r').read().splitlines()) | |
trainingText2 = " ".join(open("GriffithsQuantumMechanics.txt",'r').read().splitlines()) |
View LayerPlot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importations | |
import os, shutil | |
import numpy as np | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import matplotlib.mlab as mlab | |
import pylab | |
import warnings | |
from mpl_toolkits.mplot3d import Axes3D, art3d | |
from matplotlib.offsetbox import TextArea, VPacker, AnnotationBbox |