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
@tonyc
tonyc / gist:1384523
Last active February 6, 2023 04:05
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

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
set -e
BASE_DIR="${HOME}/Pictures/uploads"
BUCKET="your-s3-bucket-name"
FILENAME=$(uuidgen).png
FULL_PATH="${BASE_DIR}/${FILENAME}"
#!/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"