kday


Joined 2 years ago
Homeworks submitted:
Homework comments:
26
61

About Me

I'm mostly interested in computer programming. Python and PHP are what I'm most comfortable with, and I'm looking to expand to other languages also.

I'm starting to play guitar again after a long, multi-year break.

Classes

Programming Ruby

Class status: Under Construction
Role: Student
. 12% complete

How to develop an Android app

Class status: Under Construction
Role: Creator
. 0% complete

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming

Class status: Established
Role: Student
. 0% complete

Introduction to Django

Class status: Unpublished
Role: Creator
. 0% complete

Programming in C

Class status: Established
Role: Creator
. 6% complete

Guitar for Beginners - Playing Pink Floyd

Class status: Established
Role: Creator
. 50% complete

Bulletproof Web Design

Class status: Established
Role: Creator
. 22% complete

Bash Scripting

Class status: Established
Role: Creator
. 50% complete

Structure and Interpretation of Computer Programs

Class status: Established
Role: Creator
. 15% complete

Beginning German

Class status: Established
Role: Creator
. 100% complete

Submitted Assignments

Programming Ruby: Lesson 1, HW 1

Done. I'm on Ubuntu and I followed the instructions here to install Ruby 1.9.2 with RVM (Ruby Version Manager): http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/


kday 7 months ago
Programming in C: Lesson 1, HW 3

I accidentally forgot to change the increment from positive to negative, so I got an infinite loop for a while there. Wasn't hard to fix though.

#include <stdio.h>

main()
{
  float fahr, celsius;
  int lower, upper, step;

  lower = 0;
  upper = 300;
  step = 20;

  fahr = upper;
  printf("  C      F\n----------\n");
  while(fahr >= lower){
    celsius = (5.0/9.0) * (fahr-32.0) ;
    printf("%3.0f %6.1f\n", fahr, celsius);
    fahr = fahr - step;
  }
}

kday 1 year ago
Programming in C: Lesson 1, HW 2
# Exercise 1-3
#include <stdio.h>

/* print Farenheight-Celsius table                                                                                                                                                 
   for fahr = 0, 20, ..., 300 */

main()
{
  float fahr, celsius;
  int lower, upper, step;

  lower = 0;
  upper = 300;
  step = 20;

  fahr = lower;
  printf("  C      F\n----------\n");
  while(fahr <= upper){
    celsius = (5.0/9.0) * (fahr-32.0) ;
    printf("%3.0f %6.1f\n", fahr, celsius);
    fahr = fahr + step;
  }
}


# Exercise 1-4
#include <stdio.h>

/* print Celsius-Farenheight table                                                                                                                                                 
   for celsius = -20, -10, 0 ..., 150 */

main()
{
  float fahr, celsius;
  int lower, upper, step;

  lower = -20;
  upper = 150;
  step = 10;

  celsius = lower;
  printf("  F      C\n----------\n");
  while(celsius <= upper){
    fahr = 32.0 + (9.0/5.0) * celsius;
    printf("%3.0f %6.1f\n", celsius, fahr);
    celsius = celsius + step;
  }
}

kday 1 year ago
Programming in C: Lesson 1, HW 1

I got the hello.c program to compile and run.

Also, I tried a few characters in place of n and below are the compiler errors I got.

#\u on end of line:
hello.c:5:9: warning: universal character names are only valid in C++ and C99
hello.c:5:9: error: incomplete universal character name \u

#\o on end of line:
hello.c:5:9: warning: unknown escape sequence '\o'

#\q on end of line:
hello.c:5:9: warning: unknown escape sequence '\q'

kday 1 year ago
Bash Scripting: Lesson 9, HW 1

I got functions to work in section 10.4, but the function that they have defined produced an error for me. I'm not sure if I was misusing it, but below is what I got when I tried to run the 'usage' function.

Also, I was surprised to learn that bash functions can't explicitly return a value. They just set values to variables that can be access by the code the calls the function, or they can output text that can be parsed. Seems kind of annoying to do things that way.

