function f(parameter1, paremeter2) { // define function
argument1 = parameter1; // pass parameters in as arguments
argument2 = parameter2;
return argument1 + argument2;
This file contains hidden or 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 monthNames = [ | |
"January", "February", "March", "April", "May", "June", | |
"July", "August", "September", "October", "November", "December" | |
]; | |
function onOpen() { | |
var ui = DocumentApp.getUi(); | |
// Or FormApp or SpreadsheetApp. | |
ui.createMenu('Macro') | |
.addItem('Update last modified date', 'replaceFormattedDate') |
This file contains hidden or 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 guess | |
x = rand(10) | |
puts "I have a number between 0-10 in mind? What is your best guess?" | |
y = gets.chomp!.to_i | |
if x == y | |
print "you got it!" | |
elsif x < y | |
print "You are about #{y-x} too high in your guess.\n" | |
print "Hint, x is #{x}" | |
else x > y |
This file contains hidden or 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
$ bundle install | |
Fetching gem metadata from http://rubygems.org/. | |
Error Bundler::HTTPError during request to dependency API | |
Fetching full source index from http://rubygems.org/ | |
^C | |
Quitting... |
This file contains hidden or 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
#Problem 12: | |
# The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: | |
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... | |
# Let us list the factors of the first seven triangle numbers: | |
# 1: 1 | |
# 3: 1,3 | |
# 6: 1,2,3,6 |
This file contains hidden or 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
grid_string = <<EOS | |
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 | |
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 | |
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 | |
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 | |
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 | |
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 | |
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70 | |
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21 | |
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72 |
This file contains hidden or 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
found = false | |
(1..1E3).each { |x| | |
(1..1E3).each { |y| | |
puts "a = #{x}, b = #{y}, c = #{1000 - x - y}, product = #{x * y * (1000 - x - y)}" | |
found = true if x ** 2 + y ** 2 == (1000 - x - y) ** 2 | |
break if found | |
} | |
break if found | |
} |
This file contains hidden or 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
Tourious::Application.configure do | |
# Settings specified here will take precedence over those in config/application.rb | |
TWITTER_KEY = 'Development Keys' | |
TWITTER_SECRET = 'Development Secret' | |
FACEBOOK_KEY = 'Development Keys' | |
FACEBOOK_SECRET = 'Development Secret' | |
# In the development environment your application's code is reloaded on | |
# every request. This slows down response time but is perfect for development |
This file contains hidden or 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 User < ActiveRecord::Base | |
has_many :events | |
has_many :ratings | |
has_many :messages | |
belongs_to :profile | |
def self.create_with_omniauth(auth) | |
create! do |user| | |
user.provider = auth["provider"] | |
user.uid = auth["uid"] |
This file contains hidden or 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
questions = [ | |
'How spontaneous of a traveler are you?', | |
'Do you drink alcohol?', | |
'Do you smoke cigarettes?', | |
'Do you like to know how things work?', | |
'I always like to try new things:', | |
'How religious are you?', | |
'In general, it is important to follow the rules:', | |
'Are you sensitive to others\' needs?' | |
] |
NewerOlder