Skip to content

Instantly share code, notes, and snippets.

@frobs
frobs / Rakefile
Last active December 16, 2015 05:29
Multibrowser test with capybara using Rake(if set two browser only work the last)
require 'rubygems'
require 'bundler'
Bundler.setup(:default)
desc 'Run specs multibrowser test'
task :spec, [:browser] do |t,args|
Bundler.setup(:test)
require 'rspec/core/rake_task'
@frobs
frobs / bin.xml
Created March 13, 2014 09:02
Packaging with maven .tar.gz .tar.bz2 .zip
<!--See:https://maven.apache.org/plugins/maven-assembly-plugin/component.html-->
<assembly>
<formats>
<format>tar.gz</format>
<!--<format>tar.bz2</format>-->
<!--<format>zip</format>-->
</formats>
@frobs
frobs / Dockerfile Postgres
Created June 27, 2015 21:24
A example Dockerfile for Postgres 2.4 downloded from https://registry.hub.docker.com/_/postgres/
# vim:set ft=dockerfile:
FROM debian:wheezy
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r postgres && useradd -r -g postgres postgres
# grab gosu for easy step-down from root
RUN gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \
@frobs
frobs / testing.ex
Created January 17, 2023 11:23
Testing file
defmodule MyTestScript do
@h 7
@fixed_value 37
def decode(num) do
decode_internal(num, "")
end
defp decode_internal(num, accum) when rem(num, @fixed_value) == 3 do
decode_internal(get_next_value(num , 3), accum <> "e")
defmodule MyTestScript do
@h 7
@fixed_value 37
def decode(num) do
decode_internal(num, "")
end
defp decode_internal(num, accum) when num == @h do
String.reverse(accum)
@frobs
frobs / Fizz_buzz.ex
Created September 10, 2023 15:31
Fizzbuzz with recursion
defmodule FizzBuzz do
@first_number 1
def fizzbuzz(n) do
do_fizzbuzz([], @first_number, n)
end
def do_fizzbuzz(acc, current_number, limit) when current_number > limit, do: Enum.reverse(acc)
def do_fizzbuzz(acc, current_number, limit) do
do_fizzbuzz([get_value(current_number) | acc], current_number + 1, limit)

Formatter to phoenix project

LiveView 0.17.8 and later includes Phoenix.LiveView.HTMLFormatter for formatting HEEx templates.

It’s a mix format plugin that’s added to the .formatter.exs file by default when you generate a Phoenix 1.7 app:

[
  plugins: [Phoenix.LiveView.HTMLFormatter],
  inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
  # ...