Skip to content

Instantly share code, notes, and snippets.

View Sparkmasterflex's full-sized avatar

Keith Raymond Sparkmasterflex

View GitHub Profile
@Sparkmasterflex
Sparkmasterflex / bubblify.scss
Created December 12, 2018 19:33
sass mixin to "bubblify" a DOM element
p.bubble {
background: #6bc384;
color: #fff;
@include bubblify('right', #6bc384, 8px);
}
@mixin bubblify($dir, $color, $size: 10px) {
position: relative;
&:after {
@Sparkmasterflex
Sparkmasterflex / allow-receive-do-block.rb
Last active June 5, 2018 19:51
Rspec Allow/Receive do block
specify "my super awesome test here" do
nested_value = "my awesome string"
allow(model).to receive(:method) do |arg|
expect(arg).to include(:nested_key)
expect(arg[:nested_key]).to eq nested_value
end
end
@Sparkmasterflex
Sparkmasterflex / game_of_life.ex
Created May 17, 2017 04:45
GameOfLife module: Following game of life tutorial and getting a GenServer.call() no process error
defmodule GameOfLife do
use Application
@moduledoc """
Documentation for GameOfLife.
"""
def start(_type, _args) do
import Supervisor.Spec, warn: false
init_alive_cells = []
@Sparkmasterflex
Sparkmasterflex / board_server.ex
Created May 17, 2017 04:43
Following game of life tutorial and getting a GenServer.call() no process error
defmodule GameOfLife.BoardServer do
use GenServer
require Logger
@name {:global, __MODULE__}
@game_speed 1000
def start_link(alive_cells) do
case GenServer.start_link(__MODULE__, {alive_cells, nil, 0}, name: @name) do
@Sparkmasterflex
Sparkmasterflex / CanCan and Strong Parameters Fix
Created September 5, 2014 16:16
Solution for the CanCan issue with Rails strong parameters. This uses a method in the ApplicationController and calling it at the top of create/update action
class ApplicationController < ActionController::Base
...omitted code...
def check_ability action, obj
raise CanCan::AccessDenied unless can?(action, obj)
end
end
class UsersController < ApplicationController
load_and_authorize_resource except: [:create, :update]