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 / 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:
@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 / 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 / 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 ๐˜ผ๐˜ฝ๐˜พ๐˜ฟ๐™€๐™๐™‚๐™ƒ๐™„๐™…๐™†๐™‡๐™ˆ๐™‰๐™Š๐™‹๐™Œ๐™๐™Ž๐™๐™๐™‘๐™“๐™”๐™•
(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();
}
});
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]
]);
@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\] "