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
#!/bin/bash | |
# Gist https://gist.github.com/5618d1816364893ce9236d5d50272aa2 | |
backup_file () | |
{ | |
DATE=`date +"%Y%m%d-%S"` | |
NAME=${1} | |
NEWNAME=${NAME}-${DATE}.og | |
echo "Copying ${NAME} to ${NEWNAME}" |
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/f6a5ebf19ad736a3bdcf28be34b84cc4 | |
// To try out this program, you don't need to have a folder full of JPEG images. | |
// Do the following from from the command line to create some sample data to | |
// demonstrate how this program works. | |
// $ mkdir sample_data | |
// $ cd sample_data | |
// $ touch blue.jpeg red.jpeg yellow.jpeg orange.jpeg green.jpeg purple.jpeg | |
// $ cd .. |
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/30ad98e4ca6f0aa45db9e9a31c5625af | |
// Filename cpsc120_write_message.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_write_message.cc | |
// Read a line of text from cin and then write the line out to a file | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> |
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/746e191172af461f09f7b06bbebd3680 | |
#include <array> | |
#include <iostream> | |
#include <string> | |
int main(int argc, char const* argv[]) { | |
std::array<int, 6> my_array{10, 11, 12, 13, 14, 15}; | |
bool should_skip_first{true}; |
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/77e6c030cb519c2cbb221a00eff2cbe2 | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
int main(int argc, char const* argv[]) { | |
std::vector<std::string> arguments{argv, argv + argc}; | |
bool should_skip_first{true}; |
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/5b341c7d272ce7442754699351008d3e | |
// Filename cpsc120_fscat.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_fscat.cc | |
// An implementation of the `cat` program which prints the contents of a file | |
// to the std::cout (stdout) using the filesystem::path type. | |
#include <filesystem> | |
#include <fstream> | |
#include <iostream> | |
#include <string> |
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/ccd1c720a571b84e855c59e00f66df99 | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
int main(int argc, char const* argv[]) { | |
vector<std::string> arguments{argv, argv + argc}; | |
bool found{false}; |
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/37b21d3ba3d4630be6d97dae1b8fbde1 | |
#include <array> | |
#include <iostream> | |
int main(int argc, char const* argv[]) { | |
std::array<int, 6> my_array{10, 11, 12, 13, 14, 15}; | |
for (const int& number : my_array) { | |
if (number % 2 != 0) { |
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/49124a3e4c73ad44ac331dc023b61326 | |
// Filename cpsc120_cat.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_cat.cc | |
// An implementation of the `cat` program which prints the contents of a file | |
// to the std::cout (stdout). | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> |
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/fba16c441b459231d6fc5d2e35d046aa | |
#include <filesystem> | |
#include <iostream> | |
int main(int argc, char const *argv[]) { | |
// works just like `pwd` | |
std::cout << std::filesystem::current_path().string() << "\n"; | |
return 0; |