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
# Create an empty list using square brackets. | |
numbers = [] | |
print(numbers) # Output: [] | |
# Create an empty list using list(). | |
numbers = list() | |
print(numbers) # Output: [] | |
# Create a list of numbers. | |
numbers = [1, 2, 3] |
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
# Create an empty set using the constructor method. | |
numbers = set() | |
print(numbers) # Output: set() | |
# Note: {} creates a dictionary in Python. | |
print(type({})) # Output: <class 'dict'> | |
# set() constructor function takes an iterable as input. | |
numbers = set([1, 2]) | |
print(numbers) # Output: {1, 2} | |
string_set = set("hello") |
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
#### Tuple creation ##### | |
# Create a tuple, also called tuple packing. | |
numbers = 1, 2 | |
print(numbers) # Output: (1, 2) <- Note that it is represented with an enclosing paranthesis | |
# Create tuple with paranthesis. | |
numbers = (1, 2, 3) | |
print(numbers) # Output: (1, 2, 3) | |
# Create an empty tuple. | |
numbers = () | |
print(numbers) # Output: () |
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
Simulation Begin | |
! We will use this as input to Normal() below ; | |
Integer seed; | |
! Utility method for logging messages along with the current simulation | |
time ; | |
Procedure log(message); Text message; Begin | |
OutFix(Time, 2, 0); | |
OutText(": " & message); | |
OutImage; |
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
gem 'pg' | |
group :development do | |
gem 'ruby-debug' | |
end | |
gem 'rake', '~> 0.8.7' | |
gem 'devise' | |
gem 'oa-oauth', :require => 'omniauth/oauth' | |
gem 'omniauth' | |
gem 'haml' | |
gem 'dynamic_form' |
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 'io/console' | |
# Reads keypresses from the user including 2 and 3 escape character sequences. | |
def read_char | |
STDIN.echo = false | |
STDIN.raw! | |
input = STDIN.getc.chr | |
if input == "\e" then | |
input << STDIN.read_nonblock(3) rescue nil |
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
# The idea is just to illustrate that Ruby's #map and #select Enumerable methods | |
# are simply specific flavours of a fold operation, which Ruby implements as #inject. | |
# I've implemented #map and #select using #inject, and at the end I implemented #inject | |
# recursively. Ruby does #inject with Array#each, for very good reason. The recursive | |
# implementation is really just to illustrate the core Functional Programming concept | |
# which it derives from. | |
# We'll start simple. Map without applying a function: | |
[1,2,3,4,5].inject([]) {|memo, obj| memo << obj } |
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
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get install dosbox wget | |
mkdir -p wolf3d | |
cd wolf3d | |
wget http://image.dosgamesarchive.com/games/1wolf14.zip | |
unzip *.zip | |
dosbox INSTALL.EXE | |
echo "After setup cd into the new wolf3d directory" |
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
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get install dosbox wget | |
mkdir -p wolf3d | |
cd wolf3d | |
wget http://image.dosgamesarchive.com/games/1wolf14.zip | |
unzip *.zip | |
dosbox INSTALL.EXE | |
echo "After setup cd into the new wolf3d directory" |
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
#Not my code, this is from Mike Pfeiffer - http://mikepfeiffer.net/2010/03/how-to-merge-pdf-files-using-powershell-and-pdfsharp/ | |
#Requires PDFSharp assembly libraries http://sourceforge.net/projects/pdfsharp/ | |
#You need to load the assembly before you can use the function | |
# | |
#Merge-PDF -path c:\pdf_docs -filename c:\saved_docs.pdf | |
Add-Type -Path C:\assemblies\PdfSharp.dll | |
Function Merge-PDF { |