Skip to content

Instantly share code, notes, and snippets.

@emilioforrer
emilioforrer / keybindings.json
Created November 12, 2023 02:11 — forked from bitterteasweetorange/keybindings.json
setup vscode like neovim
[
{
"command": "projectManager.listGitProjects#sideBarGit",
"key": "cmd+o"
},
{
"command": "expand_region",
"key": "ctrl+=",
"when": "editorTextFocus"
},
@emilioforrer
emilioforrer / config.exs
Last active September 20, 2021 00:59
phoenix_production_performance_config.exs
import Config
# https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
# https://stackoverflow.com/questions/41885427/use-so-reuseport-with-phoenix
sol_socket = 1
so_reuseport = 15
so_reuseport_opts =
case :os.type() do
{:unix, :linux} -> {:raw, sol_socket, so_reuseport, <<1::32-native>>}
@emilioforrer
emilioforrer / solution.ex
Created April 21, 2021 15:46 — forked from samuelralak/solution.ex
HackerRank 30 days of code. Day 0: Hello, World. Read from STDIN in Elixir
defmodule Solution do
#Enter your code here. Read input from STDIN. Print output to STDOUT
def read do
case IO.read(:stdio, :line) do
:eof -> :ok
{:error, reason} -> IO.puts "Error: #{reason}"
data ->
IO.write(:stdio, "Hello, World. \n")
IO.write(:stdio, data)
read()
@emilioforrer
emilioforrer / job_scheduler_using_ractor.rb
Created January 5, 2021 04:30 — forked from GustavoCaso/job_scheduler_using_ractor.rb
Simple implementation for a job scheduler using ruby Ractor primitive
# How to install the latests version of ruby
# 1. clone ruby/ruby
# 2. autoconf
# 3. ./configure
# 4. cd ext/openssl && ruby extconf.rb --with-openssl-dir=<openssl_root>; make; make install
# 5. cd ../../
# 6. make
# 7. make install-nodoc
# You should be ready ti run this script!!!!
@emilioforrer
emilioforrer / application_form.rb
Created September 10, 2020 06:17 — forked from danieldraper/application_form.rb
Service object and form object using ActiveModel and dry-rb
require "dry/monads/result"
class ApplicationForm
include Dry::Monads::Result::Mixin
include ActiveModel::Model
def self.attribute(name, options = {})
self.send(:attr_accessor, name)
_attributes << Attribute.new(name, options)
end
@emilioforrer
emilioforrer / Ruby documentation.md
Last active February 11, 2019 23:09
Ruby documentation

Ruby

JSON parse BigDecimal as number and not string

Install oj gem and create and intilizer config/initializers/oj.rb and set the mode to rails.

require 'active_support/core_ext'
require 'active_support/json'
require 'oj'
@emilioforrer
emilioforrer / object-to-formdata.js
Created December 4, 2018 04:01
object-to-formdata.js
'use strict'
function isUndefined (value) {
return value === undefined
}
function isObject (value) {
return value === Object(value)
}
@emilioforrer
emilioforrer / api-format.md
Last active December 31, 2018 15:37
API FORMAT

Format

The basic format of every HTTP request made to API is a JSON object with the following main nodes:

{
  "filter": {},
  "page": {},
  "data": {},
 "errors": {},
@emilioforrer
emilioforrer / scripts.md
Last active February 20, 2019 23:48
development-scripts

Encrypt a file to store it securely in the repo, for use in any CI

In this example, the gitignored contents of .env are:

FOO=secret
BAR=alsosecret

You can encrypt it with openssl running the next command: