Skip to content

Instantly share code, notes, and snippets.


Aaron Cruz mraaroncruz

View GitHub Profile
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 Jun 6, 2021
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.


raprasad /
Last active Jul 23, 2021
django user; change password from shell

update django password

general changes

To use in dev environments

  • after python shell
from django.contrib.auth.models import User
View rails_single_file.rb
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
gemfile(true) do
source ""
bsodmike /
Last active Apr 27, 2021
OC Nvidia GTX1070s in Ubuntu 16.04LTS for Ethereum mining

Following mining and findings performed on EVGA GeForce GTX 1070 SC GAMING Black Edition Graphics Card cards.

First run nvidia-xconfig --enable-all-gpus then set about editing the xorg.conf file to correctly set the Coolbits option.

# /etc/X11/xorg.conf
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"