Skip to content

Instantly share code, notes, and snippets.

View richardsondx's full-sized avatar

Richardson Dackam richardsondx

View GitHub Profile
@richardsondx
richardsondx / country_select.rb
Last active August 29, 2015 13:56
Error with activeadmin and country_select
module ActionView
module Helpers
module FormOptionsHelper
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
end
# Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
# have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
# that they will be listed above the rest of the (long) list.
app = angular.module("wallrentjs", ["ngResource"])
@ArtworkCtrl = ($scope, $http) ->
$http(
method: "GET"
url: "http://localhost:3000/api/artists/ac9998fc-1735-44fc-8ae0-814154d9cb2f/artworks"
).success(data) ->
console.log(data)
$scope.artworks = data
@richardsondx
richardsondx / JirasController
Created March 12, 2014 22:04
WebsocketRails
class JirasController < ApplicationController
def action
send_message :event_name, new_message
end
end
@richardsondx
richardsondx / gist:9517669
Created March 12, 2014 22:17
websocketrails error
def dispatch(controller, action, env)
controller.action(action).call(env)
end
Local Variables
controller: JirasController
action: "import"
class JirasController < ApplicationController
def generate_work_log
...
fields.each_with_index do |field,index|
progress = field.index
WebsocketRails[:admin_channel].trigger :event_name, progress
end
end
@richardsondx
richardsondx / route.rb
Created April 1, 2014 20:42
apply https to active admin
scope :protocol => 'https://', :constraints => { :protocol => 'https://' } do
ActiveAdmin.routes(self)
end
<li>
<%= truncate(experience.content, length: 200) { button_to "Continue", { action: "#" }, method: :get } %>
</li>
<li>
<%= truncate(experience.content, length: 200) { button_to "Continue", { action: "#" }, method: :get } %>
</li>
me = User.create(*all the info*)
ruby = Language.create(name: 'ruby')
python = Language.create(name: 'python')
UsersLanguage.add_language(python, me)
=> true
UsersLanguage.add_language(ruby, me)
=> true
@richardsondx
richardsondx / sort.rb
Last active August 29, 2015 14:06 — forked from aspyct/sort.rb
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end