Skip to content

Instantly share code, notes, and snippets.

@billcreswell
billcreswell / jQToC.html
Last active December 14, 2015 03:08
Dynamically generate a table of contents of all #jQueryMobile data-role=pages's?
<!DOCTYPE html>
<head>
<title>Automatically generate table of contents using jQuery </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#toc").append('<p>In this article:</p>')
$("h1[data-role='page']").each(function(i) {
var current = $(this);
@billcreswell
billcreswell / PHPProjectDocumentationHints
Created March 1, 2013 17:04
Setting up Documentation for PHP Projects With Doxygen
Separate subdirectory called "doxygen" for docs
use a dir list script in index.php for projects:
....
foreach($dirlist as $file) {
if ($file["type"] == "dir") {
} else {
@billcreswell
billcreswell / BloggerFBLikeButton
Last active December 17, 2015 08:38
Add FB Like Button to Each Blogger Post
Put the FB Javascript code in the template
This code was retrieved from https://developers.facebook.com/docs/reference/plugins/like/
at the time of this writing.
# Add to the Template:
1 Template/Edit HTML
2 Underneath the <body> tag:
@billcreswell
billcreswell / TimeCardValidRange.php
Created February 8, 2014 12:15
For a time range, like a time card entry, check that input range of time is valid, and check against a table with times entered to avoid overlap; Allow times to "touch" in a minute range.
/**
* @brief Check for Valid Time In and Out
*
* @params arr(in_time, out_time, technichian_id);
* @return json (success,message);
*/
private function isValidRange($params)
{
// validate input
if ($params["in_time"] == "1969-12-31 19:00") die("{'success': false, 'message': 'Incorrect Time In.'}");
<!doctype html>
<head>
<style>
body {font-size:1em; font-family:Droid Sans,Verdana,Helvetica,sans-serif;}
.iwrap { float:left;padding:2px}
.iwrap label {display:block;font-weight:bold;}
.iwrap.border { border:1px #eee solid;padding:2px;margin:4px}
.iwrap.border label {text-align:center}
@billcreswell
billcreswell / application.php
Last active August 29, 2015 13:56
Drop in form for job application
<?php
/**
* @brief: job application for websites
* @created: 2010/07
* @todo: classify
*/
// config
$email = "something@example.com"; // recipient
$site = "unknown";
http://stackoverflow.com/questions/19971428/recursively-search-all-directories-for-an-array-of-strings-in-php?lq=1
$contents_list = array("xyz","abc","hello");
$path = "/tmp/";
$pattern = implode('\|', $contents_list) ;
$command = "grep -r '$pattern' $path";
$output = array();
exec($command, $output);
foreach ($output as $match) {
echo $match . '\n';
<!--http://updates.html5rocks.com/2012/08/Stick-your-landings-position-sticky-lands-in-WebKit->
<style>
body {
margin: 0;
text-align: center;
font-family: sans-serif;
}
.fixed {
position: fixed;
top: 0;
<?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) {
<?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);