Skip to content

Instantly share code, notes, and snippets.

View walterdavis's full-sized avatar

Walter Lee Davis walterdavis

View GitHub Profile
<!-- PHP -->
<?php echo date('Y'); ?>
<div id="item4">
<p>
Last Name <input type="text" name="lastname[]" value=""/>
First Name <input type="text" name="firstname[]" value=""/>
Pronunciation <input type="text" name="pronunciation[]" value=""/>
</p>
<p>
Last Name <input type="text" name="lastname[]" value=""/>
First Name <input type="text" name="firstname[]" value=""/>
Pronunciation <input type="text" name="pronunciation[]" value=""/>
$('addMore').observe('click',function(evt){
evt.stop();
var template = '<p>Last Name <input type="text" name="lastname[]" value=""/> First Name <input type="text" name="firstname[]" value=""/> Pronunciation <input type="text" name="pronunciation[]" value=""/></p>';
var insertPoint = this.up('p');
(5).times(function(){
insertPoint.insert({before:template});
});
});
<?php
require_once('lib/config.inc.php');
$page_title = $page_header = SITE_NAME;
if(isset($_SESSION['flash'])){
$flash = $_SESSION['flash'];
unset($_SESSION['flash']);
}
$out = '<p><a href="?action=login">Log in</a>, or <a href="?action=register">register here</a> to use the members-only features of this site.</p>';
if(isset($_SESSION['current_user'])){
if($_user = ActiveRecord::FindCookie()){
@walterdavis
walterdavis / gist:596937
Created September 25, 2010 15:18
A quickie source view for files, using the PHP stream wrappers for file_get_contents()
<?php
$out = '';
if(isset($_GET['src']) && !empty($_GET['src']) && strstr($_GET['src'],'..') === false){
if(file_exists('./' . $_GET['src'])){
$out = file_get_contents('./' . $_GET['src']);
}else{
$out = 'error traversing filesystem';
}
}elseif(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $_SERVER['REQUEST_URI']){
$out = file_get_contents($_SERVER['HTTP_REFERER']);
var list = $$('#yourBox li');
list.each(function(elm){
elm['keys'] = elm.innerHTML.stripTags().toLowerCase();
});
var lastValue = $F("filter");
$('filter').observe('keyup', function(e) {
var value = this.value.toLowerCase();
if (value !== lastValue) {
list.each(function(elm) {
if (elm.keys.include(value)) {
var f = $('yourFooterName');
var t = f.getHeight();
var y = document.viewport.getHeight();
var h = document.viewport.getScrollOffsets()[1];
if (Prototype.Browser.MobileSafari) h = window.pageYOffset;
f.setStyle({"top":parseInt(y - t + h,10).toString() + "px"});
Event.observe(window,"scroll",function(evt){
var y = document.viewport.getHeight();
var h = document.viewport.getScrollOffsets()[1];
if (Prototype.Browser.MobileSafari) h = window.pageYOffset;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6/prototype.js"></script>
<title>Placeholder Text</title>
<script type="text/javascript" charset="utf-8">
@walterdavis
walterdavis / document.rb
Created October 19, 2010 22:45
This pair of code-bits convert a PDF to plain text using the ancient pdftotext library.
#models/document.rb
class Document < ActiveRecord::Base
has_attached_file :pdf,:styles => { :text => { :fake => 'variable' } }, :processors => [:text]
#more class stuff here
end
function SetCSSAttribute(tag, attributeName, attributeValue) {
// Sets a "CSS" attribute such as "position:absolute" in a tag value
// Passing an attribute value of null removes that attribute entirely
if (tag==null) return;
var tagField = tag['style'];
if (tagField == null){
tag['style'] = '"'+attributeName+':'+attributeValue+'"';
}else{
var tagField = tagField.toString();
var pairs = tagField.slice(1,-1).split(';');