Skip to content

Instantly share code, notes, and snippets.

Avatar
🏃‍♂️

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@sivers
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
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
mraaroncruz / ethereum.rb
Created Nov 8, 2018
Use your key with a contract in ruby
View ethereum.rb
key = Eth::Key.new(priv: YOUR_PRIVATE_KEY)
client = Ethereum::HttpClient.new(...)
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": [
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
@vdbelt
vdbelt / cloudflare-purge-cache-service-worker.js
Created Aug 21, 2018
A CloudFlare service worker that proxies purge cache requests. Example: https://example.com/__purge_cache?zone=XX
View cloudflare-purge-cache-service-worker.js
addEventListener('fetch', event => {
event.respondWith(purgeCache(event.request))
})
async function purgeCache(request) {
const url = new URL(request.url)
@sulmanweb
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
Aetherus / scale-out-phoenix-with-websocket.md
Last active Jun 6, 2021
How to scale out a Phoenix application with websocket
View scale-out-phoenix-with-websocket.md

How to scale out a Phoenix application with websocket

Foreword

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.

Resources

@raprasad
raprasad / change_password.md
Last active Jul 23, 2021
django user; change password from shell
View change_password.md

update django password

general changes

To use in dev environments

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

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"