Skip to content

Instantly share code, notes, and snippets.

@olzaragoza
olzaragoza / template.cpp
Last active June 26, 2016 22:21
starter cpp template
// simple cpp template
//
// Short description of what your project will do
#include<iostream>
// prototypes go here
int main()
{
@olzaragoza
olzaragoza / sync github repo
Last active June 14, 2016 03:44
git commands to cleanly sync a fork with the original repo without dirtying up the commit history with pull requests
git remote add upstream /url/to/original/repo
git fetch upstream
git checkout master # only needed if not already in master
git rebase upstream/master
git push
also,
git push --tags # to sync tags/releases
<?php
if ( function_exists( 'mail' ) )
{
echo 'mail() is available';
}
else
{
echo 'mail() has been disabled';
}
@olzaragoza
olzaragoza / ShowSourceCode.php
Last active June 12, 2016 05:30
Display the source code of a file with PHP highlighting.
<?php
/* examples of usage:
// in php block
$relativePathToFile = "folder/exampleFile.php";
ShowSourceCode.php?source_file=$relativePathToFile
// as html link
<a href="ShowSourceCode.php?source_file=exampleFile.php" target="blank">View the Source Code</a>
*/
@olzaragoza
olzaragoza / randomTesting()
Created June 17, 2016 03:53
random number testing function
void randomTesting() {
cout << "Random Number Generation Testing" << endl << endl;
cout << "Seeding the number generator... ";
// srand(5); //seed the random number generator with 5
cout << "Done!" << endl;
cout << "Generating 10 random integers..... ";
int extraCount = 0;
while (1) {
vector<int> randVector; //to store the random numbers
@olzaragoza
olzaragoza / rand()
Created June 17, 2016 06:57
C++ rand() function usage examples
random1 = rand() % 10; // range 0 to 9
random2 = rand() % 100 + 1; // range 1 to 100
random3 = rand() % 22 + 1999; // range 1999-2019
@olzaragoza
olzaragoza / update .gitignore
Created June 19, 2016 03:03
git commands to remove newly ignored files from being tracked
git rm -r --cached .
git add .
git commit -m "remove new ignored files"
@olzaragoza
olzaragoza / ascii.php
Last active July 29, 2016 00:33
a simple PHP code block displaying ascii numbers and letters
<?php
// 0-9
echo '<br>ascii(48-57): ';
for ($i = 48; $i <= 57; $i++) {
echo chr($i);
}
// A-Z
echo '<br>ascii(65-90): ';
@olzaragoza
olzaragoza / CSP: browser-sync
Created August 11, 2016 20:05
Content-Security-Policy for developing with Browsersync
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; connect-src http://localhost:3000 ws://localhost:3000; script-src 'sha256-6w7vfY25rjzxRvjgGUXxQWVtH2vipu/5/hnX06LWvHo=' ws://localhost:3000 http://localhost:3000;">