Skip to content

Instantly share code, notes, and snippets.

View paulghaddad's full-sized avatar

Paul Haddad paulghaddad

View GitHub Profile
@paulghaddad
paulghaddad / Chapter 1
Created March 2, 2021 13:33
Practice of Programming
Exercise 1-1: Comment on the choice of names and values in the following code:
#define TRUE 0
#define FALSE 1
if ((ch = getchar()) == EOF)
not_eof = FALSE;
- Answer:
- You'd expect TRUE to be 1 and FALSE to be 0.
@paulghaddad
paulghaddad / test_vm_with_os.py
Created February 10, 2020 20:02
VM with OS Exercise
import pytest
from vm_with_os import VirtualMachine
def test_load_two_programs_to_memory():
vm = VirtualMachine()
segment_file_path_1 = 'add_255_3_test.vef'
vm.load_program(segment_file_path_1)
@paulghaddad
paulghaddad / hello_world.md
Last active August 15, 2019 11:06
Hello World Examples

Run ruby hello_world.rb or python hello_world.py to print Hello World

@paulghaddad
paulghaddad / hello_world.py
Created August 9, 2019 11:02
Hello World Examples
class HelloWorld:
def __init__(self, name):
self.name = name.capitalize()
def sayHi(self):
print "Hello " + self.name + "!"
hello = HelloWorld("world")
hello.sayHi()
@paulghaddad
paulghaddad / Aggregations
Last active August 15, 2018 12:18
PG Exercises
1. Count the number of facilities
SELECT COUNT(*)
FROM cd.facilities
2. Count the number of expensive facilities
SELECT COUNT(*)
FROM cd.facilities
WHERE guestcost > 10
<div class="nav" id="primary_navigation" style="background-color: #ff7600; font-size: 15px;">
<div class="container phone-message">
<p style="text-align: center;">Please use live chat to contact us</p>
</div>
</div>
@paulghaddad
paulghaddad / .powrc
Created June 8, 2015 15:25
Put in root of app
if [ -f "/usr/local/share/chruby/chruby.sh" ]; then
source /usr/local/share/chruby/chruby.sh
chruby $(cat ./.ruby-version)
fi
cnuapp-cnu_content-lib-ruby-cnu/content-action_controller
def locale
request_uri unless @locale
@locale
end
def locale_cd
locale.locale_cd
end
@paulghaddad
paulghaddad / README.md
Created February 23, 2015 13:22
Exercism Ruby - Robot Name

Robot Name

Write a program that manages robot factory settings.

When robots come off the factory floor, they have no name.

The first time you boot them up, a random name is generated, such as RX837 or BC811.

Every once in a while we need to reset a robot to its factory settings,

@paulghaddad
paulghaddad / gist:d26204d12de99b480644
Last active August 29, 2015 14:15
Level Up 7: Creates and maintains useful documentation for projects
1. What is a useful level of documentation?
Documentation should cover the following items:
- How to install the software and any dependencies, such as Ruby version.
- How to use the API and public methods.
- The current way of doing things and the proper idioms to use.
- Including meaningful examples of how to use the software.
- How to upgrade if moving up versions.