Skip to content

Instantly share code, notes, and snippets.

View elbow-jason's full-sized avatar
🏠
Working from home

Jason Goldberger elbow-jason

🏠
Working from home
View GitHub Profile
@elbow-jason
elbow-jason / iex.exs
Created February 17, 2021 20:04
Nx - get and set by index for rank1 tensors
iex(1)> t1 = Nx.tensor([3, 4, 5])
#Nx.Tensor<
s64[3]
[3, 4, 5]
>
iex(2)> Rank1.at(t1, 0)
#Nx.Tensor<
s64
3
>
@elbow-jason
elbow-jason / running_it.txt
Created November 5, 2020 20:48
Why are `fox3` and `the2` null?
~/W/z/playground $ zig version
0.6.0+342ba960f
~/W/z/playground $ zig build-exe tfidf.zig
~/W/z/playground $ ./tfidf
word "the" initialized to count 1
after word "the" map count is 1
word "quick" initialized to count 1
after word "quick" map count is 2
@elbow-jason
elbow-jason / kill_it_with_fire.docker.sh
Created May 23, 2020 17:44
Remove Docker from OSX
#!/bin/bash
# Uninstall Script
if [ "${USER}" != "root" ]; then
echo "$0 must be run as root!"
exit 2
fi
while true; do
@elbow-jason
elbow-jason / readme_as_moduledoc.ex
Created April 24, 2020 16:13
SNIPPET: readme as moduledoc
defmodule Thing do
# get the full qualified path to the README.
@readme_path Path.join(__DIR__, "../README.md")
# ensure the module recompiles if the README changes
# NOTE: @external_resource requires a fully qualified path.
@external_resource @readme_path
# read the README into the moduledoc
@moduledoc File.read!(@readme_path)
end
@elbow-jason
elbow-jason / iex_session.ex
Created October 18, 2019 17:34
SparseCells
iex(1)> cells = SparseCells.build([cell_1: ["a", "b"], cell_2: [1, 2], cell_3: ["w", "x", "y", "z"]])
%SparseCells{
key_sizes: [cell_1: 2, cell_2: 2, cell_3: 4],
map: %{
{:cell_1, 0} => "a",
{:cell_1, 1} => "b",
{:cell_2, 0} => 1,
{:cell_2, 1} => 2,
{:cell_3, 0} => "w",
{:cell_3, 1} => "x",
@elbow-jason
elbow-jason / 000_what_is_nil.ex
Last active September 26, 2019 17:15
Bad, Better, Best - Loss of type information in Elixir
x = nil
# Q: What is x?
# Q: What type is it?
# Q: What does it represent?
alias Ecto.Changeset
defmodule Poly1 do
use Ecto.Schema
embedded_schema do
field(:key1, :string)
end
defmodule MultisortDecimalTest do
use ExUnit.Case
@data [
%{multiplier: Decimal.from_float(1.0), points: Decimal.from_float(400.0)},
%{multiplier: Decimal.from_float(1.0), points: Decimal.from_float(500.0)},
%{multiplier: Decimal.from_float(0.9), points: Decimal.from_float(600.0)},
%{multiplier: Decimal.from_float(0.9), points: Decimal.from_float(700.0)}
]
use std::thread;
use std::time as timing;
use time;
use std::fs;
use std::io;
use std::io::BufRead;
static DB_PATH: &str = "./file.db";
@elbow-jason
elbow-jason / redis_cheatsheet.bash
Created October 27, 2018 21:22 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.