Skip to content

Instantly share code, notes, and snippets.

@jeregrine
jeregrine / Howto.md
Created May 12, 2015 19:37
Setting up Redo and Poolboy for redis connections in Elixir

Then add

worker(Redis, []),

to your supervision tree

@jeregrine
jeregrine / exwx.exs
Created October 13, 2023 22:20 — forked from rlipscombe/exwx.exs
Using wxWidgets from Elixir
#!/usr/bin/env elixir
defmodule Canvas do
@behaviour :wx_object
@title "Canvas Example"
@size {600, 600}
def start_link() do
:wx_object.start_link(__MODULE__, [], [])
@jeregrine
jeregrine / fakespot.js
Last active July 3, 2023 14:18
Fakespot Amazon Grease Monkey
// ==UserScript==
// @name FakeSpot Amazon
// @version 1
// @match https://*.amazon.com/gp/product/*
// ==/UserScript==
const url = "https://www.fakespot.com/analyze?url="+ encodeURIComponent(window.location)
window.addEventListener('load', () => {
let ratings = document.getElementById("averageCustomerReviews_feature_div");

Xmerl

Mix.install([
  {:tesla, "~> 1.7"},
  {:fast_xml, "~> 1.1"}
])

Data

@jeregrine
jeregrine / elixir_nsid.ex
Created May 3, 2023 20:33
Elixir NSID Parser and Validator
defmodule NSID do
@moduledoc """
Grammar:
alpha = "a" / "b" / "c" / "d" / "e" / "f" / "g" / "h" / "i" / "j" / "k" / "l" / "m" / "n" / "o" / "p" / "q" / "r" / "s" / "t" / "u" / "v" / "w" / "x" / "y" / "z" / "A" / "B" / "C" / "D" / "E" / "F" / "G" / "H" / "I" / "J" / "K" / "L" / "M" / "N" / "O" / "P" / "Q" / "R" / "S" / "T" / "U" / "V" / "W" / "X" / "Y" / "Z"
number = "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / "0"
delim = "."
segment = alpha *( alpha / number / "-" )
authority = segment *( delim segment )
name = segment
nsid = authority delim name

What is a Tensor

Mix.install([
  {:nx, "~> 0.5.3"}
])

Section

@jeregrine
jeregrine / canvas.livemd
Last active December 9, 2021 23:02
LiveBook Canvas Example. You will need to run this locally and apply a patch to make it possible.

Canvas Example

Setup

First clone livebook and apply the following diff (time of writing commit 973fc51c9d5cdcc8863016de0cf9127add0a90fb)

diff --git a/assets/js/app.js b/assets/js/app.js
@jeregrine
jeregrine / fixer.rb
Created October 18, 2012 15:55
Encoding::UndefinedConversionError - "\xC2" from ASCII-8BIT to UTF-8 Fix
lines = IO.readlines("app/views/terms.haml").map do |line|
line.encode('ASCII-8BIT', :invalid => :replace, :undef => :replace)
end
File.open("app/views/terms2.haml", "w") do |file|
file.puts(lines)
end
@jeregrine
jeregrine / hiring.md
Last active November 19, 2018 19:08
RokkinCat is Hiring

Date Posted: 11/19/2018

Full Time Web Developer

Description: Developer who is familar with front end web development technologies, including but not limited to:

  • JavaScript
  • HTML/CSS
  • Comfortable with at least one major modern JavaScript framework and comfortable moving frameworks as client needs change.

The ideal candidate is someone who is:

def index(conn, %{"event" => "true"}) do
conn = conn
|> put_resp_content_type("text/event-stream")
|> send_chunked(200)
{:ok, conn} = chunk(conn, ["data: ", JSON.encode!(Thermostat.Data.get()), "\n\n"])
Phoenix.Topic.subscribe self, "data"
data_updated(conn)
end
defp data_updated(conn) do