Skip to content

Instantly share code, notes, and snippets.

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

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@nicholasjhenry
nicholasjhenry / cheatsheet.md
Last active March 17, 2021 22:22
Absinthe GraphQL Schema Language Cheat Sheet

GraphQL Schema Language Cheat Sheet

The definitive guide to express your GraphQL schema succinctly

A port of a cheat sheet authored by Hafiz Ismail.

What does it look like?

defmodule MyApp.Schema do
 use Absinthe.Schema
Links:
A Visual Introduction to Machine Learning
http://www.r2d3.us/visual-intro-to-machine-learning-part-1/
UC Berkeley CS188 Intro to AI -- Course Materials
http://ai.berkeley.edu/home.html
Eyeo 2016 – Gene Kogan
https://vimeo.com/180044029
@danielberkompas
danielberkompas / scheduler.ex
Created October 26, 2016 17:59
A simple mix task scheduler for Elixir apps
defmodule MyApp.Scheduler do
@moduledoc """
Schedules a Mix task to be run at a given interval in milliseconds.
## Options
- `:task`: The name of the Mix task to run.
- `:args`: A list of arguments to pass to the Mix task's `run/1` function.
- `:interval`: The time interval in millisconds to rerun the task.
@mcshakes
mcshakes / Rails C error.
Created October 14, 2016 23:45
Running into RVM and readline issues
$ rails c
Running via Spring preloader in process 7916
/Users/edmac/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': dlopen(/Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle
Reason: image not found - /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle
Fixed with:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
lock '3.5.0'
set :application, 'your-app'
set :repo_url, 'https://github.com/your/app'
set :deploy_to, '/home/deploy/apps/your-app/'
namespace :deploy do
after :updated, :build do
on roles(:web) do
execute "cd '#{release_path}' && shards install"
@taiansu
taiansu / app.js
Created August 10, 2016 10:46
Phoenix brunch config which just make sense
import "phoenix_html"
import "bootstrap"
import "jquery"
import "toastr"
// ...
@pnc
pnc / poolboy.md
Last active June 27, 2022 10:56
Debugging poolboy checkout errors

Just about the only thing that'll crash the Erlang VM is running out of memory. Although processes themselves are cheap, a good way to run out of memory is to start an unbounded number of processes from an external signal (such as one per web request), and then make each of those processes hold onto some more expensive resource. If you're not careful about cleanup, you can also leak processes, which compounds the problem. Anyway, nobody's perfect, so to avoid these cases, we use the poolboy library in a bunch of places to handle process pools that handle cleanup and limit the total amount of concurrency to some reasonable amount.

When:

  1. all a pool's workers are checked out (by actual organic load/concurrency)
  2. some process is leaking pool workers by not checking them back in (rude)
  3. the pool supervisor isn't responding (it's deadlocked, bugs, etc.)

you'll see "checkout" timeouts (waited longer than the timeout to check out a worker from the pool):

@fschuindt
fschuindt / elixir_notes.md
Last active December 15, 2023 22:32
My personal study notes on Elixir. It's basically a resume of http://elixir-lang.org/getting-started/ (Almost everything is copied). Still working on it!
@maxim
maxim / ecto_batch_stream.ex
Last active September 9, 2022 18:15
Similar to Rails `find_each`, but for Elixir's Ecto, using Stream
defmodule EctoBatchStream do
import Ecto.Query, only: [from: 1, 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 # => […]
@kzkin
kzkin / phoenix-app.service
Last active October 30, 2018 19:16
systemd service for phoenix framework release (exrm)
# Phoenix Framework - A productive web framework that does not compromise speed and maintainability
[Unit]
Description=Phoenix Framework ISControl Application
After=network.target
[Service]
Type=simple
User=deployer
RemainAfterExit=yes