Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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();
@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 / Instructions.md
Created March 25, 2016 17:27
Sublime Text - Automatic reindentation while swapping

Sublime Text has a somewhat hidden feature to automatically reindent the current line. It would be wasteful to bind this to a keybinding, I prefer it to be automatic.

print("Executing a function")
def someFunction():
    return 5

Moving the print line one line down with ctrl+shift+down will result in

@Azeirah
Azeirah / keybase.md
Created August 26, 2015 22:29
keybase.md

Keybase proof

I hereby claim:

  • I am azeirah on github.
  • I am azeirah (https://keybase.io/azeirah) on keybase.
  • I have a public key whose fingerprint is C6CC 3CFF 9C23 0D36 124F 26C2 B4D2 59A9 2CA3 1AE3

To claim this, I am signing this object:

@Azeirah
Azeirah / meteorhelper.js
Created September 20, 2014 12:15
meteor helper
Template.previewNote.rerender = function () {
console.log(UI._templateInstance());
var codes = UI._templateInstance().findAll("pre>code");
for (var i = 0; i < codes.length; i++) {
hljs.highlightBlock(codes[i]);
}
};
@Azeirah
Azeirah / g.js
Created August 30, 2014 14:47
adding to profile
Template.register.events({
'submit #register-form': function(event, t) {
event.preventDefault();
var email = t.find('#register-email').value.toLowerCase();
var password = t.find('#register-password').value;
var username = t.find('#register-username').value;
Accounts.createUser({
email: email,
password: password,
username: username,