Skip to content

Instantly share code, notes, and snippets.

View squeakyspacebar's full-sized avatar
🧠

Squeaky Spacebar squeakyspacebar

🧠
View GitHub Profile

Arsenic in Food

Arsenic

Notes

  • The broadest way to divide the forms of arsenic[al compounds] is into these two categories:
    • Inorganic (I-As)
      • Most toxic
      • Established links to cancer
        • The International Argency for Research on Cancer (IARC) Monographs program - which evaluates agents for carcinogenicity - has classified arsenic as an agent under group 1; per the FAQ definition of group 1, "[t]his category is used when there is sufficient evidence of carcinogenicity in humans. In other words, there is convincing evidence that the agent causes cancer in humans."
    • Organic (i.e. any compound containing carbon-carbon/carbon-hydrogen bonds)
@squeakyspacebar
squeakyspacebar / drop_index.sql
Created April 24, 2018 17:16
PL/pgSQL function for finding an index name (typically automatically generated) and dropping it.
CREATE OR REPLACE FUNCTION drop_index (
schema_name TEXT,
table_name TEXT,
column_name TEXT,
index_type TEXT
) RETURNS void AS $$
DECLARE index_name TEXT;
BEGIN
SELECT tc.constraint_name INTO index_name
FROM information_schema.table_constraints AS tc
@squeakyspacebar
squeakyspacebar / games_played.txt
Last active October 21, 2022 19:44
List of Video Games I've Played
1941: Counter Attack (Arcade)
3D Dinosaur Adventure
The 7th Guest
Aces of the Deep
Aero Fighters (Arcade/SNES)
Aladdin (SNES)
Alan Wake
Alien Swarm
Alone in the Dark
Alpha Protocol (PS3)
@squeakyspacebar
squeakyspacebar / polytopic_loop.cpp
Created September 16, 2017 05:39
A function designed to traverse a polytopic structure in a loop and execute arbitrary functionality inside.
/**
* Loop to traverse an n-dimensional polytopic structure.
*
* Note: Unfortunately, the stride is currently the step size across ALL
* dimensions. Per-dimension stride specification is currently unavailable.
*/
template<typename F>
inline void polytopic_loop(const std::vector<std::size_t> & shape,
F f,
std::size_t index = 0,
@squeakyspacebar
squeakyspacebar / pointinsidepolygon.cs
Created July 3, 2017 18:52
Check whether a point is inside a (convex) polygon.
// Determines whether a point is inside the polygon formed by the given vertices.
// Assumes the vertices form a convex polygon.
private bool PointInsidePolygon(Vector2f point, List<Vector2f> vertices) {
int n_vertices = vertices.Count;
int low = 0;
int high = n_vertices;
do {
int mid = (low + high) / 2;
@squeakyspacebar
squeakyspacebar / triangleisccw.cs
Created July 3, 2017 18:50
Triangle Is Counterclockwise
// Determines whether or not a set of three points is in counter-clockwise order.
private bool TriangleIsCCW(Vector2f a, Vector2f b, Vector2f c) {
float det = ((a.x - c.x) * (b.y - c.y)) - ((a.y - c.y) * (b.x - c.x));
if (det > 0) {
return true;
} else {
return false;
}
}
private void FillPolygon(Texture2D texture, List<Vector2f> vertices, Color color) {
// Set polygon bounding box.
int IMAGE_TOP = (int)vertices.Max(v => v.y);
int IMAGE_BOTTOM = (int)vertices.Min(v => v.y);
int IMAGE_RIGHT = (int)vertices.Max(v => v.x);
int IMAGE_LEFT = (int)vertices.Min(v => v.x);
int POLY_CORNERS = vertices.Count;
// Decompose vertex components into parallel lists for looping.
@squeakyspacebar
squeakyspacebar / bresenham.cs
Created July 3, 2017 18:43
Bresenham Line Drawing Algorithm
private void DrawLine(Vector2f p0, Vector2f p1, Texture2D tx, Color c, int offset = 0) {
int x0 = (int)p0.x;
int y0 = (int)p0.y;
int x1 = (int)p1.x;
int y1 = (int)p1.y;
int dx = Math.Abs(x1-x0);
int dy = Math.Abs(y1-y0);
int sx = x0 < x1 ? 1 : -1;
int sy = y0 < y1 ? 1 : -1;
@squeakyspacebar
squeakyspacebar / Custom Git Commands
Last active December 19, 2022 11:01
BASH script to implement custom git command functionality, such as automatically tracking all remotes after running git-clone. Add to your .bashrc, .bash_profile, or .zshrc for convenience.
git() {
local URL;
local REPO_DIR;
local ORIG_REF;
# Expects command in `git clone URL` format.
if [[ $1 == 'clone' ]]; then
URL=$2;
# Retrieves repo name from URL argument.
@squeakyspacebar
squeakyspacebar / fgetline.c
Created May 9, 2012 07:49
A rudimentary function to read a line of input of arbitrary length from a file. Written as a small exercise for relearning pointer basics.
void fgetline(FILE *pInputFile, char **pszString) {
int counter = 0;
// Initialize the character read buffer.
char *szReadBuffer = (char*)malloc(sizeof(char) * (counter + 1));
// Read character into the buffer from the file stream and check for
// terminating characters.
szReadBuffer[counter] = fgetc(pInputFile);