Skip to content

Instantly share code, notes, and snippets.

@miwebguy
miwebguy / style.php
Last active August 29, 2015 13:58
PHP CSS Stylesheet with variables and cache headers
<?php
/**
* Adding Cache Headers and ETag to example: http://sperling.com/examples/pcss/
*/
class PHPStyle
{
public static function setHeaders($filename="style.css",$type="text/css")
<?php
$url="http://thehilolowdown.blogspot.com/feeds/posts/default?max-results=1";
$_c = curl_init();
curl_setopt($_c, CURLOPT_URL, $url);
curl_setopt($_c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($_c, CURLOPT_TIMEOUT, 3);
//curl_setopt($_c, CURLOPT_USERPWD, "$_user:$_pass");
//curl_setopt($_c, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$_data = curl_exec($_c);
$response= curl_getinfo($_c);
<?php
function SendNews($to,$subject,$emailText,$emailHtml) {
global $fromName,$fromEmail,$MoPixList;
//TEXT FORMAT
//Plain Text Boundary of Email Message for Non-HTML browsers
$message="
--==Multipart_Boundary_xc75j85x
@miwebguy
miwebguy / PHPTableOfContents.php
Created April 25, 2014 16:21
Create PHP Table of Contents from Headers in HTML String
<?php
/**
* Use whatever method you like to grab your HTML string. We'll use a site I mentioned in this post
* as an example.
*/
$remote_site_data = file_get_contents('http://www.10stripe.com/articles/automatically-generate-table-of-contents-php.php');
$dom_document = new DomDocument();
@$dom_document->loadHTML($remote_site_data);
$headers = $dom_document->getElementsByTagName('h2');
foreach ($headers as $header) {
@miwebguy
miwebguy / namedparameters.php
Created September 4, 2014 19:13
Faking PHP Named Parameters
<?php
/**
* http://philsturgeon.uk/blog/2013/09/named-parameters-in-php
*/
public function getFriends($args)
{
$args += [
'user_id' => null,
'screen_name' => null,
'cursor' => -1,
@miwebguy
miwebguy / validymd.php
Last active August 29, 2015 14:09
Check Valid Y-m-d
<?php
/**
* Check for Valid Date Entry
*/
public function validDateString($datestring)
{
if(!preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$datestring)
|| date("Y-m-d", strtotime($datestring))!=$datestring)
return false;
else
@miwebguy
miwebguy / CheckYYYY-MM-DD.php
Created January 14, 2015 15:46
Check Date Format Front and Back
/**Check Date Input on Server**/
$date_regex = '/^(19|20)\d\d[\-\/.](0[1-9]|1[012])[\-\/.](0[1-9]|[12][0-9]|3[01])$/';
// Check date input
if(isset($_POST['start'])) {
if (preg_match($date_regex,$_POST['start']) && preg_match($date_regex,$_POST['end'])) {
$_start = $_POST['start'];
$_end = $_POST['end'];
} else {
die("Invalid Date Format");
}
@miwebguy
miwebguy / ucword.js
Last active August 29, 2015 14:20
Uppercase word in Javascript
//
// because I like to Captilize Id's
// <span='Name'><label><input name='name'/></label></span
//
var TSD = {};// my object
TSD.ucword = function(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

#Post OpenSUSE / Gnome Install List

Basic

  • add keys
  • Setup proxy if necessary
  • Add packman repo

Appearance

  • Remove OO, Music and Music from Favorites
@miwebguy
miwebguy / CoderQuotes
Created February 26, 2016 15:37
Coder Quotes
"A wise coder once said: “When I commit my code, only God and I know what it does. After a while, only God knows."
Quoted by Remi Woler http://www.sitepoint.com/preventing-code-rot-101-unit-testing/