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 'webrick' | |
class TestContentServlet < WEBrick::HTTPServlet::AbstractServlet | |
def do_GET(req, res) | |
res.body = get_body(req.path) | |
res.content_type = WEBrick::HTTPUtils.mime_type( | |
req.path_info, WEBrick::HTTPUtils::DefaultMimeTypes) | |
end | |
def get_body(path) |
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
deployment: | |
production: | |
branch: master | |
commands: | |
- heroku maintenance:on --app production | |
- heroku scale worker=0 --app production | |
- git push -f git@heroku.com:production.git $CIRCLE_SHA1:refs/heads/master | |
- heroku run 'rake db:migrate; rake db:seed' --app production | |
- heroku maintenance:off --app production | |
staging: |
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
// Swift Sequence | |
import UIKit | |
var str = "Hello, playground" | |
class Cart<T> { | |
var items: [T] | |
init(items: [T]) { |
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 Model { | |
class func classString() -> String { | |
return NSStringFromClass(self.classFromCoder) | |
} | |
} |
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="https://github.com/user/repo/compare/049508ce0e26...286b18317092" | |
echo ${var#*compare/} | |
# 049508ce0e26...286b18317092 |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
epsilon = 0.01 | |
y = 1234567.0 | |
guess = y/2.0 | |
while abs(guess*guess - y) >= epsilon: | |
guess = guess - (((guess**2) - y)/(2*guess)) | |
print(guess) | |
print('Square root of ' + str(y) + ' is about ' + str(guess)) |
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
x = 1234567 | |
epsilon = 0.01 | |
numGuesses = 0 | |
low = 0.0 | |
high = x | |
ans = (high + low)/2.0 | |
while abs(ans**2 - x) >= epsilon: | |
print('low = ' + str(low) + ' high = ' + str(high) + ' ans = ' + str(ans)) | |
numGuesses += 1 | |
if ans**2 < x: |
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
num = 256 | |
if num < 0: | |
isNeg = True | |
num = abs(num) | |
else: | |
isNeg = False | |
result = '' | |
if num == 0: | |
result = '0' |
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 a(x, y, z): | |
if x: | |
return y | |
else: | |
return z | |
def b(q, r): | |
return a(q>r, q, r) | |
print(a(False, 2, 3)) |
OlderNewer