Skip to content

Instantly share code, notes, and snippets.

View NullVoxPopuli's full-sized avatar

NullVoxPopuli

View GitHub Profile
@NullVoxPopuli
NullVoxPopuli / desk_sso.rb
Last active August 29, 2015 13:56
Authenticating to Box.com using Single Sign On in Ruby on Rails
# https://github.com/assistly/multipass-examples/blob/master/ruby.rb
module DeskSSO
# http://dev.desk.com/guides/sso/#enable
def self.build_url(user)
json = {
uid: user.id,
expires: (DateTime.now + 10.years).iso8601,
customer_email: user.email,
customer_name: user.name
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://www.swingin.org/jquery.countdown.min.js"></script>
<script type="text/javascript">$(function(){
$(".kento-splash-screen").click(function(){
$(".kento-splash-screen, #kento-splash-screen-black").fadeOut();
});
$(".kento-splash-screen .countdown").countdown('2014/04/16 20:00:00', function(event) {
$(this).html(event.strftime('%w weeks %d days %H:%M:%S'));
});
});</script>
@NullVoxPopuli
NullVoxPopuli / .vimrc
Last active August 29, 2015 13:57
.vimrc for converting VIM into SublimeText
" Gutter Numbers
set number
" Moust Support
set mouse=a
" Normal Sized tabs, zomg
set tabstop=4
@NullVoxPopuli
NullVoxPopuli / app-controllers-concerns-presntable.rb
Created May 14, 2014 18:08
A Dynamic Presenter Pattern with Support for API Versioning
# helper methods for using presenters for rendering objects using for
# API requests
#
#
# usage:
# in application_controller,
# include Presntable
#
# in your controller's action methods:
# format.json{ render json: json_for(ar_object_or_collection) }
# how to configure automated testing:
# http://www.rubyinside.com/how-to-rails-3-and-rspec-2-4336.html
##################################################################33
require 'spork'
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start 'rails' do
add_filter "/vendor/"
add_group 'Changed' do |source_file|
require 'spec_helper'
describe Documents::ChangeRequestsController do
before(:each) do
instantiate_mock_user_and_account
@proposal = create_proposal
end
it "works" do
@NullVoxPopuli
NullVoxPopuli / include-vs-prepend.rb
Created December 11, 2014 21:15
shows what happens to the ancestry if a class - and the super classes
require "pry-byebug"
module ToBeIncluded
end
module ToBePrepended
end
class Super
end
@NullVoxPopuli
NullVoxPopuli / route_recognizer.rb
Created December 28, 2014 20:04
Route Recognizer to replace the broken Rails 3+'s recognize_path
class RouteRecognizer
include Singleton
ROUTE_LIST = Rails.application.routes.routes.collect{|r| r.path.spec.to_s}
REGEX_ROUT_LIST = ROUTE_LIST.map{|r|
Regexp.new(r.gsub(/\:(.*)id/, "(\d+)").gsub("(.:format)", ""))
}
def self.is_route?(path)
REGEX_ROUT_LIST.each do |regex|
@NullVoxPopuli
NullVoxPopuli / FormatKey.vb
Created March 20, 2015 16:07
VisualBasic module to convert strings to lowerCamelCase
Module FormatKey
Private _knownPrefixes() As String = New String() _
{"i", "d", "dt", _
"dr", "ds"}
Public Function ToLowerCamelCase(ByVal s As String) As String
Dim result As String = ""
Dim listOfWords As ArrayList = SplitWords(s)
@NullVoxPopuli
NullVoxPopuli / CollectionEquality.vb
Last active May 18, 2021 05:15
Deep Equality Compare of Nested Dictionaries and Lists
Imports System.Collections.Generic
Namespace AUL
Partial Class Utils
Private Shared _valueComparer As EqualityComparer(Of Object) = EqualityComparer(Of Object).Default
''' <summary>
'''
''' There is no pre-given implementation of .Equals