Skip to content

Instantly share code, notes, and snippets.

View elissonmichael's full-sized avatar
🚫
undefined method 'status' for nil:NilClass

Élisson Michael elissonmichael

🚫
undefined method 'status' for nil:NilClass
View GitHub Profile
@claudiohilario
claudiohilario / Date Picker (materializecss) config pt pt.js
Created October 23, 2016 16:38
Tradução para português do Date Picker (materializecss)
$(function () {
//Config datepiker matrializecss () language
$('.datepicker').pickadate({
selectMonths: true,//Creates a dropdown to control month
selectYears: 15,//Creates a dropdown of 15 years to control year
//The title label to use for the month nav buttons
labelMonthNext: 'Proximo Mês',
labelMonthPrev: 'Mês Anterior',
//The title label to use for the dropdown selectors
labelMonthSelect: 'Selecionar Mês',
@the-bass
the-bass / application.html.erb
Last active April 15, 2020 15:01
Using Google Analytics with Rails 5 and Turbolinks 5. This code is taken from the conversation between @preetpalS and @packagethief on https://github.com/turbolinks/turbolinks/issues/73.
<%# Put this code snippet between the <head></head>-tags in your application layout and %>
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %>
<%# ... %>
<head>
<%# ... %>
<% if Rails.env.production? %>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@matiaskorhonen
matiaskorhonen / sign-pdf.rb
Last active May 25, 2023 10:58
Quick and dirty PDF signing in Ruby (using Origami)
#!/usr/bin/env ruby
require "openssl"
require "time"
begin
require "origami"
rescue LoadError
abort "origami not installed: gem install origami"
end
@dukeimg
dukeimg / expectation_matchers_spec.rb
Created February 28, 2016 09:13
RSpec -- Expectation Matchers
describe 'Expectation Matchers' do
describe 'equivalence matchers' do
it 'will match loose equality with #eq' do
a = "2 cats"
b = "2 cats"
expect(a).to eq(b)
expect(a).to be == b # synonym for #eq
@psobocinski
psobocinski / dummy_controller.rb
Created January 23, 2016 20:04
Asserting on a JSON response in a Rails controller test with MiniTest
class DummyController < ApplicationController
def do
render json: { balance: 50 }
end
end
@joekur
joekur / html_safe.md
Last active December 11, 2023 22:57
Proper Use of `html_safe`

Proper use of html_safe

Let's look at an innocuous piece of ruby. Consider some view code showing a user's name and phone number:

"#{first_name} #{last_name} #{phone}"

Great - this is very succinct, readable, and can easily be extracted to a method in a

@mlanett
mlanett / rails http status codes
Last active April 13, 2024 13:40
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@terrywbrady
terrywbrady / GoogleSpreadsheet.html
Last active April 12, 2024 13:14
Sample HTML/JS to parse a Google Spreadsheet
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var spData = null;
function doData(json) {
spData = json.feed.entry;
}
@yuanyan
yuanyan / atom-ruby-snippets.cson
Created March 4, 2014 11:38
Ruby Snippets for Atom
'.source.ruby':
'describe (String)':
'prefix': 'des'
'body': 'describe "${1:subject}" do\n $0\nend'
'describe (type)':
'prefix': 'dest'
'body': 'describe ${1:Type} do\n $0\nend'
'describe (type, string)':
'prefix': 'dests'
'body': 'describe ${1:Type}, "${2:description}" do\n $0\nend'