Skip to content

Instantly share code, notes, and snippets.

View liveview_example.ex
defmodule CounterWeb.Counter do
use Phoenix.LiveView
def render(assigns) do
<h1>The count is: <%= @val %></h1>
<button phx-click="dec">-</button>
<button phx-click="inc">+</button>
brianstorti / timing
Created Mar 14, 2018
timing - script to prefix stdout with the executing time
View timing
#!/usr/bin/env bash
# Usage:
# $ command | timing
# Example:
# $ rails server | timing
# 00:00:00 | rails server -b
# 00:00:04 | => Booting Puma
# 00:00:04 | => Rails 5.1.3 application starting in development on
View preload.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 ''
# Activate the gem you are reporting the issue against.
brianstorti / gist:4f0c4ff0b5cfc092aa7f5a5f187b6f8b
Created Apr 7, 2016
View gist:4f0c4ff0b5cfc092aa7f5a5f187b6f8b
=ERROR REPORT==== 7-Apr-2016::21:31:31 ===
Error on AMQP connection <0.3317.0> ( ->, vhost: '/', user: 'guest', state: running), channel 1:
View stacktrace
"query" => "\"\\n query IntrospectionQuery {\\n __schema {\\n queryType { name }\\n mutationType { name }\\n types {\\n ...FullType\\n }\\n directives {\\n name\\n description\\n args {\\n ...InputValue\\n }\\n onOperation\\n onFragment\\n onField\\n }\\n }\\n }\\n\\n fragment FullType on __Type {\\n kind\\n name\\n description\\n fields(includeDeprecated: true) {\\n name\\n description\\n args {\\n ...InputValue\\n }\\n type {\\n ...TypeRef\\n }\\n isDeprecated\\n deprecationReason\\n }\\n inputFields {\\n ...InputValue\\n }\\n interfaces {\\n ...TypeRef\\n }\\n enumValues(includeDeprecated: true) {\\n name\\n description\\n isDeprecated\\n deprecationReason\\n }\\n possibleTypes {\\n ...TypeRef\\n }\\n }\\n\\n fragment InputValue on __InputValue {\\n name\\n de
View gist:45d9742c3a20233d42a0
Java Virtual Machine statistics monitoring tool (jstat -options for all the options)
$ jstat -gcutil process_id 1000
S0 -> Survivors 0
S1 -> Survivors 1
E -> Eden
O -> Old
P -> Perm
YGC -> Young GC
brianstorti / priority_queue.rb
Last active Jul 8, 2020
Priority queue implementation in Ruby
View priority_queue.rb
class PriorityQueue
attr_reader :elements
def initialize
@elements = [nil]
def <<(element)
@elements << element
bubble_up(@elements.size - 1)
View gist:2237e30386817287ace4
Generated with:
rvm get head
echo 1.26.4 >| $rvm_path/VERSION
export PS4="+ %* %F{red}%x:%I %F{green}%N:%i%F{white} %_"
set -o xtrace
rvm --trace install 2.2.0 2>&1 | tee big.log
View gist:8a2b96c65457905829bb
Found old RVM 1.26.4 - updating.
No GPG software exists to validate rvm-installer, skipping.
Upgrading the RVM installation in /Users/brianstorti/.rvm/
RVM PATH line found in /Users/brianstorti/.bashrc /Users/brianstorti/.zshrc.
RVM sourcing line found in /Users/brianstorti/.bash_profile /Users/brianstorti/.zlogin.
Upgrade of RVM in /Users/brianstorti/.rvm/ is complete.
brianstorti / client.rb
Created Dec 10, 2014
dumb client/server socket
View client.rb
require 'socket'
class Client
attr_reader :host, :port
def initialize(host, port)
@host, @port = host, port