This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Ubuntu 22.04 (Jammy Jellyfish) | |
# | |
# Basic packages i usually install. | |
# | |
# Author: Julius Beckmann <github@h4cc.de> | |
# | |
# Upgraded Script from 18.04: https://gist.github.com/h4cc/c54d3944cb555f32ffdf25a5fa1f2602 | |
# Upgraded Script from 17.04: https://gist.github.com/h4cc/09b7fe843bb737c8039ac62d831f244e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyBinaryParser do | |
# Parsing a 2 byte binary to float16 | |
# according to: https://en.wikipedia.org/wiki/Half-precision_floating-point_format | |
# Float16 is build in OTP 24. | |
def parse_float16(<<sign::1, exponent::5, significand::10>>) do | |
case {sign, exponent, significand} do | |
{0b0, 0b00000, 0b0000000000} -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyEcto do | |
# Helper to paginate a query | |
def paginate_query(%Ecto.Query{} = query, per_page, current_page, callback) when per_page > 0 and current_page >= 0 and is_function(callback) do | |
import Ecto.Query | |
offset = per_page * current_page | |
query | |
|> limit(^per_page) | |
|> offset(^offset) | |
|> LongRepo.all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Helper do | |
# Helper function for setting values deep in a map. | |
# Thanks @michalmuskala! | |
# https://elixirforum.com/t/put-update-deep-inside-nested-maps-and-auto-create-intermediate-keys/7993/8 | |
@doc """ | |
Will set value at for keys deep inside data. | |
iex> Helper.put_in_deep(%{a: %{}}, [:a, :b, :c], 42) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Ubuntu 18.04 (Bionic Beaver) | |
# | |
# Basic packages i usually install. | |
# | |
# Author: Julius Beckmann <github@h4cc.de> | |
# | |
# Upgraded Script from 17.04: https://gist.github.com/h4cc/09b7fe843bb737c8039ac62d831f244e | |
# Upgraded Script from 16.04: https://gist.github.com/h4cc/fe48ed9d85bfff3008704919062f5c9b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule InlineLookup do | |
# Examples how to handle a static lookup table in Elixir. | |
def example1(x) do | |
%{1 => "a", 2 => "b", 3 => "c"}[x] | |
# Could also be a attribute | |
# Should be the same as: | |
Map.get(%{1 => "a", 2 => "b", 3 => "c"}, x, nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AmbiPI:/ # cat /storage/hyperion-black-screen.sh | |
#!/bin/bash | |
if [ `service hyperion status | grep running | wc -l` = 1 ] | |
then | |
hyperion-remote -c black | |
sleep 3 | |
sudo service hyperion stop | |
else | |
sudo service hyperion start | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Updating a Ubuntu 14.04 LTS to 16.04 LTS | |
# by Julius Beckmann | |
# Prepare and Fix Locales. | |
apt-get update; apt-get install -y dialog language-pack-en-base language-pack-de-base; update-locale LANG=de_DE.UTF-8; dpkg-reconfigure locales; apt-get upgrade -y ; apt-get install -y update-manager-core | |
# Perform Dist Upgrade if presets ok | |
cat /etc/update-manager/release-upgrades | grep Prompt=lts && do-release-upgrade --check-dist-upgrade-only && do-release-upgrade -m server | |
# Answer questions, mostly with yes "y" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is our struct with some fields. | |
defmodule User do | |
defstruct name: "julius", role: :user | |
end | |
defmodule UserManager do | |
# Matching on %User{} will ensure we will get a user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://askubuntu.com/questions/912498/tl-wn722n-is-not-recognized | |
sudo apt-get install git dkms git make build-essential | |
cd /usr/src | |
sudo git clone https://github.com/lwfinger/rtl8188eu.git | |
sudo dkms add ./rtl8188eu | |
sudo dkms build 8188eu/1.0 | |
sudo dkms install 8188eu/1.0 | |
sudo modprobe 8188eu |
NewerOlder