Coding in the Lab
who am i
scott.tolksdorf@gmail.com
Been coding for 15 years, professionally for 10
Computational Math at UW
Web Lead at Thalmic Labs
Likes to build neat things
What are we covering
Intro - What is coding? What are languages?
Tools and Tips
Project 1: Automating your computer with Autohotkey
Fundamentals of Programming - Functions, variables, data structures oh my!
Project 2: Crunching data with Python
Project 3: Loving APIs with Javascript
What this is
Good intro to coding
Take home some sample projects
Get exposed to how programming can help you
Answer some burning questions
Have fun and build cool things
What this isn't
You won't be a programmer in a day
It can't solve everything
Not covering anything advanced, like R
Not overly easy, prepare to have some frustrations
Before we start
https://github.com/stolksdorf/BGSAWorkshop
Suitable text editor (Sublime, textmate, notepad++)
Autohotkey installed (Windows only)
Python Installed
Questions?
What is programming?
What are languages?
Looking at problems in a new way
Decomposition
potential hiccups
Tools and tips
Google and Stackoverflow are your friends
Rubber ducking
Syntax is ruthless, have a friend help
Test often
Variable names and comments
First project
automating with Autohotkey
FUNDAMENTALS of programing
variables
//variables are buckets where you store data
testResult = 0
testResult = testResult + 5
atomic types
//Strings are just text
myName = "Scott Tolksdorf"
//Numbers are, well, numbers
currentAge = 26
//Booleans can only ever be True or False
isTeachingAWorkshop = true
//Nil, undefined, or null (language dependent) is used when a variable has never been given a value
theLoniestVariable
errorTime = theLoniestVariable + 6
collection types
//Arrays are ordered lists of other variables
myFavNumbers = [3, 13, 42]
mixedTypes = [true, "this is neat", 45]
mixedTypes[1] == "this is neat"
mixedTypes.push("new value")
//Objects are used for key-value data, like a phonebook, or an encyclopedia
scott = {
name : "Scott Tolksdorf",
age : 26,
isCurrentlyTalkingAboutObjects : true
}
print scott.name
scott.age + 6
Nesting Data
//Combining collections and atomic types allows you to create useful structures
potluckInfo = {
date : '5/28/2015',
attendants : [
{
name : "Bill",
hasPlusOne : true,
contributing : ['dessert', 'plates']
},
{
name : "Sally",
hasPlusOne : false,
contributing : ['main']
}
]
}
potluckInfo.attendants[1].name // -> Sally
functions
//Functions allow you wrap up code and call it
sendGreeting = function(){
print "Hello World"
}
sendGreeting()
add = function(x,y){
return x + y
}
add(4,5) // -> 9
add(add(1,3), 5) // -> 9
looping
//Looping (for, each, map) allows us to run code over items in a collection
sum = function(listOfNumbers){
result = 0
for(num in listOfNumbers){
result = result + num
}
return result
}
print sum([1,2,3]) // -> 6
Basically The Basics
don't worry!
You don't need to remember everything
questions?
second project
data Crunching
with python
third project
Web APis with javascript
whew!
That was fun.
Coding in the Lab
By Scott Tolksdorf
Coding in the Lab
- 458