Skip to content

Instantly share code, notes, and snippets.

View sescobb27's full-sized avatar
🇨🇴
sisas parce

Simon Escobar Benitez sescobb27

🇨🇴
sisas parce
View GitHub Profile
@shmink
shmink / Eex.json
Last active March 15, 2019 19:21
HTML && EEx snippets
{
//
// EEx
//
"eex_render_block": {
"prefix": "e=",
"body": ["<%= $1 %>$0"],
"description": "<%= %> render block"
},
"eex_exec_block": {
@nateberkopec
nateberkopec / correction.md
Last active February 14, 2024 16:22
A Simple Correction

In yesterday's post I said, in relation to "how does .present? work on ActiveRecord::Relation", I said that present? performs an existence check SELECT 1 AS one FROM ... LIMIT 1 because it calls exists? underneath. This is actually wrong - it loads the relation.

Jonathan Mast corrected me on Twitter. It turns out, I should have paid closer attention! Here is the actual implementation of blank? on ActiveRecord::Relation on Rails master:

# Returns true if relation is blank.
def blank?
  records.blank?
end
-module(task).
-export([async/1, async/3]).
-export([await/1, await/2, await/3]).
-opaque t() :: #{tpid := pid(), tref := reference()}.
-type await_opts() :: [kill].
-export_type([t/0]).
-export_type([await_opts/0]).
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@aronisstav
aronisstav / 00-Supervision-tree-races.md
Last active September 10, 2018 08:41
Workers of a bottom supervisor may be left running when a top supervisor is shutdown

Workers of a bottom supervisor may be left running when a top supervisor is shutdown

This is an unexpected behaviour discovered by Concuerror.

Overview

Four modules are used:

  1. test.erl contains the configuration and entry point of the test.
  2. sup1.erl is the code of a top-level supervisor
  3. sup2.erl is the code of a bottom-level supervisor
  4. worker.erl is the code of a gen_server worker
defmodule SearchWorker do
use GenServer
@idle_timeout_ms 10 * 60 * 1000
# client api
def touch(pid) do
GenServer.cast(pid, :touch)
end
@jasonlong
jasonlong / example-sparkline.md
Last active May 14, 2018 02:36
Example for generating SVG sparklines – Released under CC0-1.0 (https://creativecommons.org/publicdomain/zero/1.0/)

example-sparkline

dockerex

socat -d TCP-LISTEN:2376,range=127.0.0.1/32,reuseaddr,fork UNIX:/run/docker.sock &
# curl localhost:2376/containers/json
[{"Id":"47d8a2db2b0b64408f23e65d28e10a44d90b029b29b89b1427407bfddad8a61e","Names":["/objective_jepsen"],....
@rushilgupta
rushilgupta / GoConcurrency.md
Last active January 25, 2024 14:59
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@jessejanderson
jessejanderson / macros.md
Last active March 26, 2024 08:33
Don't Write Macros (but do learn how they work)