Skip to content

Instantly share code, notes, and snippets.

Avatar
🍇
Grapes Vibes

Herminio Torres herminiotorres

🍇
Grapes Vibes
View GitHub Profile
View parser_combinator.ex
defmodule Parser do
def numero() do
fn
<<c::utf8>> <> rest ->
case c do
c when c in ?0..?9 -> {:ok, c - ?0, rest}
_ -> {:error, {:numero, :no_parse, c}, <<c::utf8>> <> rest}
end
end
end
@mcrumm
mcrumm / page_live_test.exs
Created February 8, 2021 22:10
LiveView artifacts
View page_live_test.exs
defmodule MyAppWeb.PageLiveTest do
use MyAppWeb.ConnCase
import Phoenix.LiveViewTest
@tag :tmp_dir
test "disconnected and connected render", %{conn: conn, tmp_dir: tmp_dir} do
{:ok, page_live, disconnected_html} = live(conn, "/")
assert disconnected_html =~ "Welcome to Phoenix!"
@keathley
keathley / .credo.exs
Last active November 22, 2021 17:47
Keathley's credo file
View .credo.exs
# This file contains the configuration for Credo and you are probably reading
# this after creating it with `mix credo.gen.config`.
#
# If you find anything wrong or unclear in this file, please report an
# issue on GitHub: https://github.com/rrrene/credo/issues
#
%{
#
# You can have as many configs as you like in the `configs:` field.
configs: [
@carterbryden
carterbryden / AddPostgresTriggerAndFunctionForAllTables.exs
Last active March 26, 2023 15:29
Elixir Phoenix Postgresql migration to add triggers for pubsub to run on every CRUD operation on every table. If a new table is added, it'll automatically add a trigger to that table too.
View AddPostgresTriggerAndFunctionForAllTables.exs
defmodule MyApp.Repo.Migrations.AddPostgresTriggerAndFunctionForAllTables do
use Ecto.Migration
def up do
# Create a function that broadcasts row changes
execute "
CREATE OR REPLACE FUNCTION broadcast_changes()
RETURNS trigger AS $$
DECLARE
current_row RECORD;
@swyxio
swyxio / 1.md
Last active May 23, 2023 03:26
Learn In Public - 7 opinions for your tech career
View 1.md

2019 update: this essay has been updated on my personal site, together with a followup on how to get started

2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!

1. Learn in public

If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.

You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos

@dealloc
dealloc / Dockerfile
Last active October 7, 2020 18:45
Elixir Docker makefile
View Dockerfile
FROM elixir:alpine
WORKDIR /app
ARG USER_UID
ARG UNAME
EXPOSE 4000
RUN apk add --no-cache curl bash
RUN curl --url https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh --output /wait-for-it.sh
COPY ./docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
@PurpleBooth
PurpleBooth / README-Template.md
Last active June 7, 2023 09:01
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ericelliott
ericelliott / essential-javascript-links.md
Last active April 22, 2023 09:05
Essential JavaScript Links
View essential-javascript-links.md