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 Rental... | |
double getCharge() { | |
double result = 0; | |
switch (getMovie().getPriceCode()) { | |
case Movie.REGULAR: | |
result += 2; | |
if (getDaysRented() > 2) | |
result += (getDaysRented() - 2) * 1.5; | |
break; | |
case Movie.NEW_RELEASE: |
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 Movie... | |
double getCharge(int daysRented) { | |
double result = 0; | |
switch (getPriceCode()) { | |
case Movie.REGULAR: | |
result += 2; | |
if (daysRented > 2) | |
result += (daysRented - 2) * 1.5; | |
break; | |
case Movie.NEW_RELEASE: |
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 Rental... | |
double getCharge() { | |
return _movie.getCharge(_daysRented); | |
} | |
class Rental... | |
int getFrequentRenterPoints() { | |
if ((getMovie().getPriceCode() == Movie.NEW_RELEASE) && | |
getDaysRented() > 1) | |
return 2; |
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
import serial | |
class Serial: | |
BAUDRATE = 57600 | |
TIMEOUT = 1 | |
SERIAL_PORT = '/dev/ttyUSB0' | |
def __init__(self): | |
self.ser = serial.Serial( |
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
>>> import re | |
>>> src = 'LAYOUT PRIMARY "source_string"' | |
>>> dest = "dest_string" | |
>>> re.sub(r'(LAYOUT PRIMARY) "\w+"', '\\1 "%s"' % dest, src) | |
'LAYOUT PRIMARY "dest_string"' |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.putty.modal = true | |
config.vm.box = "bento/centos-6.7" | |
config.vm.provision "shell", inline: <<-SHELL | |
yum update -y | |
yum install -y epel-release | |
yum install -y http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm |
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
*xterm*font: 12x24 | |
*xterm*background: #101010 | |
*xterm*foreground: #d0d0d0 | |
*xterm*cursorColor: #d0d0d0 | |
*xterm*color0: #101010 | |
*xterm*color1: #960050 | |
*xterm*color2: #66aa11 | |
*xterm*color3: #c47f2c | |
*xterm*color4: #30309b | |
*xterm*color5: #7e40a5 |
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
# Reference: http://stevelorek.com/how-to-shrink-a-git-repository.html | |
function discoveryLargeGitObject() { | |
IFS=$'\n'; | |
# list all objects including their size, sort by size, take top 10 | |
objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head` | |
echo "All sizes are in kB. The pack column is the size of the object, compressed, inside the pack file." |
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
# from https://stackoverflow.com/questions/1128496/to-get-a-prompt-which-indicates-git-branch-in-zsh | |
# get the name of the branch we are on | |
git_prompt_info() { | |
git branch | awk '/^\*/ { print $2 }' | |
} | |
get_git_dirty() { | |
git diff --quiet || echo '*' | |
} | |
autoload -U colors |
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
'use strict'; | |
const path = require('path'); | |
const zlib = require('zlib'); | |
const winston = require('winston'); | |
const Koa = require('koa'); | |
const Router = require('koa-router'); | |
const koaLogger = require('winston-koa-logger'); | |
const convert = require('koa-convert'); | |
const compress = require('koa-compress'); |