Skip to content

Instantly share code, notes, and snippets.


Aaron Cruz mraaroncruz

View GitHub Profile
Manzanit0 / ci-simple.yaml
Last active Jun 28, 2022
Elixir CI with Github Actions
View ci-simple.yaml
branches: [master, develop]
branches: [master, develop]
MIX_ENV: test
andrebrait /
Last active Sep 23, 2022
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

Sheikh2Imran /
Last active Dec 21, 2021
Custom method decorator in Django
def authentication_decorator(function):
def wrap(request, *args, **kwargs):
user_token = request.META.get('HTTP_AUTHORIZATION')
user_response, status_code = backend_obj.get_user(user_token)
if status_code == 200:
kwargs = user_response
return function(request, *args, **kwargs)
return wrap
sivers / podcast.rb
Created Oct 29, 2019
Podcast RSS generator in Ruby
View podcast.rb
#!/usr/bin/env ruby
require 'date'
require 'xml'
def htmlit(infile)
lines = File.readlines(infile)
/<!--\s+(.+)\s+-->/.match lines.shift
lines.unshift('<h2>%s</h2>' % $1)
html = ''
lines.each do |line|
alvinncx / config.exs
Last active Feb 4, 2021
Getting Phoenix.PubSub & Phoenix.LiveView to work together
View config.exs
# Configures the endpoint
config :example, Example.Endpoint,
pubsub: [name: Example.PubSub, adapter: Phoenix.PubSub.PG2],
mraaroncruz / ethereum.rb
Created Nov 8, 2018
Use your key with a contract in ruby
View ethereum.rb
client =
client.default_account = key.address
contract = Ethereum::Contract.create(...)
contract.key = key
View iam_admin_policy.json
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": [
"Resource": "arn:aws:s3:::*"
vdbelt / cloudflare-purge-cache-service-worker.js
Created Aug 21, 2018
A CloudFlare service worker that proxies purge cache requests. Example:
View cloudflare-purge-cache-service-worker.js
addEventListener('fetch', event => {
async function purgeCache(request) {
const url = new URL(request.url)
sulmanweb / _document.json.jbuilder
Created May 13, 2018
Active Storage as Attachment in Rails API with base64 decoding
View _document.json.jbuilder
json.extract! document, :id, :documentable_type, :documentable_id, :created_at
json.url rails_blob_url(document.doc)
Aetherus /
Last active May 24, 2022
How to scale out a Phoenix application with websocket

How to scale out a Phoenix application with websocket


It's relatively easy to scale out stateless web applications. You often only need a reverse proxy. But for those stateful web applications, especially those applications that embeds websocket services in them, it's always a pain to distribute them in a cluster. The traditional way is introducing some external services like Redis to handle pubsub, however, in such way, you often need to change your code. Can Erlang/Elixir, the "concurrency oriented programming languages", best other languages in this use case? Has Phoenix framework already integrated the solution of horizontally scaling websocket? I'll do an experiment to prove (or disprove) that.