Skip to content

Instantly share code, notes, and snippets.

public String statement() {
double totalAmount = 0;
int frequentRenterPoints = 0;
Enumeration rentals = _rentals.elements();
String result = "Rental Record for " + getName() + "\n";
while (rentals.hasMoreElements()) {
double thisAmount = 0;
Rental each = (Rental) rentals.nextElement();
//determine amounts for each line
switch (each.getMovie().getPriceCode()) {
class Customer {
private String _name;
private Vector _rentals = new Vector();
public Customer (String name){
_name = name;
};
public void addRental(Rental arg) {
_rentals.addElement(arg);
}
public String getName (){
class Rental {
private Movie _movie;
private int _daysRented;
public Rental(Movie movie, int daysRented) {
_movie = movie;
_daysRented = daysRented;
}
public int getDaysRented() {
return _daysRented;
}
public class Movie {
public static final int CHILDRENS = 2;
public static final int REGULAR = 0;
public static final int NEW_RELEASE = 1;
private String _title;
private int _priceCode;
public Movie(String title, int priceCode) {
_title = title;
_priceCode = priceCode;
}
#!/bin/bash
ImageName=CrossToolNG
ImageNameExt=${ImageName}.sparseimage
#diskutil umount force /Volumes/${ImageName}
#rm -f ${ImageNameExt}
hdiutil create ${ImageName} -volname ${ImageName} -type SPARSE -size 8g -fs HFSX
hdiutil mount ${ImageNameExt}
cd /Volumes/$ImageName
apt-get source linux-image-$(uname -r)
apt-get build-dep linux-image-$(uname -r)
# let kernel config be tailored to your current hardware (skip lots of unnecessary drivers)
lsmod > /tmp/lsmod
make LSMOD=/tmp/lsmod localmodconfig
# simple build
fakeroot make -j #CPU
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y vim git zsh ctags cscope tmux tree
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
git clone https://github.com/rightson/shell-dev-env.git ~/.env
~/.env/deploy.sh all
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
@rightson
rightson / virtualbox-patch-for-installing-osx.sh
Last active May 20, 2016 21:44
virtualbox patch for installing OS X
VBoxManage modifyvm "OS X 10.11" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff
VBoxManage setextradata "OS X 10.11" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3"
VBoxManage setextradata "OS X 10.11" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "OS X 10.11" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-2BD1B31983FE1663"
VBoxManage setextradata "OS X 10.11" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "OS X 10.11" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
@rightson
rightson / create-jos-env.sh
Last active May 20, 2016 22:33
A script for creating development environment for MIT JOS
export PFX=$HOME/jos-env
#export PATH=$PFX/bin:$PATH
#export LD_LIBRARY_PATH=$PFX/lib:$LD_LIBRARY_PATH # On Linux, use LD_LIBRARY_PATH
#export DYLD_LIBRARY_PATH=$PFX/lib:$DYLD_LIBRARY_PATH # On Mac OS X, use DYLD_LIBRARY_PATH
export GPM=gmp-5.0.2
export MPFR=mpfr-3.1.2
export MPC=mpc-0.9
export BINUTILS=binutils-2.21.1
export GCCCORE=gcc-core-4.6.3
#include <stdio.h>
typedef unsigned int u32;
typedef unsigned long u64;
static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
{
union {
u64 v64;
u32 v32[2];
} d = { dividend };