Skip to content

Instantly share code, notes, and snippets.

View akey7's full-sized avatar

Alicia Key akey7

View GitHub Profile
@akey7
akey7 / theme_set.R
Created January 7, 2023 16:20
ggplot theme set
theme_set(theme_linedraw(base_size = 15))
@akey7
akey7 / qtrsf.py
Last active September 7, 2020 22:29
Qt Recursive Structure Form
import sys
from typing import Any
from PySide2.QtWidgets import ( # type: ignore
QVBoxLayout,
QLineEdit,
QPushButton,
QLabel,
QFormLayout,
@akey7
akey7 / rst.py
Last active September 7, 2020 20:43
Recursive Structure Traversal
from typing import Any
def rst(root: Any, key: str = "root") -> None:
if type(root) is dict and len(root.keys()) > 0:
for k, v in root.items():
rst(v, f"{key}['{k}']")
elif type(root) is dict and len(root.keys()) == 0:
print(">>> Skipping key with empty dictionary as value", key)
elif type(root) is list and len(root) > 0 and type(root[0]) is dict:
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 28 columns, instead of 24 in line 6.
AtomicNumber,Element,Symbol,AtomicMass,NumberofNeutrons,NumberofProtons,NumberofElectrons,Period,Group,Phase,Radioactive,Natural,Metal,Nonmetal,Metalloid,Type,AtomicRadius,Electronegativity,FirstIonization,Density,MeltingPoint,BoilingPoint,NumberOfIsotopes,Discoverer,Year,SpecificHeat,NumberofShells,NumberofValence
1,Hydrogen,H,1.007,0,1,1,1,1,gas,,yes,,yes,,Nonmetal,0.79,2.2,13.5984,8.99E-05,14.175,20.28,3,Cavendish,1766,14.304,1,1
2,Helium,He,4.002,2,2,2,1,18,gas,,yes,,yes,,Noble Gas,0.49,,24.5874,1.79E-04,,4.22,5,Janssen,1868,5.193,1,
3,Lithium,Li,6.941,4,3,3,2,1,solid,,yes,yes,,,Alkali Metal,2.1,0.98,5.3917,5.34E-01,453.85,1615,5,Arfvedson,1817,3.582,2,1
4,Beryllium,Be,9.012,5,4,4,2,2,solid,,yes,yes,,,Alkaline Earth Metal,1.4,1.57,9.3227,1.85E+00,1560.15,2742,6,Vaulquelin,1798,1.825,2,2
5,Boron,B,10.811,6,5,5,2,13,solid,,yes,,,yes,Metalloid,1.2,2.04,8.298,2.34E+00,2573.15,4200,6,Gay-Lussac,1808,1.026,2,3
6,Carbon,C,12.011,6,6,6,2,14,solid,,yes,,yes,,Nonmetal,0.91,2.55,11.2603,2.27E+00,3948.15,4300,7,Prehi
@akey7
akey7 / amplitude_modulator.py
Created June 28, 2020 20:28
Writes and amplitude modulated waveform to a .wave file.
# Import libraries
import numpy as np
from scipy.io.wavfile import write
# Properties of the wav
sps = 44100 # DON'T change
carrier_hz = 440.0
modulator_hz = 0.25
ac = 1.0
import numpy as np
from scipy.io.wavfile import write
import sounddevice as sd
import time
# Samples per second
sps = 44100
# Duration
duration_s = 5.0
@akey7
akey7 / sine_to_sounddevice.py
Created June 28, 2020 20:22
Plays a sine wave generated in NumPy to the sound device.
# Use the sounddevice module
# http://python-sounddevice.readthedocs.io/en/0.3.10/
import numpy as np
import sounddevice as sd
import time
# Samples per second
sps = 44100
@akey7
akey7 / numpy_sine_to_wav_file.py
Created June 28, 2020 20:20
This creates a sine wave in NumPy and writes it to a wave file.
import numpy as np
from scipy.io.wavfile import write
sps = 44100
freq_hz = 440.0
duration_s = 3.0
t_samples = np.arange(sps * duration_s)
waveform = np.sin(2 * np.pi * freq_hz * t_samples / sps)
waveform *= 0.3
@akey7
akey7 / modeling_with_data_tidyverse.R
Created June 20, 2020 22:03 — forked from rudeboybert/modeling_with_data_tidyverse.R
R source code for "Modeling with Data in the Tidyverse" DataCamp course
# R source code for all slides/videos in Albert Y. Kim's "Modeling with Data in
# the Tidyverse" DataCamp course:
# https://www.datacamp.com/courses/modeling-with-data-in-the-tidyverse
# This code is available at http://bit.ly/modeling_tidyverse
# Load all necessary packages -----
library(ggplot2)
library(dplyr)
library(moderndive)
@akey7
akey7 / fizz_buzz.R
Created May 15, 2020 02:21
Fizz Buzz in R
for (i in 1:20) {
if (i %% 3 == 0) print("Fizz")
else if (i %% 5 == 0) print("Buzz")
else print(i)
}