Skip to content

Instantly share code, notes, and snippets.

View amalbuquerque's full-sized avatar

André Albuquerque amalbuquerque

View GitHub Profile
@amalbuquerque
amalbuquerque / type_specs_cleaner.exs
Last active June 14, 2021 10:25
Elixir Type Specs Cleaner
# Elixir Type specs cleaner v1.0.1
#
# I wanted to understand the time cost of having type specs in practically all
# our modules of a large Elixir codebase since, by using remote structs on type
# specs instead of struct references that would become a compile time
# dependency, we already saw some time improvements.
#
# Good (using `Bar.t`): `@spec foo(String.t) :: Bar.t`
# Bad (using `%Bar{}`): `@spec foo(String.t) :: %Bar{}`
#
@amalbuquerque
amalbuquerque / cognito-developer-authenticated-client-example.py
Created July 18, 2020 22:51 — forked from dkarchmer/cognito-developer-authenticated-client-example.py
django-boto3-cognito: AWS' Cognito Developer Authenticated Identities Authflow using Django/Python/Boto3 (For building stand-alone clients)
__author__ = 'dkarchmer'
'''
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but
requires your Django server to have an API for your user to access Cognito based credentials
Because of Cognito, the client (this script) will only get temporary AWS credentials associated
to your user and only your user, and based on whatever you configure your AIM Policy to be.
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate
how to create a stand-alone Python script but operating similarly to these apps.
@amalbuquerque
amalbuquerque / cognito-developer-authenticated-client-example.py
Created July 18, 2020 22:51 — forked from dkarchmer/cognito-developer-authenticated-client-example.py
django-boto3-cognito: AWS' Cognito Developer Authenticated Identities Authflow using Django/Python/Boto3 (For building stand-alone clients)
__author__ = 'dkarchmer'
'''
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but
requires your Django server to have an API for your user to access Cognito based credentials
Because of Cognito, the client (this script) will only get temporary AWS credentials associated
to your user and only your user, and based on whatever you configure your AIM Policy to be.
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate
how to create a stand-alone Python script but operating similarly to these apps.
@amalbuquerque
amalbuquerque / manual_config.ex
Created March 2, 2020 22:54
Configuring an HID device by "manually" interacting with ConfigFS via /sys/kernel/config
defmodule ElixirKeeb.ManualConfig do
@moduledoc """
Manually create a Keyboard HID and writes to its device.
"""
@usb_gadget_root "/sys/kernel/config/usb_gadget"
def configure_device do
create_gadget_dir("mygadget")
@amalbuquerque
amalbuquerque / enable_nerves_network_disable_nerves_init_gadget.diff
Last active February 27, 2020 23:18
Configure :nerves_network, disable :nerves_init_gadget
diff --git a/config/custom_rpi0.exs b/config/custom_rpi0.exs
new file mode 100644
index 0000000..b551d92
--- /dev/null
+++ b/config/custom_rpi0.exs
@@ -0,0 +1,15 @@
+use Mix.Config
+
+config :nerves_network,
+ regulatory_domain: "EU"
@amalbuquerque
amalbuquerque / linux_config.diff
Created February 24, 2020 00:08
Buildroot Linux config updated after our linux-menuconfig changes
diff --git a/linux-4.19.defconfig b/linux-4.19.defconfig
index c508772..fcb9dfa 100644
--- a/linux-4.19.defconfig
+++ b/linux-4.19.defconfig
@@ -210,7 +210,8 @@ CONFIG_SND_SIMPLE_CARD=m
# CONFIG_HID_GENERIC is not set
CONFIG_USB_DWC2=m
CONFIG_USB_GADGET=y
-CONFIG_USB_CDC_COMPOSITE=y
+CONFIG_USB_CONFIGFS=m
diff --git a/mix.exs b/mix.exs
index f9be22c..0bac063 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,7 +1,7 @@
-defmodule NervesSystemRpi0.MixProject do
+defmodule MinefieldCustomNervesRpi0.MixProject do
use Mix.Project
- @app :nerves_system_rpi0
@amalbuquerque
amalbuquerque / nerves_hello_world.sh
Last active February 22, 2020 22:46
Nerves hello world!
~/projs/personal/minefield
❯ ssh nerves.local
Interactive Elixir (1.8.1) - press Ctrl+C to exit (type h() ENTER for help)
Toolshed imported. Run h(Toolshed) for more info
RingLogger is collecting log messages from Elixir and Linux. To see the messages, either attach the current IEx session to the logger:
RingLogger.attach
or print the next messages in the log:
@amalbuquerque
amalbuquerque / building_burning_nerves_firmware.sh
Created February 22, 2020 22:38
Building and burning the Nerves firmware
~/projs/personal/minefield
❯ mix firmware
Nerves environment
MIX_TARGET: rpi0
MIX_ENV: dev
==> socket
Compiling 11 files (.ex)
Generated socket app
@amalbuquerque
amalbuquerque / set_nerves_env_vars_mix_deps_get.sh
Created February 22, 2020 22:36
Setting Nerves env vars + mix deps.get
~/projs/personal/minefield
❯ export MIX_ENV=dev MIX_TARGET=rpi0
~/projs/personal/minefield
❯ mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
artificery 0.4.1
distillery 2.0.12