Skip to content

Instantly share code, notes, and snippets.

View EJTH's full-sized avatar

Elias J. T. Hansen EJTH

  • Copenhagen, Denmark
View GitHub Profile
@EJTH
EJTH / .bashrc
Last active October 17, 2019 18:41
# Śhow git branch in prompt.
gb() {
echo -n '(' && git branch 2>/dev/null | grep '^*' | colrm 1 2 | tr -d '\n' && echo -n ')'
}
git_branch() {
gb | sed 's/()//'
}
#dir(branch)$
PS1="\[\e[01;36m\]\w\[\e[33m\]\$(git_branch)\[\e[01;32m\]\\$\[\e[m\] "
const buzzwords = /Bitcoin|Litecoin|uheld|politi|breaking/gi
aggregator([
['https://news.ycombinator.com/','.itemlist .storylink',buzzwords,3],
['https://www.reddit.com/r/Denmark/new/','.thing',buzzwords,5],
['http://www.uriasposten.net','.blogitemtitle',buzzwords,3],
['http://tv2.dk','.o-teaser',buzzwords,3],
['https://www.bt.dk/','.teaser',buzzwords,3],
['https://www.dr.dk/','.dredition-item-inner',buzzwords,3]
]);
(function(){
var input = [];
var konami = JSON.stringify(["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "KeyB", "KeyA"]);
document.addEventListener('keydown', function(e){
input.push(e.code);
if(JSON.stringify(input.slice(-10)) == konami){
konamiSecret();
}
});
@EJTH
EJTH / CoolType.js
Last active November 22, 2017 16:30
For making vaporwave UTF8 text.
// Fonts: Either a string containing s single letter "A" from the utf code space you want to use or a number for one of these code spaces:
// 0 𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐗𝐘𝐙
// 1 𝐴𝐵𝐶𝐷𝐸𝐹𝐺𝐻𝐼𝐽𝐾𝐿𝑀𝑁𝑂𝑃𝑄𝑅𝑆𝑇𝑈𝑉𝑋𝑌𝑍
// 2 𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑿𝒀𝒁
// 3 𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓧𝓨𝓩
// 4 𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖃𝖄𝖅
// 5 𝖠𝖡𝖢𝖣𝖤𝖥𝖦𝖧𝖨𝖩𝖪𝖫𝖬𝖭𝖮𝖯𝖰𝖱𝖲𝖳𝖴𝖵𝖷𝖸𝖹
// 6 𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗫𝗬𝗭
// 7 𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘟𝘠𝘡
// 8 𝘼𝘽𝘾𝘿𝙀𝙁𝙂𝙃𝙄𝙅𝙆𝙇𝙈𝙉𝙊𝙋𝙌𝙍𝙎𝙏𝙐𝙑𝙓𝙔𝙕
@EJTH
EJTH / gist:b1f7cc4d66f777eee160
Created November 8, 2014 17:22
PEG.JS - Danish number literal parser
start
= tal_1000000_9999999
/ tal_1_999999
/ tal_0
tal_1_999
= tal_100_plus
/ tal_100_gange
/ tal_1_99
@EJTH
EJTH / emoji.json
Created September 16, 2014 08:01
Easy emoji search CLI tool for OSX
[
{
"emoji": "😄"
, "description": "smiling face with open mouth and smiling eyes"
, "aliases": [
"smile"
]
, "tags": [
"happy"
, "joy"
@EJTH
EJTH / PHP date validator
Last active August 29, 2015 14:01
Simple and powerful function for date range validation in PHP using date() and eval() (So it is probably not 100% safe for user exposure, though input is sanitized somewhat). Syntax is simple and allows for every possible crazy date rules that might occour.
<?php
/**
* Validates a date to a specific rule. Rules has the following format:
* :[date-component]: ==|<|>|>=|<=|!= [number]
*
* So to validate if the date is the first of the month:
* :d: == 1
*
* And the first monday of the month: