Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Preston Marshall bbhoss

🎯
Focusing
View GitHub Profile
@bbhoss
bbhoss / fun.sql
Last active Jun 20, 2017
Using Google Natural Language API from PL/Python. Make sure to set up authentication and install the proper libraries to the PL/Python PYTHONPATH first.
View fun.sql
CREATE EXTENSION plpython3u;
CREATE TYPE GOOGSENTIMENTRESULT AS (
sentiment FLOAT,
magnitude FLOAT
);
CREATE OR REPLACE FUNCTION GOOGsentiment(txt TEXT)
RETURNS GOOGSENTIMENTRESULT
AS $$
# Imports the Google Cloud client library
from google.cloud import language
View minikube_test.sh
# bash <(curl -s https://gist.githubusercontent.com/bbhoss/b2af48ba6426568b51da25fc93c4896c/raw/15b978487149d5ea478fb1597e9a5771d70f024a/minikube_test.sh)
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
# ----------------------
# adding resolver for test domain
# ----------------------
[ -d /etc/resolver ] || sudo mkdir -v /etc/resolver
@bbhoss
bbhoss / awesome.txt
Created Jan 28, 2016
Nerves booting on an Intel Edison
View awesome.txt
******************************
PSH KERNEL VERSION: b0182b2b
WR: 20104000
******************************
SCU IPC: 0x800000d0 0xfffce92c
PSH miaHOB version: TNG.B0.VVBD.0000000c
microkernel built 11:24:08 Feb 5 2015
View ssh_error.txt
11:55:08.809 [error] GenServer #PID<0.83.0> terminating
** (ArgumentError) argument error
:erlang.iolist_size([27, 91, 51, 54, 109, 27, 91, 49, 109, 9475, 32, 104, 32, 69, 110, 117, 109, 13, 10, 9475, 32, 104, 32, 69, 110, 117, 109, 46, 109, 97, 112, 13, 10, 9475, 32, 104, 32, 69, 110, 117, 109, 46, 114, 101, 118, 101, 114, 115, 101, 47, ...])
(ssh) ssh_cli.erl:434: :ssh_cli.write_chars/3
(ssh) ssh_cli.erl:193: :ssh_cli.handle_msg/2
(ssh) ssh_channel.erl:266: :ssh_channel.handle_info/2
(stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:681: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {#PID<0.84.0>, {:put_chars_sync, :unicode, "\e[36m\e[1m┃ h Enum\n┃ h Enum.map\n┃ h Enum.reverse/1\e[0m\n", {{#PID<0.87.0>, #Reference<0.0.8.169>}, :ok}}}
View foo.ex
defmodule TicketBuyer do
use GenServer
@ticket_sites [:ticketscalper, :feemaster, :concertoverhead]
def start_link do
GenServer.start_link __MODULE__, []
end
def init(_args) do
{:ok, %{}}
View server.ex
defmodule MyServer do
use GenServer
def init(_args) do
:gproc.reg({:p, :l, :my_little_server})
{:ok, []}
end
def handle_info(msg, state) do
IO.inspect "Got #{inspect msg} in process #{inspect self()}"
{:noreply, state}
View erl_list.S
{module, erl_list}. %% version = 0
{exports, [{hello_pipe,1},{hello_pp,1},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 9}.
{function, hello_pp, 1, 2}.
View erl_list.erl
-module(erl_list).
-export([hello_pp/0]).
-export([hello_pipe/0]).
hello_pp() ->
List1 = [1,2,3,4,5],
List2 = [1,2,3,4,5],
List1 ++ List2.
hello_pipe() ->
View erl_list.S
{module, erl_list}. %% version = 0
{exports, [{hello_pipe,0},{hello_pp,0},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 9}.
{function, hello_pp, 0, 2}.
View basic_bench.exs
defmodule BasicBench do
use Benchfella
@list Enum.to_list(1..1000)
before_each_bench _ do
{:ok, Enum.to_list(1..5000)}
end
bench "prepend with ++" do