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 makeFunc(a) { | |
var name = a; | |
function displayName() { | |
alert(a); | |
} | |
return displayName; | |
} | |
var a = 'something'; | |
var myFunc = makeFunc(a); |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<link rel="stylesheet" href="css/reset.css"> | |
<link rel="stylesheet" href="css/main.css"> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<script src="js/app.js"></script> | |
</head> |
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
<html> | |
<head> | |
<title>Tip Calculator</title> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<p>Hey there! Let me calculate that for you.</p> | |
</body> | |
</html> |
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
require "optparse" | |
def calculate_rate(base, percentage) | |
return base * percentage/100 | |
end | |
def calculate_meal_costs(meal_base, tax_rate, tip_rate) | |
tax_value = calculate_rate(meal_base, tax_rate) | |
meal_with_tax = tax_value + meal_base |
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
# first we get user inputs for our variables | |
# and convert them to Floats (they'll initially be strings). | |
puts "Please enter the cost of your meal (e.g., 22.45): $ " | |
meal_cost = Float(gets) | |
puts "Please enter tax rate as a percentage (e.g., 12.5 or 15): " | |
tax_percent = Float(gets) | |
puts "Please the tip percentage you'd like to leave (e.g., 18): " | |
tip_percent = Float(gets) | |
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
# first we assign our initial variables | |
meal_cost = 20.0 | |
tax_percent = 12 | |
tip_percent = 20 | |
# now we compute | |
tax_value = meal_cost * tax_percent/100 | |
meal_with_tax = meal_cost + tax_value | |
tip_value = meal_with_tax * tip_percent/100 | |
total_cost = meal_with_tax + tip_value |
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
from geventwebsocket.handler import WebSocketHandler | |
from gevent.pywsgi import WSGIServer | |
from flask import Flask, request, render_template | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return render_template('index.html') |
NewerOlder