Skip to content

Instantly share code, notes, and snippets.

View brianberlin's full-sized avatar
⚜️

Brian Berlin brianberlin

⚜️
View GitHub Profile
@brianberlin
brianberlin / main.lua
Created September 27, 2023 23:30
Love2D Snake
local position_x = 0
local position_y = 0
local positions = {}
local cookies = {}
local direction = "right"
local playing = true
local snake_length = 10
local score = 0
love.graphics.setPointSize(10)
--- Day 1: Sonar Sweep ---
You're minding your own business on a ship at sea when the overboard alarm goes off! You rush to see if you can help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying into the ocean!
Before you know it, you're inside a submarine the Elves keep ready for situations like this. It's covered in Christmas lights (because of course it is), and it even has an experimental antenna that should be able to track the keys if you can boost its signal strength high enough; there's a little meter that indicates the antenna's signal strength by displaying 0-50 stars.
Your instincts tell you that in order to save Christmas, you'll need to get all fifty stars by December 25th.
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
As the submarine drops below the surface of the ocean, it automatically performs a sonar
Considering every single measurement isn't as useful as you expected: there's just too much noise in the data.
Instead, consider sums of a three-measurement sliding window. Again considering the above example:
199 A
200 A B
208 A B C
210 B C D
200 E C D
207 E F D
@brianberlin
brianberlin / normalize.ex
Created June 28, 2021 13:17
Normalize user input with schemaless changesets
defmodule AppWeb.Normalize do
@moduledoc """
Normalize user input with schemaless changesets
Example usage:
```
input_schema = [
email: [:string, required: true],
password: [:string, required: true]
]
@brianberlin
brianberlin / freeway-drive.json
Last active September 9, 2021 19:38
Freeway Drive
[
[-122.03254703, 37.33527476],
[-122.03254838, 37.33525552],
[-122.03254863, 37.33523566],
[-122.03254905, 37.33521504],
[-122.0325498, 37.33519572],
[-122.03255055, 37.33517518],
[-122.03255349, 37.33515083],
[-122.03256229, 37.3351212],
[-122.0326037, 37.33507162],
/dts-v1/;
/plugin/;
/{
compatible = "brcm,bcm2708";
fragment@0 {
target = <&mmc>;
sdio_wifi: __overlay__ {
pinctrl-names = "default";
@brianberlin
brianberlin / filter.ex
Last active April 11, 2019 14:32
Ecto Filter
defmodule Filters do
import Ecto.{Query}, warn: false
defmacro __using__(_opts) do
quote do
defp apply_filters(original_query, params) do
filters = create_filters(params)
query =
try do
require('dotenv').config()
const AWS = require('aws-sdk')
const fs = require('fs')
const async = require('async')
const Bucket = process.env.AWS_BUCKET
const s3 = new AWS.S3({
accessKeyId: process.env.ACCESS_KEY_ID,
secretAccessKey: process.env.SECRET_ACCESS_KEY
})

Keybase proof

I hereby claim:

  • I am brianberlin on github.
  • I am berlin (https://keybase.io/berlin) on keybase.
  • I have a public key ASAaR_loCunlWpK3MEWi5-wCGJUfw6V1SOAwYnw2Z9lQ7Ao

To claim this, I am signing this object:

@brianberlin
brianberlin / Lets Encrypt
Last active July 5, 2016 13:34
Lets Encrypt
// Make sure pip is installed -> https://pip.pypa.io/en/stable/installing/
sudo yum install python27-devel python27-virtualenv gcc
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python27 /usr/bin/python
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo pip install virtualenv --upgrade
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
sudo /opt/letsencrypt/letsencrypt-auto certonly --standalone --debug