Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
digital nomad making music

Obie Fernandez obie

🎧
digital nomad making music
View GitHub Profile
@obie
obie / _alert.haml
Created Oct 15, 2020
Alerts in Reactive Rails style (with Shoelace web components)
View _alert.haml
%sl-alert.popup-toast{id: id, type: type, open: false, duration: duration, closable: true}
%sl-icon{slot: "icon", name: icon}
- if title.present?
%strong= title
%br
= text
@obie
obie / application_controller.rb
Created Oct 5, 2020
Workaround solution for having to restart Rails server to pickup changes to ViewComponent templates (Rails 6.1)
View application_controller.rb
class ApplicationController < ActionController::Base
after_action :clear_view_component_cache, if: -> { Rails.env.development? }
def clear_view_component_cache
ViewComponent::CompileCache.cache = Set.new
end
end
@obie
obie / quizizz.css
Created Nov 1, 2016
Print Quizizz Stylesheet
View quizizz.css
div {
font-family: Georgia;
font-size: 10pt;
}
h1 {
font-family: Helvetica;
}
img {
padding: 2em;
}
View test.html
<div class="question">
<div class="q-no">42.&nbsp;&nbsp;</div>
<div class="q-text">When the charge is reversed in a neuron during an action potential it is called</div>
<div class="answers">
<div class="answer">
<span class="answer-hole"></span>
<div class="opt">a)</div>
<div class="option">Polarization</div>
</div>
<div class="answer">
View gist:d794fe5417c4d4bfea7cdc313c424628
<div class="question">
<div class="q-no">42.&nbsp;&nbsp;</div>
<div class="q-text">When the charge is reversed in a neuron during an action potential it is called</div>
<div class="answers">
<div class="answer">
<span class="answer-hole"></span>
<div class="opt">a)</div>
<div class="option">Polarization</div>
</div>
<div class="answer">
View microservice-http-endpoint.js
console.log('Loading function');
var doc = require('dynamodb-doc');
var dynamo = new doc.DynamoDB();
/**
* Provide an event that contains the following keys:
*
* - operation: one of the operations in the switch statement below
* - tableName: required for operations that interact with DynamoDB
View designer.html
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
<template>
<style>
@obie
obie / source_maps.rb
Last active Dec 15, 2015 — forked from alexspeller/source_maps.rb
patches the generated source map with the otherwise missing filename
View source_maps.rb
if Rails.env.development?
module CoffeeScript
class SourceMapError < StandardError; end;
class << self
def compile script, options
script = script.read if script.respond_to?(:read)
if options.key?(:no_wrap) and !options.key?(:bare)
View special_nomination_spec.rb
# See http://blog.obiefernandez.com/content/2012/02/metaprogramming-your-activerecord-objects-at-runtime.html for an explanation
require 'spec_helper'
describe Nomination do
let(:user1) { FactoryGirl.create(:user) }
let(:user2) { FactoryGirl.create(:user_with_nominations_received) }
let(:user3) { FactoryGirl.create(:user_with_nominations_received) }
let(:user4) { FactoryGirl.create(:user) }
let(:user5) { FactoryGirl.create(:user) }
@obie
obie / gist:1886393
Created Feb 22, 2012
Example of using an anonymous class to build an RSpec custom Matcher
View gist:1886393
def be_guest_member_of(expected)
Class.new do
def initialize(expected)
@expected = expected
end
def matches?(target)
@target = target
@target.memberships.where(role: "guest").map(&:network).include? @expected
end
You can’t perform that action at this time.