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 word_count(file) | |
file = File.open(file) { |f| f.read.split } | |
file = file.reduce(:+) | |
file = file.each_char.count | |
end | |
# or you could do this | |
def word_count(file) | |
File.open(file) { |f| f.read.split } |
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
var hideStuff = function() { | |
if (#{@platform.platform_type == 'rewards'}) { | |
var row = document.getElementsByTagName("tr"); | |
for (var i = 0; i < row.length; i++) { | |
if (row[i].innerHTML.search("Accreditation") != -1) { | |
row[i].style.display = "none"; | |
} else if (row[i].innerHTML.search("Escrow") != -1) { | |
row[i].style.display = "none"; | |
} |
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
irb(main):023:0> a = Authentication.new(platform_id: 235, user_id: 13036) | |
=> #<Authentication id: nil, platform_id: 235, user_id: 13036, receive_newsletter: true, roles_mask: nil, created_at: nil, updated_at: nil, mailchimp_registered: false, accepted_terms: nil, accepted_accredited_terms: nil, meta: nil, additional_fields: {}> | |
irb(main):024:0> a.save | |
(1.9ms) BEGIN | |
Platform Load (1.9ms) SELECT "platforms".* FROM "platforms" WHERE "platforms"."id" = 235 LIMIT 1 | |
(1.7ms) ROLLBACK | |
NoMethodError: undefined method `custom_attributes' for nil:NilClass |
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
# (*) = methods I added | |
class Dungeon | |
attr_accessor :player | |
def initialize(player_name) | |
@player = Player.new(player_name) | |
@rooms = [] | |
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
{% if template.name == 'projects/edit' %} | |
{{ template.content }} | |
{% else %} | |
{% assign author = project.author %} | |
<div class="content grid_8"> | |
{% authorize edit project %} | |
{% if warning %} | |
<div class='box-gray'> | |
<p>{{ warning }}</p> |
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 export_orders | |
authorize! :export_orders, @project | |
file_name = I18n.transliterate("#{@project.title}_supporters").downcase.gsub(/\s/, '_').gsub(/[^a-z_]/, '') | |
file_name = file_name.present? ? file_name : 'unknown' | |
if current_platform.id == 263 | |
csv_pledges = "Name,Email,Adresse,Adresszeile 2,Stadt,Bundesland,PLZ,Land,Beitrag,Projekttitel,Beitragszeit,Kosten des Tauschguts,Tauschgut,Beschreibung,Tauschgut,Versanddatum,\r\n" | |
else | |
csv_pledges = "Name,Email,Address,Address Line 2,City,State,Zip Code,Country,Amount,Project Title,Timestamp,Reward Level,Reward Description,Reward Delivery Date\r\n" | |
end | |
@project.pledges.confirmed.map{|p| csv_pledges += p.to_csv_with_reward_details} |
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
$col-numbers: "1", "2", "3", "4", "5", "6", | |
"7", "8", "9", "10", "11", "12"; | |
$selector: (); | |
@each $item in $col-numbers { | |
$selector: append($selector, unquote('.col-md-#{$item}'), comma); | |
} | |
#{$selector} { | |
padding-right: 0px; |
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
function makeTargetAssigner(sharks, targets) { | |
return function(shark) { | |
for (var i = 0; i < sharks.length; i++) { | |
if (shark == sharks[i]) { | |
alert("What up, " + shark + "!" + "\n" + "There've been " + targets[i] + " sightings in our 'hood!" + "\n" + "Time for a swim-by lasering, homie!"); | |
} | |
} | |
}; | |
} |
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
var superBlinders = [ ["Firestorm", 4000], ["Solar Death Ray", 6000], ["Supernova", 12000] ]; | |
var lighthouseRock = { | |
gateClosed: true, | |
weaponBulbs: superBlinders, | |
capacity: 30, | |
secretPassageTo: "Underwater Outpost", | |
numRangers: 0 | |
}; | |
function addRanger(location, name, skillz, station) { |
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
// Without running the code in the console, can you tell what this will do? | |
var superBlinders = [ ["Firestorm", 4000], ["Solar Death Ray", 6000], ["Supernova", 12000] ]; | |
var lighthouseRock = { | |
gateClosed: true, | |
weaponBulbs: superBlinders, | |
capacity: 30, | |
secretPassageTo: "Underwater Outpost", | |
numRangers: 3, | |
ranger1: {name: "Nick Walsh", skillz: "magnification burn", station: 2}, |
OlderNewer