# Error from section 10.4
line 3: syntax error near unexpected token `&'

kday 1 year ago
Bash Scripting: Lesson 8, HW 1

Done. I was somewhat familiar with the find command, but it's a good review.


kday 1 year ago
Guitar for Beginners - Playing Pink Floyd: Lesson 3, HW 1

Done with week three. I think I'm making good progress:


kday 1 year ago
Beginning German: Lesson 6, HW 1

Complete.


kday 1 year ago
Guitar for Beginners - Playing Pink Floyd: Lesson 2, HW 1

Here's my second week's homework:

The noise at the end is some feedback from my amp. I felt this week I made some progress, but I think I can do even better next week. My fingers were pretty sore from playing earlier today so I hope that building up my callouses will help some.


kday 1 year ago
Beginning German: Lesson 5, HW 1

Complete


kday 2 years ago
Bash Scripting: Lesson 7, HW 1

Done! Pretty easy. Hadn't used sort much before, but it seems pretty useful.


kday 2 years ago
Bash Scripting: Lesson 6, HW 1

Complete. This was a useful lesson.


kday 2 years ago
Bash Scripting: Lesson 5, HW 1

Complete


kday 2 years ago
Beginning German: Lesson 4, HW 1

Complete.


kday 2 years ago
Beginning German: Lesson 3, HW 1

Complete.


kday 2 years ago
Structure and Interpretation of Computer Programs: Lesson 2, HW 1

See below:

;1.9
inc(+ 4 5)
inc(inc(+ 3 5))
inc(inc(inc(+ 2 5)))
inc(inc(inc(inc(+ 1 5))))
inc(inc(inc(inc(inc(0 5)))))
inc(inc(inc(inc(5))))
inc(inc(inc(6)))
inc(inc(7))
inc(8)

;1.11
(define (f n)
  (if (< n 3)
      n
      (+ (f (- n 1))
	 (* 2 (f (- n 2)))
	 (* 3 (f (- n 3))))))

;1.13
;Skipped this one

;1.15, part a
;p will be applied 5 times
(sine 12.15)
(p (sine 4.05))
(p (p (sine 1.35)))
(p (p (p (sine 0.45))))
(p (p (p (p (sine 0.15)))))
(p (p (p (p (p (sine 0.05))))))

;1.15, part b
;Growth in space = a^(1/3)
;Growth in steps = 2*a^(1/3)

;1.17
;Not sure...

;1.19
;Skipped

;1.21
;199: 199
;1999: 1999
;19999: 7

;1.25
;Not sure

;1.27
;Skipped

kday 2 years ago
Bash Scripting: Lesson 4, HW 1

Useful chapter. It's complicated to keep track of the different ways that parameters can be parsed. Now I see why a cookbook is a useful format for bash. Lots of syntax gotchas.

String manipulation operators are cool, but seem hard to remember also.


kday 2 years ago
Bash Scripting: Lesson 3, HW 1

Nice chapter. I've been looking for something similar to nohup for a long time. I've actually resorted to using cron at times for one-off long running tasks. nohup is going to save me a lot of trouble :)


kday 2 years ago
Bash Scripting: Lesson 2, HW 1

Complete. The select function in 3.7 is pretty cool. I didn't know that existed.

I got the following error when I tried 3.6. Not sure how to fix it because they kind of just put a big script in there without much explanation. Otherwise the homework went well.

# cookbook filename: func_choose
# Let the user make a choice about something and execute code based on
# the answer
# Called like: choose <default (y or n) > <prompt> <yes action> <no action>
# e. g. choose "y" \
#       "Do you want to play a game?" \
#       /usr/games/GlobalThermonucularWar \
#       ' printf "%b" "See you later Professor Falkin. "' >&2
# Returns: nothing
function choose {
    local default="$1"
    local prompt="$2"
    local choice_yes="$3"
    local choice_no="$4"
    local answer
    read -p "$prompt" answer
    [ -z "$answer" ] && answer="$default"
    case "$answer" in
        [ yY1] ) exec "$choice_yes"
            # error check
            ;;
        [ nN0] ) exec "$choice_no"
            # error check
            ;;
        *     ) printf "%b" "Unexpected answer ' $answer' ! "  >&2 ; ;
    esac
} # end of function choose

choose y "choose one" {echo "yes"} {echo "no"}


$./func_choose
$./func_choose: line 19: syntax error near unexpected token `yY1]'

