Skip to content

Instantly share code, notes, and snippets.

View tonyc's full-sized avatar
💭
wondering why github decided to add a user status

Tony Collen tonyc

💭
wondering why github decided to add a user status
View GitHub Profile
defmodule App.Service do
@spec parse() :: {:ok, String.t()}, | {:error, String.t()}
def parse do
url = "https://example.com/foo.txt"
case HTTPoison.get(url) do
{:ok, %HTTPoison.response{status_code: 200, body: body}} ->
body # Note: Not {:ok, body}
_ ->
function lb() {
local_bundle_ver=$(grep -A1 "BUNDLED WITH" Gemfile.lock | grep -v BUNDLED | tr -d '[:space:]')
if [ -n "$local_bundle_ver" ]; then
echo "Using bundler ${local_bundle_ver}"
bundle _${local_bundle_ver}_ $*
else
echo "Could not determine correct version of bundler to use. Sorry!"
fi
}
function local_bundle() {
local_bundle_ver=$(grep -A1 "BUNDLED WITH" Gemfile.lock | grep -v BUNDLED | tr -d '[:space:]')
if [ -n "$local_bundle_ver" ]; then
echo "Using bundler ${local_bundle_ver}"
bundle _${local_bundle_ver}_ $*
else
echo "Could not determine correct version of bundler to use. Sorry!"
fi
}
___
/\__ _\/\ \ __ /\__ _\ /\ _ \
\/_/\ \/\ \ \___ /\_\ ____ \/_/\ \/ ____ \ \ \L\ \
\ \ \ \ \ _ `\/\ \ /',__\ \ \ \ /',__\ \ \ __ \
\ \ \ \ \ \ \ \ \ \/\__, `\ \_\ \__/\__, `\ \ \ \/\ \
\ \_\ \ \_\ \_\ \_\/\____/ /\_____\/\____/ \ \_\ \_\
\/_/ \/_/\/_/\/_/\/___/ \/_____/\/___/ \/_/\/_/
____ __
/'\_/`\ __ /\ _`\ /\ \
iex(30)> flush
{:circuits_uart, "ttyACM0", "BY 0,1"}
{:circuits_uart, "ttyACM0", "BY 0,0"}
:ok
iex(31)> flush
{:circuits_uart, "ttyACM0", "FQ 0,0146985000"}
{:circuits_uart, "ttyACM0", "FQ 0,0147030000"}
{:circuits_uart, "ttyACM0", "FQ 0,0147060000"}
{:circuits_uart, "ttyACM0", "FQ 0,0147120000"}
{:circuits_uart, "ttyACM0", "FQ 0,0147165000"}
iex(8)> flush
{:circuits_uart, "ttyACM0", "$GPRMC,,V,,,,,,,,,,N*53\r\n"}
{:circuits_uart, "ttyACM0", "$GPGGA,,,,,,0,,,,,,,,*66\r\n"}
{:circuits_uart, "ttyACM0", "$GPRMC,,V,,,,,,,,,,N*53\r\n"}
{:circuits_uart, "ttyACM0", "$GPGGA,,,,,,0,,,,,,,,*66\r\n"}
{:circuits_uart, "ttyACM0", "$GPRMC,,V,,,,,,,,,,N*53\r\n"}
{:circuits_uart, "ttyACM0", "$GPGGA,,,,,,0,,,,,,,,*66\r\n"}
{:circuits_uart, "ttyACM0", "$$CRC6CCE,W8SXT>API510,DSTAR*:"}
{:circuits_uart, "ttyACM0", "$GPRMC,,V,,,,,,,,,,N*53\r\n"}
{:circuits_uart, "ttyACM0", "$GPGGA,,,,,,0,,,,,,,,*66\r\n"}
iex(3)> Nerves.UART.enumerate()
%{
"ttyACM0" => %{
description: "TH-D74",
manufacturer: "JVC KENWOOD",
product_id: 24587,
vendor_id: 8550
},
"ttyS0" => %{}
}
#!/usr/bin/env bash
get_latest_sha () {
heroku releases --num 1 --remote $1 2> /dev/null | grep -v === | awk '{print $3}'
}
STAGING_SHA=$(get_latest_sha "staging")
PRODUCTION_SHA=$(get_latest_sha "production")
echo "Staging: $STAGING_SHA, Production: $PRODUCTION_SHA"
#!/usr/bin/env bash
set -e
BASE_DIR="${HOME}/Pictures/uploads"
BUCKET="your-s3-bucket-name"
FILENAME=$(uuidgen).png
FULL_PATH="${BASE_DIR}/${FILENAME}"
# This works
final_zip_codes =
zip_codes
|> Enum.map(& &1[:id])
|> Enum.sort()
# This also works