Skip to content

Instantly share code, notes, and snippets.

children = if System.get_env("ANDROID_ROOT") do
[ TermuxSmsCli.Fetcher,
TermuxSmsCli.Thread
] else
[ TermuxSmsCli.UI
] end
** (exit) exited in: GenServer.call({TermuxSmsCli.Fetcher, :"[email protected]"}, :threads, 5000)
** (EXIT) an exception was raised:
** (FunctionClauseError) no function clause matching in TermuxSmsCli.Fetcher.handle_call/3
(termux_sms_cli) lib/termux_sms_cli/fetcher.ex:13: TermuxSmsCli.Fetcher.handle_call(:threads, {#PID<0.173.0>, #Reference<0.507083762.647495681.6201
1>}, nil)
(stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:690: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
(elixir) lib/gen_server.ex:989: GenServer.call/3
defmodule TermuxSmsCli.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# List all child processes to be supervised
children = if System.get_env("ANDROID_ROOT") do
def handle_call(:threads, _From, nil) do
TermuxSmsCli.Fetcher.fetch(TermuxSmsCli.Fetcher)
end
def threads(pid) do
GenServer.call(pid, :threads)
end
iex([email protected])1> TermuxSmsCli.Fetcher.fetch({TermuxSmsCli.Fetcher, :'[email protected]'}, 1);
[
%{
"body" => "You have up to 1GB of VIDEO EVERY DAY with your GIGA subscription. To check your balance and other exciting offers, dial *121# NOW! It's FREE and easy!",
"number" => "SMART",
"read" => true,
"received" => "2019-06-09 01:38",
"threadid" => 1,
"type" => "inbox"
}
iex([email protected])14> x = self(); Node.spawn_link(:"[email protected]", fn -> send x, TermuxSmsCli.Fetcher.start_link([]) end); {:ok, pid} = receive do x -> x end
{:ok, #PID<16052.226.0>}
iex([email protected])15> TermuxSmsCli.Fetcher.fetch(pid, 1)
[
%{
"body" => "You have up to 1GB of VIDEO EVERY DAY with your GIGA subscription. To check your balance and other exciting offers, dial *121# NOW! It's FREE and easy!",
"number" => "SMART",
"read" => true,
"received" => "2019-06-09 01:38",
"threadid" => 1,
nix-shell -p '(with import <nixpkgs> { overlays = [ (self: super: { beam = self.lib.recursiveUpdate super.beam { interpreters.erlang = self.beam.interpreters.erlangR21; interpreters.elixir = self.beam.packages.erlang.elixir; packages.erlang = super.beam.packages.erlangR21.extend (self: super: { elixir = super.elixir_1_8; }); }; } )]; }; [ elixir beamPackages.hex ] )'
defmodule TermuxSmsCli.Fetcher do
use GenServer
defp fetch_int(filter_fn, minimum) do
fetch_int(filter_fn, minimum, minimum)
end
defp fetch_int(filter_fn, minimum, count) do
{reply, 0} = System.cmd("ssh", ["myrl-phone-tether", "-p", "8022", "termux-sms-list", "-l", "#{count}"])
reply = Jason.decode!(reply)
[myrl@myrl:~]$ nix-build '<nixpkgs>' -A elixir.src --no-out-link
/nix/store/ffbdgaaq9sm3wq4mcpsbjjah78jbfala-source
[myrl@myrl:~]$ TERM=xterm-256color ssh [email protected] -p 8022
Welcome to Termux!
[ omitted ]
$ ./nix-in-termux/nix-in-termux bash
defmodule TermuxSmsCli.Fetcher do
use GenServer
defp fetch_int(filter_fn, minimum) do
fetch_int(filter_fn, minimum, minimum)
end
defp fetch_int(filter_fn, minimum, count) do
{reply, 0} = System.cmd("ssh", ["192.168.2.8", "-p", "8022", "termux-sms-list", "-l", "#{count}"])
reply = Jason.decode!(reply)