Skip to content

Instantly share code, notes, and snippets.

@Azeirah
Azeirah / createNonIntersectingPolygon.js
Last active December 30, 2023 03:40
Generate simple polygons
/**
* Calculates if a given point `point` lies above a given line `p1p2`
* THIS FUNCTION DOES NOT RETURN BOOLEANS. It has three different return values, above = 1, below = -1, on the line = 0.
* @param {[x, y]} point The point to test for
* @param {[x, y]} p1 The starting point of a line
* @param {[x, y]} p2 The ending point of a line
* @return {number} 1 = above, -1 = below, 0 = exactly on the line
*/
function pointAboveLine(point, p1, p2) {
// first, horizontally sort the points in the line
@Azeirah
Azeirah / setup-gitlab-for-magit-in-doom-emacs.md
Last active November 23, 2023 07:07
Setting up magit forge for gitlab in Doom Emacs

Magit forge for Gitlab in Doom Emacs

This guide assumes you're working on a Unix-like environment. I'm using Linux Mint (Ubuntu). It should work on Macs, and might on Windows.

These are the four steps you can use as a checklist, see the headings below for the details on each step.

  • Enable forge support
  • Create a Gitlab API key
  • Add your gitlab credentials to ~/.authinfo.gpg
  • Set-up forge in emacs
@Azeirah
Azeirah / listLocales.php
Created December 26, 2016 23:10
List supported locales
<?php
// this list is large, but might not be completely exhaustive.
// I retrieved it from this stackoverflow answer: http://stackoverflow.com/a/20818686/2302759
// and added zh_TW
$locales = ["af_NA", "af_ZA", "af", "ak_GH", "ak", "sq_AL", "sq", "am_ET", "am", "ar_DZ", "ar_BH", "ar_EG", "ar_IQ", "ar_JO", "ar_KW", "ar_LB", "ar_LY", "ar_MA", "ar_OM", "ar_QA", "ar_SA", "ar_SD", "ar_SY", "ar_TN", "ar_AE", "ar_YE", "ar", "hy_AM", "hy", "as_IN", "as", "asa_TZ", "asa", "az_Cyrl", "az_Cyrl_AZ", "az_Latn", "az_Latn_AZ", "az", "bm_ML", "bm", "eu_ES", "eu", "be_BY", "be", "bem_ZM", "bem", "bez_TZ", "bez", "bn_BD", "bn_IN", "bn", "bs_BA", "bs", "bg_BG", "bg", "my_MM", "my", "ca_ES", "ca", "tzm_Latn", "tzm_Latn_MA", "tzm", "chr_US", "chr", "cgg_UG", "cgg", "zh_Hans", "zh_Hans_CN", "zh_Hans_HK", "zh_Hans_MO", "zh_Hans_SG", "zh_Hant", "zh_Hant_HK", "zh_Hant_MO", "zh_Hant_TW", "zh", "kw_GB", "kw", "hr_HR", "hr", "cs_CZ", "cs", "da_DK", "da", "nl_BE", "nl_NL", "nl", "ebu_KE", "ebu", "en_AS", "en_AU", "en_BE", "en_BZ", "en_
@Azeirah
Azeirah / tea.js
Last active December 26, 2021 21:42
Tea bitterness calculator
/**
* tea_serving is a Natural number.
* 1 represents 1 teaspoon
* water_temperature is in degrees
* tea_type is of enum TEA_TYPE
* steeping time is in minutes
*/
function bitterness(tea_serving, water_temperature, tea_type, steeping_time) {
let tooHotBitternessMultiplier = 1;
let teaTypeGroundBitterness = 1;
@Azeirah
Azeirah / groovemarklet.js
Created December 24, 2013 01:27
JavaScript: groovemarklet
(function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader=
from Xlib.display import Display
from Xlib import X
from Xlib.ext import record
from Xlib.protocol import rq
import time
disp = None
keysym_map = {
32: "SPACE",
@Azeirah
Azeirah / Default (Linux).sublime-keymap
Last active December 17, 2017 18:50
The settings for my sublime text set-up
[
// Use paste and indent as default paste mechanism,
// this conserves your indentation and it's overall better.
// original paste is now ctrl+shift+v
{
"keys": ["ctrl+v"],
"command": "paste_and_indent"
}, {
"keys": ["ctrl+shift+v"],
"command": "paste"
<!DOCTYPE html>
<html>
<head>
<title>Text Editor</title>
<style>
body, document, html {
width: 100%;height: 100%;
}
div {
height: 60rem;
@Azeirah
Azeirah / confy.py
Created October 16, 2016 06:06
Confy, dictionary backed by a json file, use it for your configuration files.
"""Confy, a dictionary backed by a json file, serves as a replacement to ini/config files. Use like any other dict, call .save() to save.
Initialize it with a filename, the backing file will be created if it didn't previously exist,
otherwise, the contents of the file will be loaded into the dict.
save using confy.save(), loading happens automatically
"""
import json
import collections
function rateLimit(fn, rate) {
var queue = [];
var currentlyEmptyingQueue = false;
function emptyQueue() {
if (queue.length) {
currentlyEmptyingQueue = true;
window.setTimeout(function () {
queue.shift().call();
emptyQueue();