pixelhandler

Pushin' & pullin' pixels on the net

searchText() jQuery Plugin to Add Helper Text in Search Input

This jQuery plugin script added text to an input field in a search form. The defaults are set to the IDs used in a WordPress search form. The behavior can be set to force clearing of text every time user causes focus event to fire in text input (clicks to type). The function tirggers the focus event to start off with the helper text in the input field. Demo and Qunit tests

Simple PHP Skinning Scripts Using Basic Template Class

This example is based on a MAMP environment with DNS setup for a .local domain, using MAMP apache’s httpd.conf to set up vhosts; notes on this are in the index.php file. Source code on github : http://github.com/pixelhandler/simplephpskinner

Files used to create simple skinning scripts

  • css
  • style.css
  • includes
    • body_bottom.phtml
    • body_top.phtml
    • class_template.php
    • config.php
    • footer.phtml
    • head.phtml
    • topnav.phtml
    • tracking.phtml
  • index.php
  • js
    • jquery.plugins.js
    • tail.js
  • Use Ruby Gem, Sass to Generate a CSS Grid Layout

    This is a basic template tool for generating your own grid system using Sass, and builds on best practices of existing CSS grid systems like 960.gs or Blueprint in a bare bones fashion. The generated CSS includes classes for prototyping or designing in a browser; and also creates variables for assignment to your semantic id’s for cleaner markup.

    Ruby Block to Create Random Token String Without Offending

    In creating rant.cc as a short URL generator I wanted to avoid generating random text that would be offensive, so the block below attempts to avoid creating some text string you may have to apologize to your mother about.
    Create random token with Ruby (random_token.rb) download
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    def random_token
    characters = 'BCDFGHJKLMNPQRSTVWXYZbcdfghjkmnpqrstvwxyz23456789-_'
    temp_token = ''
    srand
    TOKEN_LENGTH.times do
    pos = rand(characters.length)
    temp_token += characters[pos..pos]
    end
    temp_token
    end

    Import a URL With Ruby

    Simple blocks to use as a method to import a url in a rails app, like using content from another api
    import HTML with Ruby (importHTML.rb) download
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
    def importHTML
    require 'open-uri'
    @source = open("http://domain.com/some.html").read
    end
    # uses a reference parameter when getting remote XML
    def importXML
    require 'open-uri'
    @aclass = AClass.find(params[:id]) # expecting a param named ref
    @content = open("http://domain.com" + @aclass.ref + "&type=xml").read
    respond_to do |format|
    format.xml { render :xml => @content }
    end
    end

    Clean Up Directories Prior to Initializing Repository

    Use command line to clean up directories prior to initializing repository :
    • remove junk like .DS_Store or clean out repositories like folders named CVS .svn .git
    • -type d for directories f for files
    find . -name '.svn' -type d | xargs echo
    
    find . -name '.svn' -type d | xargs rm -rf
    
    find . -name '.git' -exec rm -rf {} ;
    
    find . -name '.DS_Store' -type f | xargs rm -rf