This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JirasController < ApplicationController | |
def action | |
send_message :event_name, new_message | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dispatch(controller, action, env) | |
controller.action(action).call(env) | |
end | |
Local Variables | |
controller: JirasController | |
action: "import" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope :protocol => 'https://', :constraints => { :protocol => 'https://' } do | |
ActiveAdmin.routes(self) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<li> | |
<%= truncate(experience.content, length: 200) { button_to "Continue", { action: "#" }, method: :get } %> | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<li> | |
<%= truncate(experience.content, length: 200) { button_to "Continue", { action: "#" }, method: :get } %> | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer