Skip to content

Instantly share code, notes, and snippets.

View AnastasiaDunbar's full-sized avatar
🈚
­

Anastasia Dunbar AnastasiaDunbar

🈚
­
View GitHub Profile
@AnastasiaDunbar
AnastasiaDunbar / Interval timer without setInterval().js
Last active November 26, 2018 13:02
A reference for looping timers.
function mod(a,b){return((a%b)+b)%b;}
class Timer{
constructor(callback,delay,tickBy=1,...parameters){
this.callback=callback;
this.duration=delay;
this.timer=delay;
this.tickBy=tickBy;
this.parameters=parameters;
}
tick(){
const LOWPASS=0,HIGHPASS=1,BANDPASS=2;
class Filter{
constructor(mode){
this.cutoff=.99;
this.resonance=0;
this.mode=mode;
this.b0=0;this.b1=0;this.b2=0;this.b3=0;
this.feedbackAmount=0;
this.cutoffMod=0;

Before enabling Developer Mode, archive your 'Downloads' folder, bookmarks, passwords, cache, add-ons, themes, apps, history, settings, custom words for spell check and etc. if you'd wish to keep your data.

Remember to disable Developer Mode before getting warranty support, this would also go through the same powerwash process.

Before setting up Linux (Beta), note that your Chromebook typically protects your computer by running each app in a “sandbox”. However, all Linux apps are run inside the same sandbox. This means a harmful Linux app can affect other Linux apps, but not the rest of your Chromebook. Permissions and files shared with Linux are available to all Linux apps. But speakers, microphones, cameras, USB devices/debuggers, Android Studio, emulators, hardware acceleration, GPU and video decoding aren't yet supported.

Steps to enable Developer Mode on your Chromebook:

  1. Press and hold Esc+Refresh+Power simultaneously.
  2. Press Ctrl+D when asked to insert recovery media.
  3. Press Enter on “To turn
@AnastasiaDunbar
AnastasiaDunbar / store(code); bookmarklet.js
Last active July 14, 2020 02:34
A bookmarklet to save current page's code/form, like a textarea cache (except it doesn't save automatically).
javascript:(()=>{
let magic="store(code);",hn=location.hostname,d=document,qS=(s,o=document)=>o.querySelector(s),
element,value,description=[new Date().getTime()];
if(/openprocessing\.org/.test(hn)){
element=codeMirror;
value=element.getValue();
}else if(/(wavepot|tinyrave)\.com/.test(hn)){
element=ace.edit("editor").getSession();
value=element.getValue();
}else if(/mytextarea\.com/.test(hn)){
//Note: JavaScript bitwise operators can only handle 32 bits, and 31st bit is used as a sign bit (use `x>>>0` to unsign it).
//Note: `1<<x` is sometimes used like an alternative to `2**x` (or `Math.pow(2,x)`) here.
//sign , (exponent bit)*eb , (mantissa bit)*mb.
function customFloatSize(eb,mb){return eb+mb+1;}
function maximumFloatNumber(eb,mb){let e=1<<(((1<<eb)-2)-1);return e+(e*(1-(1/(1<<mb))));}
function fromCustomFloat(x,eb,mb){
let sign=(x>>>(eb+mb))&1?-1:1,
maxExp=(1<<eb)-1,
expBits=(x>>>mb)&maxExp,
function clamp(x,minVal,maxVal){return Math.min(Math.max(x,minVal),maxVal);}
function pointInRect(px,py,x,y,w,h){return px>=x&&py>=y&&px<x+w&&py<y+h;}
function drawASCIItable(x,y,w,h,columns=8,fromChar=32,toChar=126){
stroke(255);noFill();
rect(x,y,w,h);
if(user.click){user.ASCIItableClicked=pointInRect(mouseX,mouseY,x,y,w,h);}
var charCount=(toChar-fromChar)+1;
for(var i=1;i<columns;i++){
line(x+(i/columns)*w,y,x+(i/columns)*w,y+h);
}
function multiplyMatrix(a,b){
var o=[];
for(var i=0;i<a.length;i++){
o[i]=[];
for(var j=0;j<b[0].length;j++){
var s=0;
for(var k=0;k<a.length;k++){s+=a[i][k]*b[k][j];}
o[i][j]=s;
}
}
@AnastasiaDunbar
AnastasiaDunbar / Add grid markers.edscript
Last active October 12, 2022 01:18
A script to add a grid of markers/regions to selection in Edison or Slicex (FL Studio).
script "Add grid markers" language "javascript";
var options=[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,24,32,64,100,128,256];
function div(a,b){var temp1=0,temp2=0;temp1=a;temp2=b;return temp1/temp2;} //Since I can't convert int to float.
function addMarkers(index,asRegions,addEnd){
var start=0,end=0,count=options[index];
Editor.GetSelectionS(start,end);
if(asRegions){
for(var i=0;i<count-1;i++){
EditorSample.AddRegion(IntToStr(i),start+Round(div((end-start)*i,count)),start+Round(div((end-start)*(i+1),count))-1);
@AnastasiaDunbar
AnastasiaDunbar / furigana syntax to HTML ruby markup.js
Created October 16, 2022 02:24
`[kanji]{kana}` furigana syntax to HTML <ruby> markup, would've been nice as a Markdown extension.
(string=>{
string=string.replace(/(\[[^\]]+\]{[^{]+})+/g,x=>"<ruby>"+x+"</ruby>");
var multiReplace=(s,o)=>{
for(var key in o){ //What if there were collisions (replacing what's already been replaced)?
s=s.replace(key,o[key]);
}
return s;
},matches=[...string.matchAll(/\[[^\]]+\]{[^{]+}/g)],iShift=0;
for(var i=0;i<matches.length;i++){
var index=matches[i].index,length=matches[i][0].length,
//JavaScript uses 32-bits bitwise operands on 64-bits floating-point numbers.
function readBitsLE(bytes,at,size){
let b=Math.floor(at/8),shift=Math.floor(at)%8,
mask=size>=32?4294967295:(1<<size)-1;
return((
(bytes[b]|bytes[b+1]<<8|bytes[b+2]<<16|bytes[b+3]<<24)>>>shift|
Math.floor(bytes[b+4])*Math.pow(2,32-shift)
)&mask)>>>0;
}
function writeBitsLE(bytes,at,size,value){