kday 2 years ago
Beginning German: Lesson 2, HW 1

Completed.


kday 2 years ago
Bash Scripting: Lesson 1, HW 1

I couldn't get 2.12 to work, Skipping a Header in a File. tail kept trying to open the file '+2' and gave an error (see below).

I also skipped a couple towards the end like 2.19 and 2.20. The rest of the examples worked well, and I learned more than I expected to given it's the first chapter.

kevin@heater:~/bashtest2$ tail +2 /tmp/ls.out
tail: cannot open `+2' for reading: No such file or directory
==> /tmp/ls.out <==
k
s
a
d
f
g
h
j
k
s
kevin@heater:~/bashtest2$ tail /tmp/ls.out +2
==> /tmp/ls.out <==
k
s
a
d
f
g
h
j
k
s
tail: cannot open `+2' for reading: No such file or directory

kday 2 years ago
Beginning German: Lesson 1, HW 1

Completed


kday 2 years ago
Structure and Interpretation of Computer Programs: Lesson 1, HW 1

1.1 1. 10, 12, 8, 3, 6, "a-->3", "b-->4", 19, #f, 4, 16, 6, 16

1.2. (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5)))) (* 3 (- 6 2) (- 2 7))

1.4 The operator can be either + or -, depending on the value of b. If b is greater than zero, it's added to a. If b is less than zero, it's subtracted from a. The result is the same as adding the absolute value of b to a.

1.5 If it's applicative order, it will execute the arguments of test first. That means it will execute (p), which will result in an infinite loop. If it's normal order, the if statement will be executed first, and will return zero immediately. (p) will never be executed.

1.6 'new-if' doesn't get a chance to evaluate because its arguments are executed first and hit the max recursion depth before returning a value. That's why if is provided as a special form.

;;;;;;;;;;;;;;;;;;;;;
;;; 1.3:
;;;;;;;;;;;;;;;;;;;;;
(define (ss a b c)
	(cond ((and (< a b) (< a c)) (+ (* b b) (* c c)))
	      ((and (< b a) (< b c)) (+ (* a a) (* c c)))
	      (else (+ (* a a) (* b b)))))
(ss 1 2 3)

;;;;;;;;;;;;;;;;;;;;;;;;
;;; 1.7:
;;;;;;;;;;;;;;;;;;;;;;;;
(define (good-enough? old-guess new-guess)
  (< (abs (/ (- old-guess new-guess) new-guess)) .001))

(define (abs x)
  (if (> x 0)
      x
      (* x -1)))

(define (sqrt x)
  (sqrt-iter 0.1 1.0 x))

;;;;;;;;;;;;;;;;;;;;;
;;; 1.8:
;;;;;;;;;;;;;;;;;;;;
(define (cubert x)
  (cubert-iter 0.1 1.0 x))

(define (cubert-iter old-guess new-guess x)
  (if (good-enough? old-guess new-guess)
      new-guess
      (cubert-iter new-guess (improve-cube new-guess x)
		 x)))

(define (improve-cube guess x)
  (/ (+ (/ x (* guess guess)) (* 2 guess)) 3))

(define (good-enough? old-guess new-guess)
  (< (abs (/ (- old-guess new-guess) new-guess)) .001))

(define (abs x)
  (if (> x 0)
      x
      (* x -1)))
(define (sqrt-iter old-guess new-guess x)
  (if (good-enough? old-guess new-guess)
      new-guess
      (sqrt-iter new-guess (improve new-guess x)
		 x)))

kday 2 years ago