Compare commits

...

3 Commits

Author SHA1 Message Date
Sage Vaillancourt 5eccbfcbfc More comprehensive C++ skeleton
With unique_ptr usage, and basic map iteration.
Delete old fake_home/vim_templates directory
2024-01-22 20:36:03 -05:00
Sage Vaillancourt c283b58a18 Merge branch 'main' of https://git.sagev.space/sage/dotfiles 2024-01-22 19:46:41 -05:00
Sage Vaillancourt 699ce8a5aa Add skeleton.php 2024-01-21 22:41:16 -05:00
8 changed files with 81 additions and 50 deletions

View File

@ -1,29 +1,46 @@
// skeleton.cpp // skeleton.cpp
#include <iostream> #include <iostream>
#include <map>
#include <memory>
class Person class Person
{ {
std::string name; std::string name;
std::map<std::string, std::string> attributes {};
public: public:
Person(std::string name) Person(std::string name)
{ {
this->name = name; this->name = name;
} }
Person* addAttribute(std::string key, std::string value)
{
this->attributes[key] = value;
return this;
}
void greet() void greet()
{ {
std::cout << "Hello, my name is " << this->name << "!" << std::endl; std::cout << "Hello, my name is " << this->name << "!" << std::endl;
for (auto& kv : this->attributes) {
std::cout << " My " << kv.first << " is " << kv.second << "." << std::endl;
}
} }
}; };
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
auto person = new Person("Madison"); auto person = std::unique_ptr<Person>((new Person("Madison"))
->addAttribute("best friend", "Bob")
->addAttribute("favorite color", "pink")
);
person->greet(); person->greet();
delete person; // Not necessary with unique_ptr:
// delete person;
return 0; return 0;
} }

View File

@ -0,0 +1,60 @@
<?php
echo '<!DOCTYPE html>';
echo '<html lang="en">';
echo '<!-- This is a simple PHP template -->';
// This section could also use <?= syntax, but for example's sake, will not.
?>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= ucfirst(basename(__FILE__, '.php')) ?></title>
<link rel="stylesheet" href="css/style.css">
<meta name="description" content="">
<meta property="og:title" content="">
<meta property="og:type" content="">
<meta property="og:url" content="">
<meta property="og:image" content="">
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="icon.png">
<link rel="manifest" href="site.webmanifest">
<meta name="theme-color" content="#fafafa">
</head>
<body>
<h1>Hello world!</h1>
<p><?= "This page was rendered on " . date("Y-m-d") ?></p>
<pre><?php
$pairs = [
"hello" => "world!",
"how are" => "you?",
"i like the number" => 3
];
// Iterate over key-value pairs
foreach ($pairs as $k => $v) {
echo "($k, $v) ";
}
echo "\n\n";
// Iterate over keys
foreach (array_keys($pairs) as $key) {
echo "$key: $pairs[$key]\n";
}
echo "\n";
// Iterate over values
foreach ($pairs as $value) {
echo "values = $value\n";
}
?>
</pre>
</body>
</html>

View File

@ -165,6 +165,7 @@ if has ("autocmd")
autocmd BufNewFile *.py 0r ~/.vim/templates/skeleton.py autocmd BufNewFile *.py 0r ~/.vim/templates/skeleton.py
autocmd BufNewFile *.rb 0r ~/.vim/templates/skeleton.rb autocmd BufNewFile *.rb 0r ~/.vim/templates/skeleton.rb
autocmd BufNewFile *.lua 0r ~/.vim/templates/skeleton.lua autocmd BufNewFile *.lua 0r ~/.vim/templates/skeleton.lua
autocmd BufNewFile *.php 0r ~/.vim/templates/skeleton.php
autocmd BufNewFile *.md 0r ~/.vim/templates/skeleton.md autocmd BufNewFile *.md 0r ~/.vim/templates/skeleton.md
autocmd BufNewFile *.html 0r ~/.vim/templates/skeleton.html autocmd BufNewFile *.html 0r ~/.vim/templates/skeleton.html
autocmd BufNewFile *.java 0r ~/.vim/templates/skeleton.java autocmd BufNewFile *.java 0r ~/.vim/templates/skeleton.java

View File

@ -1,9 +0,0 @@
CC=gcc
CFLAGS=-I.
MAIN=hello
nonnull: $(MAIN).o
$(CC) -o $(MAIN) $(MAIN).o
clean:
rm ./*.o

View File

@ -1,5 +0,0 @@
#include <stdio.h>
int main() {
printf("Hello, world!\n");
}

View File

@ -1,7 +0,0 @@
#include <iostream>
using namespace std;
int main() {
cout << "Hello, world!" << endl;
}

View File

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<title>Wow, the title of the new website</title>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#242627">
<meta name="msapplication-TileColor" content="#224679">
<meta name="theme-color" content="#ffffff">
<meta name="description" content="This should be a lovely new description">
</head>
<body>
<h1>Hello, world!</h1>
<p>This is the beginning of a beautiful new website.</p>
</body>
</html>

View File

@ -1,3 +0,0 @@
#!/bin/bash
echo "Hello, world!"