This file contains hidden or 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
// cpsc120_trunc_convert_double.cc | |
// Gist https://gist.github.com/mshafae/7b281ca822da831d8ffb85982034c917 | |
#include <cmath> | |
#include <iostream> | |
#include <limits> | |
int main(int argc, char const *argv[]) { | |
// This is a really large number, a 1 with 308 zeros after it. | |
// double decimal_number{1.0e308}; |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# Gist: https://gist.github.com/mshafae/0ca00a411cab94a106d5585451f62dff | |
"""Example solutions to the CA/US quiz using the us_state.pckl and ca_county.pckl pickle files.""" | |
from collections import namedtuple | |
import pickle | |
import locale |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# | |
# Clearing the terminal three different ways. | |
# | |
# Gist https://gist.github.com/da88307f3b58b7a82bd26a8e998d6ce5 | |
# | |
def simple(): | |
# you can make it fancier by figuring out how many rows | |
# the terminal has and replace the hard-coded 24. |
This file contains hidden or 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
// Gist https://gist.github.com/f6d31d8630589c2e8986de8ce6238350 | |
#include <iostream> | |
int main(int argc, char const *argv[]) { | |
// Constant tip rate of 15% expressed as a decimal of 0.15 | |
const double kTipRate{0.15}; | |
std::cout << "What was the bill's sum? "; | |
double bill; |
This file contains hidden or 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
// Gist https://gist.github.com/70457715ff7fc2fcdcdaf44437624dd0 | |
#include <iostream> | |
#include <string> | |
std::string PromptForString(std::string query) { | |
std::cout << query; | |
std::string answer; | |
std::cin >> answer; | |
return answer; |
This file contains hidden or 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
// cpsc120_prompt.cc | |
// Gist https://gist.github.com/70457715ff7fc2fcdcdaf44437624dd0 | |
#include <iostream> | |
#include <string> | |
std::string PromptForString(std::string query) { | |
std::cout << query; | |
std::string answer; | |
std::cin >> answer; |
This file contains hidden or 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
// Gist https://gist.github.com/mshafae/1e50f814b084f19af6a702ba8f1b9d6d | |
// Filename cpsc120_image.cc | |
// CompileCommand clang++ -std=c++17 -I /usr/include/GraphicsMagick -lGraphicsMagick++ cpsc120_image.cc | |
// Create a simple, small image from a given | |
// filename. GraphicsMagick will figure out how to output to the given file | |
// format. | |
// Supported formats: http://www.graphicsmagick.org/formats.html | |
// Example: | |
// clang++ -std=c++17 -I /usr/include/GraphicsMagick -lGraphicsMagick++ |
This file contains hidden or 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
// Gist https://gist.github.com/e319fd4912f979828fc7aca6a714820d | |
#include <iostream> | |
#include <string> | |
int main(int argc, char const* argv[]) { | |
std::string a_big_number{"65536"}; | |
int the_integer_value{-1}; | |
try { |
This file contains hidden or 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
// Gist https://gist.github.com/697c2c169ebd5cdef9a3eb7d8c0bee1e | |
#include <array> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
int main(int argc, char const *argv[]) { | |
std::vector<std::string> arguments{argv, argv + argc}; |
This file contains hidden or 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
// Gist https://gist.github.com/36392c28705f3b62dda5d99d1db340b3 | |
#include <algorithm> | |
#include <iostream> | |
#include <iterator> | |
#include <string> | |
#include <vector> | |
int main(int argc, char const *argv[]) { |