Skip to content

Instantly share code, notes, and snippets.

static value random_int( value o, value max ) {
if (!val_is_int(max)) {fprintf(stderr,"std_random max is no int\n");}
else {fprintf(stderr,"std_random max is in fact an int\n");}
if (!val_is_int(o)) {fprintf(stderr,"std_random o is no int\n");}
else {fprintf(stderr,"std_random o is in fact an int\n");}
val_check_kind(o,k_random);
val_check(max,int);
if( val_int(max) <= 0 )
return alloc_int(0);
return alloc_int( (rnd_int(val_rnd(o)) & 0x3FFFFFFF) % val_int(max) );
@Asmageddon
Asmageddon / gist:a76d7938da3c0564631b
Last active July 4, 2016 20:59
Sandbox for markdown experimentation

Header

Hello

print("hello")
a = a + b

Sub-header

  • Hello
rawrequire = require
function require(path)
if string.sub(path, 1,1) == "." then
local root = (debug.getinfo(2, 'S')).source:sub(2);
root = root:gsub("/[^/]*$", ""):gsub("/", ".")
return rawrequire(root .. path)
else
return rawrequire(path)
end
end
@Asmageddon
Asmageddon / scopecolor.lua
Created September 7, 2016 19:59
A buggy scope highlighter for ZeroBrane Studio
local golden_ratio = (1+math.sqrt(5))/2
local offset = 0.05
local function HSVtoRGB(h, s, v)
if s == 0 then
return v,v,v
end
h = h/60
i = math.floor( h )
f = h - i
@Asmageddon
Asmageddon / anime-recs.md
Last active July 27, 2020 01:11
Anime worth checking out

Preface

Anyway, for a brief list in a very rough order of what I consider best, with stuff near the bottom of the list still being at the very least "Kinda decent".

I strongly apologize for not including links and some of the descriptions being vague, but that's halfway intentional(there are better synopses and reviews out there) and halfway because this already took damn ages.

I've marked every show with single-letter tags:

@Asmageddon
Asmageddon / gist:1204526
Created September 8, 2011 20:07
Two player snake game
import sys, os, pygame, random
from pygame.locals import *
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
screen_x = 512
screen_y = 512
tile_x = 24
tile_y = 24
@Asmageddon
Asmageddon / LonelinessMatters.md
Created July 8, 2021 12:09
Paper Digest: Loneliness Maters

Loneliness Matters: A Theoretical and Empirical Review of Consequences and Mechanisms https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3874845/ General info:

As a social species, humans rely on a safe, secure social surround to survive and thrive. Perceptions of social isolation, or loneliness, increase vigilance for threat and heighten feelings of vulnerability while also raising the desire to reconnect. Implicit hypervigilance for social threat alters psychological processes that influence physiological functioning, diminish sleep quality, and increase morbidity and mortality. [...] Loneliness is not simply being alone. Interventions to reduce loneliness and its health consequences may need to take into account its attentional, confirmatory, and memorial biases as well as its social and behavioral effects. [...] Loneliness is a common experience; as many as 80% of those under 18 years of age and 40% of adults over 65 years of age report being lonely at least sometimes [1–3], with levels of l

Overview

Diet modulates brain network stability, a biomarker for brain aging, in young adults https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7084077/

Large-scale life span neuroimaging datasets show functional communication between brain regions destabilizes with age, typically starting in the late 40s, and that destabilization correlates with poorer cognition and accelerates with insulin resistance. Targeted experiments show that this biomarker for brain aging is reliably modulated with consumption of different fuel sources: Glucose decreases, and ketones increase the stability of brain networks. This effect replicated across both changes to total diet as well as fuel-specific calorie-matched bolus, producing changes in overall brain activity that suggest that network “switching” may reflect the brain’s adaptive response to conserve energy under resource constraint.

[...] irrespective of whether ketosis was achieved with a ketogenic diet or exogenous ketone ester.

[...] suggesting

@Asmageddon
Asmageddon / SDB-Q25-EN.md
Last active November 10, 2021 09:52
Sleep Disordered Breathing Questionnaire (25 questions, EN, PL)

Summary

Sleep Disordered Breathing is a rarely-diagnosed spectrum of disorders caused by respiratory airflow resistance resulting from allergies/nasal obstruction and/or physically narrow airways due to insufficient jaw development, and less frequently other disorders(septum deviation, adenoid, tonsil, turbinate hypertrophy are usually consequences of insufficient space to develop properly or inflammation)

This causes increased respiratory effort during sleep(and frequently, partial or even full airway collapse) when airway muscles are relaxed, leading to abnormal Autonomous Nervous System modulation which results in destabilization of sleep processes, severely impaired rest quality, and dysregulation of numerous physical and mental functions.

Contrary to popular belief, Obstructive Sleep Apnea is not a standalone syndrome, but rather results from years or decades of damage caused by abnormal sleep, and primary symptoms in most people are psychological and somatic in nature.

This questionnaire is desig

@Asmageddon
Asmageddon / Copy.hx
Created November 4, 2012 20:15
Deep copy of anything for Haxe
package com.asmoprime.utils;
/**
* ...
* @author Asmageddon
*/
class Copy {
/**
* Deep copy of anything using reflection (so don't hope for much performance)
**/