Skip to content

Instantly share code, notes, and snippets.

View Odaeus's full-sized avatar

Andrew France Odaeus

View GitHub Profile
@Odaeus
Odaeus / 1 original_webhook_handler.ex
Last active April 15, 2021 15:32
Elixir module refactoring pattern
# Original
defmodule Service.WebhookHandler do
def register_webhook(name) do
case Registry.register(webhook_id(name), __MODULE__) do
{:ok, _pid} -> :ok
error -> error
end
end
@Odaeus
Odaeus / fill.svg
Last active January 21, 2019 14:06
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
env:
browser: true
es6: true
extends: 'eslint:recommended'
parserOptions:
sourceType: module
rules:
indent:
- error
- 4
@import "globals";
custom-element {
--custom-var: $primaryColour;
}
require "yaks"
Book = Struct.new(:title, :author)
book = Book.new("Leviathan Wakes", "James A Corey")
class BookMapper < Yaks::Mapper
type "book"
attributes :title
require "yaks"
Book = Struct.new(:title, :author)
book = Book.new("Leviathan Wakes", "James A Corey")
class BookMapper < Yaks::Mapper
type :book
attributes :title
@Odaeus
Odaeus / gist:14196bec21648b0ddfa5
Created August 25, 2014 22:43
Todoist update failure
25/08/2014 15:41:10.000 kernel[0]: exec of /Users/andrew/Library/Containers/com.todoist.mac.Todoist/Data/Library/Application Support/Todoist/.Sparkle/Autoupdate.app/Contents/MacOS/Autoupdate denied since it was quarantined by Todoist and created without user consent, qtn-flags was 0x00000006
25/08/2014 15:41:10.659 Todoist[83762]: Couldn't posix_spawn: error 1
25/08/2014 15:41:10.669 Todoist[83762]: (
0 CoreFoundation 0x00007fff918fb25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff937c2e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff918fb10c +[NSException raise:format:] + 204
3 Foundation 0x00007fff9482efb4 -[NSConcreteTask launchWithDictionary:] + 3167
4 Foundation 0x00007fff9482dd58 +[NSTask launchedTaskWithLaunchPath:arguments:] + 200
5 Sparkle 0x00000001089d9c6e -[SUBasicUpdateDriver installWithToolAndRelaunch:displayingUserInterf
@Odaeus
Odaeus / application_controller.rb
Last active October 11, 2019 23:55
Simple Presenter Pattern
class ApplicationController < ActionController::Base
# ...
concerning :Presenters do
included do
helper_method :present
end
def present(record_or_array, klass)
if record_or_array.respond_to?(:map)
@Odaeus
Odaeus / packages.md
Last active December 15, 2015 10:19
Packages for running Ruby on Rails on Ubuntu

Minimal for gem compilation

  • build-essential

Common for gems

  • libxml2
  • libxml2-dev (for nokogiri)

Ruby compilation

  • libreadline6
@Odaeus
Odaeus / application_controller.rb
Last active June 15, 2021 09:34
Alternative to Rails' sharing of instance variables between controller and views.
class ApplicationController < ActionController::Base
# Creates an accessor which is exposed to the view
def self.view_accessor(*names)
attr_accessor *names
helper_method *names
end
end