Skip to content

Instantly share code, notes, and snippets.

View richardsondx's full-sized avatar

Richardson Dackam richardsondx

View GitHub Profile
@richardsondx
richardsondx / Controller.rb
Last active August 29, 2015 14:21
Two requests.. different handling by rails
def upload_images
render :js => "alert('Hello Rails');"
end
@richardsondx
richardsondx / Gemfile
Last active August 29, 2015 14:21
weird Ajax issue
gem 'remotipart'
gem 'jquery-rails'
gem 'turbolinks'
gem 'sass-rails', '~> 4.0.0'
@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
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
<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>
@richardsondx
richardsondx / Capfile
Last active December 10, 2015 10:30
Capistrano deploy:assets:precompile issue rake stdout: Nothing written
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
@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
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 / 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"