Skip to content

Instantly share code, notes, and snippets.

View angelikatyborska's full-sized avatar

Angelika Tyborska angelikatyborska

View GitHub Profile
@angelikatyborska
angelikatyborska / rpg.ex
Created August 15, 2021 09:35
Protocol consolidation vs mix test --no-compile
# test/rpg_test.exs
defmodule RPGTest do
use ExUnit.Case
alias RPG.{Edible, LoafOfBread}
describe "LoafOfBread" do
test "implements the Edible protocol" do
{:consolidated, modules} = Edible.__protocol__(:impls)
@angelikatyborska
angelikatyborska / myphoenixapp.service
Created March 10, 2021 18:37
Phoenix app serviced service file
# /etc/systemd/system/myphoenixapp.service
[Unit]
Description=Runner for My Phoenix App
After=network.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
WorkingDirectory=/path/to/myphoenixapp
@angelikatyborska
angelikatyborska / hello.md
Last active November 29, 2020 15:37
Exercism Elixir maintainers Slack channel welcome message

Hello!

So you want to help out with the Elixir track on Exercism? That's awesome! 💜

There are plenty of tasks that you can help with.

If you have any questions, if you're unsure where to start or you're stuck, do not hesitate to ask for help in our #maintaining-elixir Slack channel.

@angelikatyborska
angelikatyborska / gist:6f7d2fe7df779ff87082af115093eda2
Created September 14, 2020 15:48
Count LOC in an Elixir project
git ls-files | egrep '\.erl|\.ex[s]$' | xargs cat | sed '/^$/d' | wc -l
# requires the git-prompt zsh plugin, which in turn requires python2
PROMPT="%{$fg[blue]%}%n%{$reset_color%} in "
PROMPT+='%{$fg[cyan]%}%~%{$reset_color%} $(git_super_status)'
PROMPT+='
%(?:%{$fg_bold[green]%}$ :%{$fg_bold[red]%}$ )%{$reset_color%}'
RPROMPT=''
ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[red]%}%{∙%G%}"
ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{×%G%}"
@angelikatyborska
angelikatyborska / index.html
Last active August 6, 2020 15:25
Custom validation messages - 3 inputs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Validation</title>
<style>
body { padding: 10px; }
</style>
</head>
<body>
@angelikatyborska
angelikatyborska / gist:db66261f876d4047fba35bdcf244d790
Created June 2, 2020 13:46
Verify emails from a list with swaks
for E in `cat ~/some/file/with/email/addresses`
do
swaks --to $E --quit-after RCPT --hide-all
[ $? -ne 0 ] && echo $E
done
@angelikatyborska
angelikatyborska / post-checkout
Created May 14, 2020 06:48
post-checkout git hook to stash deps and _build
#!/bin/sh
# Set this to a list of space-separated paths to files/directories,
# which will be stashed away, when the current branch is changed
ARTIFACT_PATHS="deps _build"
# Set this to a directory where you would like the build artifacts of
# other branches to be stashed
ARTIFACT_STASH_PATH=".artifacts-stash"
PREVIOUS_HEAD="$1"
CURRENT_HEAD="$2"
IS_BRANCH_CHECKOUT="$3"
@angelikatyborska
angelikatyborska / index.html
Last active January 19, 2023 21:52
Providing custom error messages for built-in HTML5 form validation
<!DOCTYPE html>
<html lang="en">
<head>
<title>Form Validation</title>
<style>
body { padding: 10px; }
</style>
</head>
<body>
<form>
@angelikatyborska
angelikatyborska / sock.rb
Created July 2, 2019 15:19
HTTP(S) request via socket in Ruby
# HTTP
sock = TCPSocket.new('example.com', 80);
sock.write("GET /path HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n");
puts sock.read;
sock.close;
# HTTPS
sock = TCPSocket.new('example.com', 443)
sslsock = OpenSSL::SSL::SSLSocket.new(sock)
sslsock.connect