Skip to content

Instantly share code, notes, and snippets.

View steveobbayi's full-sized avatar

Steve Obbayi steveobbayi

View GitHub Profile
<?php
echo base64_encode(file_get_contents("images/arrow.png"));
?>
<?php
// validate input is from the form.
// Note: no other validations have been done
if ($_POST["page2control"] == "authorized")
{
?>
<form id="page2form" target="iframe-name" method="post" action="process-form-data.php">
<input name="text" value="<?= $_POST['text'] ?>">
</form>
<!-- the javascript to repost the form -->
<form action="Page2.php" method="post">
<label for="text">Input Label:</label>
<input type="text" name="text" id="text">
<input type="hidden" name="page2control" value="authorized">
<input type="submit" value="Submit">
</form>
<form action="iframe-source.php" target="iframe-name" method="post">
<label for="text">Input Label:</label>
<input type="text" name="text" id="text">
<input type="submit" value="Submit">
</form>
<!-- some more HTML here. -->
<iframe name="iframe-name" src="iframe-source.php"></iframe>
<?php // custom WordPress database error page
// Tell the browser that there is a bit of a mess on the server
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 600'); // in seconds = 10 minutes
// You can send yourself an email notification
mail("your@email.com", "Database Connection Error", "Problem with the database! Come fix me!", "From: My Website's DB");
// Put out the customized friendly template that matches your website
?>
<link rel="stylesheet" type="text/css" href="screen.css" media="screen">
<link rel="stylesheet" type="text/css" href="print.css" media="print">
vector<int> src = {2,5,3}; // our source of data
vector<int> src2 = {7,8,9}; // 2nd source of data
vector<int> dest = {0,0,0,0,0,0,0,0,0,0}; // array to be modified
// Lets exchange contents of src and src2
swap_rages(src.begin(), src.end(),src2.begin());
// src2 is now contents of src while
// src is now contents or src2
//lets move src to the end of dest assuming its redefined
vector<int> src = {2,5,3}; // our source of data
vector<int> dest = {0,0,0,0,0,0,0,0,0,0}; // array to be modified
// Lets move all of src to dest
move(src.begin(), src.end(),dest.begin());
// dest is now {2,5,3,0,0,0,0,0,0,0}
// src is now undefined
//lets move src to the end of dest assuming its redefined
move_backward(src.begin(), src.end(),dest.end());
vector<int> src = {2,5,3}; // our source of data
vector<int> dest = {0,0,0,0,0,0,0,0,0,0}; // array to be modified
// Lets copy all of src to dest
copy(src.begin(), src.end(),dest.begin());
// dest is now {2,5,3,0,0,0,0,0,0,0}
// lets copy part of src to dest
copy_n(src.begin(), 2, dest.begin());
// dest is now {2,5,0,0,0,0,0,0,0,0}
...
vector<int> v = {2,5,3,6,4,8,5,9,6,1,7,3,12,14,25};
int a = minmax_element(v.begin(), v.end());
// The value of "a.fist" above is 1
// The value of "a.second" above is 25