Skip to content

Instantly share code, notes, and snippets.

View BideoWego's full-sized avatar
:octocat:
Yarp

BideoWego BideoWego

:octocat:
Yarp
View GitHub Profile
@BideoWego
BideoWego / folder.js
Created March 23, 2016 04:36
Small jQuery plugin to fold nested divs
// ----------------------------------------
// Folder jQuery plugin
// ----------------------------------------
// Usage:
//
// $('.folder.month').folder();
// $('.folder.year').folder({
// iconOpen: 'fa-folder-open',
// iconClosed: 'fa-folder'
// });
@BideoWego
BideoWego / Key Bindings - User
Last active February 17, 2016 19:39
My Sublime Text 3 Preferences
[
{ "keys": ["super+shift+w"], "command": "close_all" }
]
@BideoWego
BideoWego / kitchen-sink.html
Last active February 28, 2020 09:42
HTML Kitchen Sink, all of the HTML elements in order for styling, testing, etc..
<h1>HTML Kitchen Sink</h1>
<h2>a</h2>
<a href="#">a</a>
<br>
<h2>abbr</h2>
<abbr title="abbr">Mr. Mrs. Dr.</abbr>
<br>
@BideoWego
BideoWego / adapter_acknowledeable.rb
Last active December 9, 2015 20:31
A Ruby on Rails model concern that allows a model to reference the database adapter type via a simple getter, great for database driver specific functionality!
module AdapterAcknowledgeable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def adapter
self.connection.instance_values["config"][:adapter]
end
end
@BideoWego
BideoWego / index.sql
Created November 26, 2015 18:41
Time Series Data SQL Example in PostgreSQL
-- ------------------------------------------------
-- Weekly
-- ------------------------------------------------
-- Revenue for week range
SELECT
DATE(weeks) AS week,
COALESCE(SUM(order_contents.quantity * products.price), 0) AS amount
FROM GENERATE_SERIES(
DATE_TRUNC('WEEK', DATE('2015-9-1')),
@BideoWego
BideoWego / index.rb
Last active November 26, 2015 18:32
Create all the combinations of 0 to n with e positions
# Array.new(2**5) do |i|
# [i / 2**4, i / 2**3 % 2, i / 2**2 % 2, i / 2 % 2, i % 2]
# end
# integer_combinations(2, 5)
# => [[0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 1], [0, 1, 0, 0, 0], [0, 1, 0, 0, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 1], [0, 1, 1, 0, 0], [0, 1, 1, 0, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 1], [1, 0, 0, 1, 0], [1, 0, 0, 1, 1], [1, 0, 1, 0, 0], [1, 0, 1, 0, 1], [1, 0, 1, 1, 0], [1, 0, 1, 1, 1], [1, 1, 0, 0, 0], [1, 1, 0, 0, 1], [1, 1, 0, 1, 0], [1, 1, 0, 1, 1], [1, 1, 1, 0, 0], [1, 1, 1, 0, 1], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1]]
def integer_combinations_of(n, e)
Array.new(n**e) do |i|
@BideoWego
BideoWego / a_rails_rspec_checklist\README.md
Last active January 13, 2022 12:20
Rails Spec setup checklist, helper and support files

Rails RSpec Checklist

  • Ensure turbolinks is disabled for good measure

    • comment out gem
    • remove from javascript asset pipeline
    • remove from application layout
  • Add the following gems to Gemfile in a development, test group

    • hirb
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
@BideoWego
BideoWego / _errors.html.erb
Last active November 28, 2017 11:14
Rails helper to get validation error messages for a given object or an optional field on that object. Also a view partial to output those errors.
<% if object.errors.present? %>
<div class="alert alert-danger">
<%
field ||= nil
error_messages_for(object, field) do |error|
%>
<%= error %>
<br/>
<% end %>
</div>
@BideoWego
BideoWego / _flash.html.erb
Last active February 15, 2016 05:54
Rails flash partial with Bootstrap classes
<% unless flash.empty? %>
<% flash.each do |key, value| %>
<div class="main-flash alert alert-<%= flash_css_class(key) %> text-center" style="border-radius: 0;">
<%= value %>
</div>
<% end %>
<% end %>