Skip to content

Instantly share code, notes, and snippets.

View codeandbattle's full-sized avatar

Marc Hoover codeandbattle

View GitHub Profile

Keybase proof

I hereby claim:

  • I am codeandbattle on github.
  • I am marc_c_hoover (https://keybase.io/marc_c_hoover) on keybase.
  • I have a public key ASBjHN0Yc_O_HkhUEAg5gAcELA3EAPsZCbewV30UEUbIRAo

To claim this, I am signing this object:

/viewProduct?offer=441302.535158 - WALMART E-GIFT CARDS
@codeandbattle
codeandbattle / Super_simple_password_protection
Last active April 2, 2018 07:20
Super simple PHP password protection.
Add this to the header:
<?php
require('access.php');
?>
Source: http://stackoverflow.com/questions/286938/what-is-the-best-way-to-password-protect-folder-page-using-php-without-a-db-or-u
@codeandbattle
codeandbattle / relative_paths
Created October 6, 2016 07:09
Relative File Paths
Here is all you need to know about relative file paths:
• Starting with "/" returns to the root directory and starts there
• Starting with "../" moves one directory backwards and starts there
• Starting with "../../" moves two directories backwards and starts there (and so on...)
• To move forward, just start with the first subdirectory and keep moving forward
@codeandbattle
codeandbattle / pagination.php
Last active April 2, 2018 07:20
Simple pagination.
$userCount = countUsers(); // Count the amount of users
$per_page = 25; // Change this to the amount of records per page
$total_page = ceil($userCount / $per_page);
$current_page = empty($_GET['page']) ? 1 : $_GET['page'];
$previous_page = $current_page - 1;
$next_page = $current_page + 1;
$myPrev = "<div id='prevlink'><a href='".$_SERVER['PHP_SELF']."?page=$previous_page'>Previous</a></div>";
$myNext = "<div id='nextlink'><a href='".$_SERVER['PHP_SELF']."?page=$next_page'>Next</a></div>";
@codeandbattle
codeandbattle / PHP_Time.php
Last active April 2, 2018 07:20
Working with midnight times and getting number of days from another date
<?
// Setting timezone for Eastern time
date_default_timezone_set("America/New_York");
// Get 4 days ago at midnight
$lastdate = strtotime("-4 days"." 0:00:00");
echo $lastdate."<br>";
// Get last midnight
$midnight = strtotime("today");
@codeandbattle
codeandbattle / PHP_Time2.php
Last active April 2, 2018 07:20
Simple time functions in PHP
<?
//Set timezone to Eastern time
date_default_timezone_set ("America/New_York");
// 1 Hour in Unix time
$onehour = 3600;
// Display the current Unix time
echo time() . "<br>";

Keybase proof

I hereby claim:

  • I am codeandbattle on github.
  • I am marcchoover (https://keybase.io/marcchoover) on keybase.
  • I have a public key whose fingerprint is 02DF E892 0F12 5DAE 7F2A 6D88 7A02 E867 B072 1A42

To claim this, I am signing this object:

@codeandbattle
codeandbattle / roundedcorners_and_shadow.css
Last active April 2, 2018 07:20
CSS box with border-radius and box shadow
.myClass {
font-size: 16px;
display: inline-block;
background: #444;
line-height: 20px;
border: 1px solid #FFF;
padding: 3px;
border-radius: 3px;
box-shadow: -3px 3px 3px #888;
}
@codeandbattle
codeandbattle / JSON_to_array.php
Last active April 2, 2018 07:20
Getting bitcoin price from Blockchain API
<?
$s_url = "https://blockchain.info/ticker";
$j_json = file_get_contents($s_url);
$a_BTC = json_decode($j_json, TRUE);
$a_BTC["USD"]["symbol"] . $a_BTC["USD"]["last"];
?>