Skip to content

Instantly share code, notes, and snippets.

View colindensem's full-sized avatar
🏠
Working from home

Fynn.Codes colindensem

🏠
Working from home
View GitHub Profile
@colindensem
colindensem / generate_svg_module.ex
Created November 12, 2024 11:06
Create svg functions in elixir from directory of svg icons
defmodule GenerateSVGModule do
@moduledoc """
Script to generate an Elixir module containing functions for each SVG icon.
Reads a directory of custom svg icons and turns them into code.
Done so that various aspects can be altered at use, eg stroke, fill
Creates a new module called `SvgIcons`
"""
@colindensem
colindensem / ci.yml
Created July 30, 2022 07:49
Ci with dialyzer - old config for memories only
# .github/workflows/ci.yml
on: push
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
otp: [22.2.8]
require "spec_helper"
RSpec.describe "Check we pass codeclimate" do
before do
current_sha = "master..HEAD"
@files = `git diff-tree --no-commit-id --name-only -r #{current_sha}`
@files.tr!("\n", " ")
ignore_files(@files)
end
@colindensem
colindensem / Spec snippet
Created June 15, 2021 09:19
Example presenter
describe EstimatePresenter do
let(:estimate) { instance_double(Estimate, type: "insurance") }
let(:presenter) { EstimatePresenter.new(estimate) }
describe '.insurance?' do
it 'is an insurance type' do
allow(estimate).to receive(:type).and_return('insurance')
expect(presenter.insurance?).to be_true
end
https://www.thegreatcodeadventure.com/composable-query-builders-with-arel-in-rails/
https://vimeo.com/91672848
@colindensem
colindensem / cli
Created June 3, 2021 16:32
Controllers decoupling rails
> sp = ServicePoro.call(
arg1: 'fu',
on_sucess: -> (text) { puts "#{text}bar" }
> fubar
@colindensem
colindensem / callable.rb
Created June 3, 2021 10:36
A result handling object
module Callable
extend ActiveSupport::Concern
class_methods do
def call(*args)
new(*args).call
end
end
end
@colindensem
colindensem / Callable.rb
Created June 3, 2021 10:28
Service object callable
module Callable
extend ActiveSupport::Concern
class_methods do
def call(*args)
new(*args).call
end
end
end
@colindensem
colindensem / method.rb
Created June 3, 2021 10:24
DataFinder using method() approach
module Accounting
class PaymentsFinder < BaseFinder
def default_model
Payments
end
def query
(
method(:by_transfer_to_id) >>
method(:by_transfer_from_id) >>
@colindensem
colindensem / Makefile
Created March 1, 2021 09:30 — forked from thomaspoignant/Makefile
My ultimate Makefile for Golang Projects
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=example
VERSION?=0.0.0
SERVICE_PORT?=3000
DOCKER_REGISTRY?= #if set it should finished by /
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
GREEN := $(shell tput -Txterm setaf 2)