Skip to content

Instantly share code, notes, and snippets.

View mraaroncruz's full-sized avatar
🏃‍♂️

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@sulmanweb
sulmanweb / _document.json.jbuilder
Created May 13, 2018 08:04
Active Storage as Attachment in Rails API with base64 decoding
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 February 23, 2024 14:31
How to scale out a Phoenix application with websocket

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

@heroheman
heroheman / ranger-cheatsheet.md
Last active April 23, 2024 15:12
Ranger Cheatsheet

Ranger Cheatsheet

General

Shortcut Description
ranger Start Ranger
Q Quit Ranger
R Reload current directory
? Ranger Manpages / Shortcuts
@raprasad
raprasad / change_password.md
Last active March 15, 2024 17:21
django user; change password from shell

update django password

general changes

To use in dev environments

  • after python manage.py shell
from django.contrib.auth.models import User
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 March 13, 2023 05:04
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"
@treeder
treeder / Dockerfile
Last active August 12, 2019 21:29
multi-stage build
# build stage
FROM golang:alpine AS build-env
RUN apk --no-cache add build-base git bzr mercurial gcc
ADD . /src
RUN cd /src && go build -o goapp
# final stage
FROM alpine
WORKDIR /app
COPY --from=build-env /src/goapp /app/
@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@mihow
mihow / load_dotenv.sh
Last active April 23, 2024 22:07
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@bsuh
bsuh / page_controller.ex
Last active July 16, 2020 20:00
proxying responses
defmodule PhoenixTest.PageController do
use PhoenixTest.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
def proxy(conn, params) do
query_string = conn.query_string
path = Enum.join(params["path"], "/")