Skip to content

Instantly share code, notes, and snippets.

View posilva's full-sized avatar
💭
I may be slow to respond.

Pedro Marques da Silva posilva

💭
I may be slow to respond.
View GitHub Profile
@posilva
posilva / erlang-elixir-on-amazon-linux.md
Created May 29, 2023 20:23 — forked from techgaun/erlang-elixir-on-amazon-linux.md
Running elixir 1.8.1 on amazon linux

Script

#!/bin/bash

yum install ncurses-devel openssl-devel -y
yum groupinstall "Development Tools" -y

cd /tmp
wget "http://erlang.org/download/otp_src_21.3.tar.gz" -O otp21.tar.gz
@posilva
posilva / .gitignore
Created March 22, 2021 14:46 — forked from BennettSmith/.gitignore
Google Protobuf v2.6.0 Build Script for iOS
protobuf
protobuf-2.6.0
protobuf-2.6.1
protobuf-master
@posilva
posilva / my_app.ex
Created March 7, 2021 22:03 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@posilva
posilva / server.py
Created March 5, 2021 15:46 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@posilva
posilva / inet_utils.erl
Created August 14, 2019 21:24 — forked from marcelog/inet_utils.erl
inet_aton, inet_ntoa, ip_between functions for erlang. Convert an ip address address to/from its uint32 and text representations, check if the give ip address falls in a specific network range
-module(inet_utils).
-export([inet_aton/1, inet_ntoa/1]).
-export([ip_between/3]).
%% @doc Converts a binary string with a human readable ip
%% address representation into an uint32.
-spec inet_aton(binary()) -> pos_integer().
inet_aton(Ip) ->
[O1Bin, O2Bin, O3Bin, O4Bin] = binary:split(Ip, <<".">>, [global]),
@posilva
posilva / email.erl
Created January 11, 2019 14:12 — forked from seriyps/email.erl
Send emails using Erlang gen_smtp shortcut.
% Send plaintext email using gen_smtp https://github.com/Vagabond/gen_smtp
% This function sends email directly to receiver's SMTP server and don't use MTA relays.
%
% Example plaintext email:
% Mail = mail_plain(<<"Bob <sender@example.com>">>, <<"Alice <receiver@example.com>">>, <<"The mail subject">>, <<"The mail body">>),
% send_email(Mail).
%
% Example email with image attachment:
% ImgName = "image.jpg",
% {ok, ImgBin} = file:read_file(ImgName),
@posilva
posilva / context.ex
Created March 31, 2018 23:07 — forked from ericstumper/context.ex
Guardian Authentication with Absinthe GraphQL in Elixir
defmodule Languafy.Web.Context do
@behaviour Plug
import Plug.Conn
alias Languafy.User
def init(opts), do: opts
def call(conn, _) do
case build_context(conn) do
{:ok, context} ->
@posilva
posilva / install_golang.sh
Last active December 18, 2017 10:24 — forked from jniltinho/install_golang.sh
Install Golang on Linux
#!/bin/bash
## Install Golang 1.9 64Bits on Linux (Debian|Ubuntu|OpenSUSE|CentOS)
## http://www.linuxpro.com.br/2015/06/golang-aula-1-instalacao-da-linguagem-no-linux.html
## Run as root (sudo su)
## Thank's @geosoft1 | @gwmoura
GO_URL="https://storage.googleapis.com/golang"
GO_VERSION=${1:-"1.9.2"}
GO_FILE="go$GO_VERSION.linux-amd64.tar.gz"