Skip to content

Instantly share code, notes, and snippets.

@xander-miller
xander-miller / README.md
Last active May 19, 2016
Ntile dashing widget. A Dashing numbers widget that puts your numbers in statistical context.
View README.md

#Ntile Widget# A Dashing widget that shows numbers in statistical context. This widget is also available in a GitHub Repository.

Demo Dashboard Screenshot

##Description## A Dashing widget (and an associated job) that will take any set of timestamped data, divid that data by day (or any other unit of time) and compare those units of time, and displays the current day in statistical context of previous days. It currently has three modes of operation Quartile, Quintile and Percentile (hench 'N'tile). The code is designed to take in a variety of data sources. Examples include:

  • Display number of new users your app has attracted this week compared to previous weeks.
  • Display how many customer service tickets have been closed by an individual employee today in the cont
@xander-miller
xander-miller / directions.erb
Created Oct 2, 2013
Make the following changes to devise/registrations/new.html.erb:
View directions.erb
<!-- add -->
<div class="control-group">
<%= f.label :name, class: 'control-label' %>
<div class="controls">
<%= f.text_field :name, :autofocus => true %>
</div>
</div>
<!-- end add -->
<div class="control-group">
@xander-miller
xander-miller / fish_cypher.rb
Last active Dec 27, 2015
Shopify asked me to send them a message so I created the best cover letter ever!!!
View fish_cypher.rb
quote = 'The last ever dolphin message was misinterpreted as a surprisingly sophisticated attempt to do a double-backwards-somersault through a hoop whilst whistling the ‘Star Spangled Banner’, but in fact the message was this: So long and thanks for all the fish.'
alphabet = ('a'..'z').to_a
offset = 5
result_quote = ''
quote.each_char do |char|
if alphabet.include?(char)
char = alphabet.rotate(alphabet.index(char))[offset]
elsif alphabet.include?(char.downcase)
char = alphabet.rotate(alphabet.index(char.downcase))[offset].upcase
View kathleen_seed.rb
require 'faker'
topics = []
15.times do
topics << Topic.create(
name: Faker::Lorem.words(rand(1..10)).join(" "),
description: Faker::Lorem.paragraph(rand(1..4))
)
end
View seeds.rb
require 'faker'
topics = []
15.times do
topics << Topic.create(
name: Faker::Lorem.words(rand(1..10)).join(" "),
description: Faker::Lorem.paragraph(rand(1..4))
)
end
@xander-miller
xander-miller / bookmark.rb
Created Feb 8, 2014
Using Embedly to generate preview thumbnails for bookmark links.
View bookmark.rb
#method for your app/models/bookmark.rb
def thumbnail_url
Embedly::API.new.oembed( url: self.url).first.thumbnail_url
end
View _comment.html.erb
<div class='status'>
<div class='row'>
<div class='span7'>
<strong><%= comment.user.name %></strong>
<p><%= comment.content %></p>
<div class='meta'>
<%= link_to "#{time_ago_in_words(comment.created_at)} ago", comment %>
</div>
</div>
</div>
View exercise.rb
class String
def title_case
articles = ['a','the','of']
words_array = self.downcase.split(" ")
words_array.each do |word|
unless articles.include?(word)
word.capitalize!
end
end
words_array.first.capitalize!
View show_me_the_specialities.html.erb
<ol>
<% @lawyers_specialty_questions.each do |question| %>
<li><%= question.title %></li>
<% end %>
</ol>
View items_controller.rb
def index
@list = List.find(params[:list_id])
@items = @list.items
end