Skip to content

Instantly share code, notes, and snippets.

@lantius
lantius / aoc2020.js
Last active January 5, 2021 22:36
AoC 2020
4.2
let a = s.split('\n\n');
let valid = 0;
let rng = (v, min, max) => { return parseInt(v, 10) >= min && parseInt(v, 10) <= max; }
let byr = (v) => /^\d{4}$/.exec(v) && rng(v, 1920, 2002);
let iyr = (v) => /^\d{4}$/.exec(v) && rng(v, 2010, 2020);
let eyr = (v) => /^\d{4}$/.exec(v) && rng(v, 2020, 2030);
let hgt = (v) => /^\d+(?:cm|in)$/.exec(v) && (v.includes('cm') ? rng(v, 150, 193) : rng(v, 59, 76));
let hcl = (v) => /^#[0-9a-f]{6}$/.exec(v);
let ecl = (v) => /^(?:amb|blu|brn|gry|grn|hzl|oth)$/.exec(v);

Keybase proof

I hereby claim:

  • I am lantius on github.
  • I am lantius (https://keybase.io/lantius) on keybase.
  • I have a public key whose fingerprint is 2DCC D971 2EB0 088E ABFC A631 CC35 F3DE ADF6 A461

To claim this, I am signing this object:

@lantius
lantius / gist:2573472
Created May 2, 2012 03:52 — forked from voscausa/gist:1397784
Google App engine Python 2.5 version of pankratiev / python-amazon-ses-api, using method override
#!/usr/bin/python
# -*- coding: utf-8 -*-
from ek_settings import AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY
from amazon_ses import AmazonSES, EmailMessage
from google.appengine.api import urlfetch
from google.appengine.runtime import DeadlineExceededError
import urllib, logging
#===============================================================================================================================
@lantius
lantius / imgrec.pl
Created January 30, 2012 08:13
perl script for recovering images from a CF card
#!/usr/bin/perl -w
print "Starting CompactFlash card recovery\n";
$argsLen = $#ARGV + 1;
if ($argsLen < 2) {
print "Error:\nIncorrect usage of file, please supply 2 arguments\n.";
print "./recover.pl \n";
print " - Path to the dumpfile \n";
print " - Destination for recovered files\n";
print "./recover.pl ~/dumpfile ~/recovered\n";
@lantius
lantius / blocks.js
Created December 20, 2011 02:47
Simple response to simple coding exercise.
// blocks class; targets a container and specifies a highlight color for the blocks when they are clicked.
// constructor arguments 'args' is a JSON object:
// {
// container: "#container", //Container element content blocks should be added to
// clickColor: "#ff9" //Color to be applied to a block after clicking it
// }
function blocks(args) {
this.container = args['container'];
this.clickColor = args['clickColor'];