Skip to content

Instantly share code, notes, and snippets.

Avatar
🏃‍♂️

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@mraaroncruz
mraaroncruz / jwt_params.rb
Created Apr 28, 2019
JWT params middleware
View jwt_params.rb
module Middlewares
class JwtParams
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
token = request.params['auth']
@mraaroncruz
mraaroncruz / Dockerfile
Last active Mar 8, 2019
Very, very simple ruby docker image
View Dockerfile
FROM ruby:2.6
RUN mkdir /app
WORKDIR /app
ADD Gemfile Gemfile.lock /app/
RUN gem install bundler \
&& bundle install -j 8
ADD . /app
@mraaroncruz
mraaroncruz / docker-compose.yml
Last active Mar 7, 2019
Setup docker registry
View docker-compose.yml
version: '3'
services:
registry:
image: registry:2
ports:
- "5000:5000"
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry
@mraaroncruz
mraaroncruz / setup.bash
Last active Apr 15, 2019
Setup a docker letsencrypt nginx port forwarded box
View setup.bash
#!/bin/bash
set -e
# Run like
# bash setup.bash example.com janet@example.com 5000
# vhost letsencrypt email application port
HOST=$1
EMAIL=$2
@mraaroncruz
mraaroncruz / Dockerfile
Created Mar 4, 2019 — forked from teamon/Dockerfile
elixir + phoenix + node dockerfile
View Dockerfile
########################################
# 1. Build nodejs frontend
########################################
FROM node:10.9-alpine as build-node
# prepare build dir
RUN mkdir -p /app/assets
WORKDIR /app
# set build ENV
@mraaroncruz
mraaroncruz / deploy.rb
Created Feb 28, 2019 — forked from larrylv/deploy.rb
mina script for Phoenix deployment
View deploy.rb
require 'mina/git'
set :domain, 'your_domain'
set :deploy_to, 'your_path_on_server'
set :repository, 'your_git'
set :branch, 'master'
set :app_name, 'your_app_name'
set :shared_paths, ['log']
@mraaroncruz
mraaroncruz / ecto_batch_stream.ex
Created Feb 21, 2019
Batch ecto requests as a stream
View ecto_batch_stream.ex
defmodule PrimedMind.Domain.Utils.EctoBatchStream do
import Ecto.Query, only: [from: 2]
@batch_size 1000
# Example:
#
# query = from u in MyApp.User, select: u.email
# stream = EctoBatchStream.stream(MyApp.Repo, query)
# stream |> Stream.take(3) |> Enum.to_list # => […]
@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:::*"
@mraaroncruz
mraaroncruz / steps.md
Last active Jun 9, 2021
Get the Telegram channel ID
View steps.md

To get the channel id

  1. Create your bot with botfather
  2. Make you bot an admin of your channel

New improved next steps

  1. Go to https://web.telegram.org
  2. Click on your channel
  3. Look at the URL and find the part that looks like c12112121212_17878787878787878
  4. Remove the underscore and after c12112121212