Skip to content

Instantly share code, notes, and snippets.

Avatar

Angelika Tyborska angelikatyborska

View GitHub Profile
@angelikatyborska
angelikatyborska / .zshrc
Last active May 30, 2022
Prevent yourself from using the wrong js package manager
View .zshrc
npm() {
if [ -f yarn.lock ]; then
echo 'use yarn';
else
command npm $*;
fi
}
yarn() {
if [ -f package-lock.json ]; then
View pot-loader.js
const { spawnSync } = require('child_process')
const fs = require('fs')
const path = require('path')
const os = require('os')
const glob = require('glob')
// this loader "imports" a .pot file by compiling all of the .po files under the same domain
// into a JSON with translations that can be used by vue-gettext
//
// E.g.:
@angelikatyborska
angelikatyborska / gettext.ex
Last active Jan 16, 2022
A custom `gettext_with_link` macro for easily putting inline links into gettext strings
View gettext.ex
# Has one external dependency except for Gettext: https://github.com/rrrene/html_sanitize_ex
defmodule MyApp.Gettext do
@doc """
A helper for translations with links.
Pass in the translation string which must include
`%{link_start}`/`%{link_end}`. For multiple URLs, use
`%{link_start_<0,1,2...>}`.
@angelikatyborska
angelikatyborska / gettext_test.exs
Last active Jan 16, 2022
A unit test for Gettext translations that checks if the original and the translation use the same HTML tags. Uses Floki to parse HTML.
View gettext_test.exs
defmodule MyAppWeb.GettextTest do
use ExUnit.Case
import MyAppWeb.Gettext
# A unit test for Gettext translations that checks if the original and the translation
# use the same HTML tags.
#
# Uses Floki to parse HTML.
describe "translations" do
@angelikatyborska
angelikatyborska / rpg.ex
Created Aug 15, 2021
Protocol consolidation vs mix test --no-compile
View rpg.ex
# 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 Mar 10, 2021
Phoenix app serviced service file
View myphoenixapp.service
# /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 Nov 29, 2020
Exercism Elixir maintainers Slack channel welcome message
View hello.md

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.

View gist:6f7d2fe7df779ff87082af115093eda2
git ls-files | egrep '\.erl|\.ex[s]$' | xargs cat | sed '/^$/d' | wc -l
View angelika.zsh-theme
# 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 Aug 6, 2020
Custom validation messages - 3 inputs
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Validation</title>
<style>
body { padding: 10px; }
</style>
</head>
<body>