tomdowning/WP all query options ( PHP)
offset - start from post number
orderby - order by id,author,title,date,modified,parent,rand,menu_order,meta_value
order - ASC,DESC
author - show posts from one author, use author id or name
cat (int) - use category id.
category_name (string) - use category slug (NOT name).
category__and (array) - use category id.
category__in (array) - use category id.
category__not_in (array) - use category id.
tag (string) - use tag slug.
tag_id (int) - use tag id.
tag__and (array) - use tag ids.
tag__in (array) - use tag ids.
tag__not_in (array) - use tag ids.
tag_slug__and (array) - use tag slugs.
tag_slug__in (array) - use tag slugs.
tax_query (array) - use taxonomy parameters (available with Version 3.1).
taxonomy (string) - Taxonomy.
field (string) - Select taxonomy term by ('id' or 'slug')
terms (int/string/array) - Taxonomy term(s).
operator (string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
p (int) - use post id.
name (string) - use post slug.
page_id (int) - use page id.
pagename (string) - use page slug.
post_parent (int) - use page id. Return just the child Pages.
post__in (array) - use post ids. Specify posts to retrieve.
post__not_in (array) - use post ids. Specify post NOT to retrieve.
post_type (string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
'post' - a post.
'page' - a page.
'revision' - a revision.
'attachment' - an attachment. The default WP_Query sets 'post_status'=>'published', but attachments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
'any' - retrieves any type except revisions and types with 'exclude_from_search' set to true.
post_status (string / array) - use post status. Retrieves posts by Post Status, default value is 'publish'.
'publish' - a published post or page.
'pending' - post is pending review.
'draft' - a post in draft status.
'auto-draft' - a newly created post, with no content.
'future' - a post to publish in the future.
'private' - not visible to users who are not logged in.
'inherit' - a revision. see get_children.
'trash' - post is in trashbin (available with Version 2.9).
'any' - retrieves any status except those from post types with 'exclude_from_search' set to true.
meta_key (string) - Custom field key.
meta_value (string) - Custom field value.
meta_compare (string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.
meta_query (array) - Custom field parameters (available with Version 3.1).
key (string) - Custom field key.
value (string|array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
compare (string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
type (string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
beneberle/mySQL UNIX cheat sheet ( MySQL)
Selecting a database:
mysql> USE database;
Listing databases:
mysql> SHOW DATABASES;
Listing tables in a db:
mysql> SHOW TABLES;
Describing the format of a table:
mysql> DESCRIBE table;
Creating a database:
mysql> CREATE DATABASE db_name;
Creating a table:
mysql> CREATE TABLE table_name (field1_name TYPE(SIZE), field2_name TYPE(SIZE));
Ex: mysql> CREATE TABLE pet (name VARCHAR(20), sex CHAR(1), birth DATE);
Load tab-delimited data into a table:
mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table_name;
(Use \n for NULL)
Inserting one row at a time:
mysql> INSERT INTO table_name VALUES ('MyName', 'MyOwner', '2002-08-31');
(Use NULL for NULL)
Retrieving information (general):
mysql> SELECT from_columns FROM table WHERE conditions;
All values: SELECT * FROM table;
Some values: SELECT * FROM table WHERE rec_name = "value";
Multiple critera: SELECT * FROM TABLE WHERE rec1 = "value1" AND rec2 = "value2";
Reloading a new data set into existing table:
mysql> SET AUTOCOMMIT=1; # used for quick recreation of table
mysql> DELETE FROM pet;
mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table;
Fixing all records with a certain value:
mysql> UPDATE table SET column_name = "new_value" WHERE record_name = "value";
Selecting specific columns:
mysql> SELECT column_name FROM table;
Retrieving unique output records:
mysql> SELECT DISTINCT column_name FROM table;
Sorting:
mysql> SELECT col1, col2 FROM table ORDER BY col2;
Backwards: SELECT col1, col2 FROM table ORDER BY col2 DESC;
Date calculations:
mysql> SELECT CURRENT_DATE, (YEAR(CURRENT_DATE)-YEAR(date_col)) AS time_diff [FROM table];
MONTH(some_date) extracts the month value and DAYOFMONTH() extracts day.
Pattern Matching:
mysql> SELECT * FROM table WHERE rec LIKE "blah%";
(% is wildcard - arbitrary # of chars)
Find 5-char values: SELECT * FROM table WHERE rec like "_____";
(_ is any single character)
Extended Regular Expression Matching:
mysql> SELECT * FROM table WHERE rec RLIKE "^b$";
(. for char, [...] for char class, * for 0 or more instances
^ for beginning, {n} for repeat n times, and $ for end)
(RLIKE or REGEXP)
To force case-sensitivity, use "REGEXP BINARY"
Counting Rows:
mysql> SELECT COUNT(*) FROM table;
Grouping with Counting:
mysql> SELECT owner, COUNT(*) FROM table GROUP BY owner;
(GROUP BY groups together all records for each 'owner')
Selecting from multiple tables:
(Example)
mysql> SELECT pet.name, comment FROM pet, event WHERE pet.name = event.name;
(You can join a table to itself to compare by using 'AS')
Currently selected database:
mysql> SELECT DATABASE();
Maximum value:
mysql> SELECT MAX(col_name) AS label FROM table;
Auto-incrementing rows:
mysql> CREATE TABLE table (number INT NOT NULL AUTO_INCREMENT, name CHAR(10) NOT NULL);
mysql> INSERT INTO table (name) VALUES ("tom"),("dick"),("harry");
Adding a column to an already-created table:
mysql> ALTER TABLE tbl ADD COLUMN [column_create syntax] AFTER col_name;
Removing a column:
mysql> ALTER TABLE tbl DROP COLUMN col;
(Full ALTER TABLE syntax available at mysql.com.)
Batch mode (feeding in a script):
# mysql -u user -p < batch_file
(Use -t for nice table layout and -vvv for command echoing.)
Alternatively: mysql> source batch_file;
Backing up a database with mysqldump:
# mysqldump --opt -u username -p database > database_backup.sql
(Use 'mysqldump --opt --all-databases > all_backup.sql' to backup everything.)
(More info at MySQL's docs.)
lister/Mailchimp HTMLEmail Basic Code Template ( Other)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Announcing Cool New Stuff</title>
<style type="text/css" media="screen">
/**
* @tab Page
* @section background
* @tip Specify a color for all the hyperlinks in your email.
* @theme link
*/
body {
/*@editable*/ background-color: #314a66;
margin: 0;
padding: 0;
}
/**
* @tab Page
* @section link style
* @tip Specify a color for all the hyperlinks in your email.
* @theme link
*/
a, a:link, a:visited {
/*@editable*/ color: #336699;
/*@editable*/ text-decoration: underline;
/*@editable*/ font-weight: normal;
}
/**
* @tab Header
* @section header bar
* @tip Choose a set of colors that look good with the colors of your logo image or text header.
*/
#header {
/*@editable*/ background-color: #314a66;
/*@editable*/ color: #FFFFFF;
/*@editable*/ font-family: Helvetica;
/*@editable*/ font-weight: normal;
/*@editable*/ text-align: center;
}
/**
* @tab Header
* @section primary heading
* @tip Choose a set of colors that look good with the colors of your logo image or text header.
*/
#header .primary-heading {
/*@editable*/ font-size: 40px;
/*@editable*/ font-weight: bold;
/*@editable*/ color: #FFFFFF;
/*@editable*/ font-family: Helvetica;
/*@editable*/ margin: 0;
}
/**
* @tab Header
* @section secondary heading
* @tip Choose a set of colors that look good with the colors of your logo image or text header.
*/
#header .secondary-heading {
/*@editable*/ color:#EEEEEE;
/*@editable*/ margin-top: 7px;
/*@editable*/ font-size: 14px;
/*@editable*/ font-weight: normal;
}
/**
* @tab Body
* @section content area
* @tip This is the default text style for the body of your email.
* @theme content
*/
#content {
margin: 0;
/*@editable*/ font-size: 12px;
/*@editable*/ color: #555555;
/*@editable*/ font-style: normal;
/*@editable*/ font-weight: normal;
/*@editable*/ font-family: Helvetica;
/*@editable*/ line-height: 1.6em;
/*@editable*/ padding: 0px 30px 0;
}
/**
* @tab Body
* @section title
* @tip This is the byline text that appears immediately underneath your titles/headlines.
* @theme subtitle
*/
#content .title {
/*@editable*/ font-size: 20px;
/*@editable*/ font-weight: bold;
/*@editable*/ color: #333333;
/*@editable*/ font-style: normal;
/*@editable*/ font-family: Helvetica;
/*@editable*/ margin: 15px 0 10px 0;
/*@editable*/ text-align: left;
padding: 0;
}
/**
* @tab Body
* @section subtitle
* @tip This is the byline text that appears immediately underneath your titles/headlines.
* @theme subtitle
*/
#content .subTitle {
/*@editable*/ font-size: 16px;
/*@editable*/ font-weight: bold;
/*@editable*/ color: #333333;
/*@editable*/ font-style: normal;
/*@editable*/ font-family: Helvetica;
/*@editable*/ margin: 15px 0 5px 0;
/*@editable*/ text-align: left;
padding: 0;
}
/**
* @tab Body
* @section copy
* @tip This is the byline text that appears immediately underneath your titles/headlines.
* @theme subtitle
*/
#content .copy {
/*@editable*/ margin:0 0 15px 0;
/*@editable*/ line-height:1.6em;
/*@editable*/ font-size:12px;
}
/**
* @tab Body
* @section lower links
* @tip This is the byline text that appears immediately underneath your titles/headlines.
* @theme subtitle
*/
#footer_links {
/*@editable*/ text-align:center;
/*@editable*/ padding-top:20px;
/*@editable*/ font-size:12px;
}
/**
* @tab Footer
* @section footer
* @tip You might give your footer a light background color and separate it with a top border
* @theme footer
*/
#footer {
background-color: #314a66;
/*@editable*/ padding: 20px;
/*@editable*/ font-size: 10px;
/*@editable*/ color: #ccc;
/*@editable*/ line-height: 150%;
/*@editable*/ font-family: Verdana;
/*@editable*/ text-align:center;
}
/**
* @tab Footer
* @section link style
* @tip Specify a color for your footer hyperlinks.
* @theme link_footer
*/
#footer a {
/*@editable*/ color: #cc6757;
/*@editable*/ text-decoration: underline;
/*@editable*/ font-weight: normal
}
/* Static Styles */
#layout{margin:0px auto;text-align:left;border-collapse:collapse;background:#ffffff;}
.rounded{margin:0;padding:0;line-height:8px;}
#social strong{padding:0 10px;}
#social{line-height:1.5em;}
#social img{margin-right:3px;margin-top:5px;position:relative;top:3px;}
#social a{text-decoration:none;}
#share{margin-top:15px;}
#can-spam{width:70%;margin:auto;}
#can-spam td{padding:10px;text-align:left;font-size:12px;color:#ddd;}
#copyright{font-size:10px;font-style:italic;}
#social,#contact,#share{margin-bottom:20px;font-size:11px;}
#social h2,#contact h2,#share h2{margin-top:0;text-transform:uppercase;font-size:12px;letter-spacing:1px;border-bottom:1px dotted #ccc;color:#333;margin-bottom:10px;}
#product-table{display:block;border:1px dotted #ddd;border-left:0;border-right:0;margin:15px 0;padding-bottom:15px;}
#product-table h3{font-size:12px;}
#product-table p.copy{font-size:11px;}
#footer_links{}
#product-table td{padding-right:8px;}
</style>
</head>
<body>
<table id="layout" border="0" cellspacing="0" cellpadding="0" width="757">
<tr>
<td id="header" style="background:#314a66 url(http://gallery.mailchimp.com/799706b3fccc214a076b1ad13/images/header.9.jpg) no-repeat; height:164px;">
<h1 class="primary-heading" mc:edit="email-header">
Announcing New Features
</h1>
<h2 class="secondary-heading" mc:edit="copy">
We've just released a slew of awesome new features on our site...
</h2>
</td>
</tr>
<tr>
<td id="content">
<table id="content-grid" width="100%">
<tr>
<td style="vertical-align:top; padding-right:30px;" width="550" valign="top" mc:edit="">
<h1 class="title">
Super Awesome News!
</h1>
<p class="copy">
Uniquely deploy excellent services vis-a-vis emerging architectures. Continually conceptualize orthogonal partnerships through client-centered portals. Progressively harness focused strategic theme areas with e-business technologies. Nunc auctor bibendum eros. Maecenas porta accumsan mauris. Etiam enim enim, elementum sed, bibendum quis, rhoncus non, metus. Fusce neque dolor, adipiscing sed, consectetuer et, lacinia sit amet, quam. Suspendisse wisi quam, consectetuer in, blandit sed, suscipit eu, eros. Etiam ligula enim, tempor ut, blandit nec.
</p>
<h2 class="subTitle">
Other Stuff
</h2>
<p class="copy">
Assertively productivate open-source meta-services and pandemic collaboration and idea-sharing. Conveniently integrate emerging growth strategies through robust data. Synergistically optimize cross-unit testing procedures without vertical channels. Conveniently parallel task interactive action items without team building web-readiness. Efficiently reintermediate customer directed catalysts for change whereas revolutionary methods of empowerment. Objectively redefine resource sucking technologies before ubiquitous schemas.
</p>
<p class="copy">
Progressively formulate timely technology after backend growth strategies. Authoritatively innovate superior niche markets before goal-oriented channels. Collaboratively pursue transparent platforms and error-free e-business. Dynamically plagiarize cross-platform methodologies without goal-oriented solutions. Energistically exploit user-centric benefits vis-a-vis compelling metrics. Dramatically plagiarize robust services before collaborative meta-services.
</p>
<p class="copy">
Assertively unleash competitive total linkage rather than robust channels. Appropriately redefine efficient core competencies for distinctive expertise. Distinctively underwhelm market-driven relationships without an expanded array of alignments.
</p>
<p class="copy">
Interactively drive dynamic deliverables vis-a-vis interactive potentialities. Continually facilitate vertical models rather than extensible expertise. Phosfluorescently supply customized systems before best-of-breed total linkage.
</p>
<p class="copy">
Interactively matrix business e-commerce for intuitive intellectual capital.
</p>
</td>
<td style="vertical-align:top; padding-top:20px;" width="180" valign="top">
<div id="social" mc:edit="social">
<h2>
Connect with us:
</h2><a rel="external" title="Follow us on Twitter!" href="http://twitter.com/mailchimp" target="_blank"><img width="16" height="16" border="0" alt="Follow us on Twitter!" src="http://www.mailchimp.com/img/icons/Twitter-24x24.png" />Follow us on Twitter</a><br />
<a rel="external" title="Follow us on Twitter!" href="http://www.facebook.com/pages/MailChimp/43929265776" target="_blank"><img width="16" height="16" border="0" alt="Follow us on Facebook!" src="http://www.mailchimp.com/img/icons/FaceBook-24x24.png" />Become a fan</a><br />
<a title="Read the MailChimp blog" href="http://www.mailchimp.com/blog/"><img width="16" height="16" border="0" alt="Read the MailChimp blog" src="http://www.mailchimp.com/img/icons/rss.png" />Read our blog</a><br />
<a rel="external" title="Learn MailChimp on iTunes" href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=306802337" target="_blank"><img width="16" height="16" border="0" alt="Learn MailChimp on iTunes" src="http://www.mailchimp.com/img/icons/itunes.png" />Watch our podcast</a>
</div>
<div id="share" mc:edit="share">
<h2>
Share this email:
</h2>*|MC:SHARE|*
</div>
<div id="contact" mc:edit="contact">
<h2>
Contact Us:
</h2>*|HTML:LIST_ADDRESS_HTML|*
</div>
</td>
</tr>
<tr>
<td colspan="2" id="footer_links" mc:edit="footer_links">
<p>
<a href="*|ARCHIVE|*" class="adminText">view email in browser</a> | <a href="*|UNSUB|*">unsubscribe</a> | <a href="*|UPDATE_PROFILE|*">update your profile</a> | <a href="*|FORWARD|*">forward to a friend</a>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="footer" mc:edit="footer">
<p>
*|LIST:DESCRIPTION|*
</p>*|REWARDS|*
<p id="copyright">
Copyright (C) 2009 *|LIST:COMPANY|* All rights reserved.
</p>
</td>
</tr>
</table>
</body>
</html>
nerdfiles/CSS New Doc (Two-column) ( CSS)
@charset "utf-8";
/*
* Author: Aaron Alexander (nerdfiles.net)
*/
/* Kill defaults */
/*-----------------------------------------------------------------------------------*/
* { margin: 0; padding: 0; border: none; outline: 0; list-style: none; vertical-align: baseline; }
/* Definitions */
/*-----------------------------------------------------------------------------------*/
body { font: 12px Helvetica; line-height: 1.5em; }
/* Common elements (block) */
/*-----------------------------------------------------------------------------------*/
h1 { }
h2 { }
h3 { }
h4 { }
h5 { }
h6 { }
form { }
input { }
ul { }
ul li { }
ol { }
ol li { }
dl { }
dt { }
dd { }
table { border: 0px; border-collapse: collapse; border-spacing: 0px; }
caption { }
table td, table th { margin: 0px; padding: 0.1em; empty-cells: show; vertical-align: top; }
table tr { }
p { margin: 0.5em 0; }
blockquote { }
blockquote p { }
address { font-style: normal; }
acronym, abbr { border-bottom: 1px #000 dashed; cursor: help; }
/* Common elements (inline) */
/*-----------------------------------------------------------------------------------*/
img { border: none; }
input { }
label { }
span { }
/* Hyperlinks */
/*-----------------------------------------------------------------------------------*/
a { text-decoration: none; }
a:hover { }
a img { border: none; }
/* Classes for those who like to overcompensate (General global classes) */
/*-----------------------------------------------------------------------------------*/
.clear { clear: both; }
.clear-left { clear: left; }
.clear-right { clear: right; }
.clear-hack:after { content: "clear"; clear: both; display: block; visibility: hidden; height: 0; }
.float-left { float: left; }
.float-right { float: right; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-justify { text-align: justify; }
.bold { font-weight: bold; }
.italic { font-style: italic; }
.underline { border-bottom: 1px solid; }
.highlight { background: #ffc; }
.img-left { float: left; margin: 0.2em 1em 0.2em 0; }
.img-right { float: right; margin: 0.2em 0 0.2em 1em; }
.nopadding { padding: 0; }
.noindent { margin-left: 0; padding-left: 0; }
.nobullet { list-style: none; list-style-image: none; }
.alignright { float: right; }
.alignright { float: left; }
/* Local classes */
/*-----------------------------------------------------------------------------------*/
/* #jacket (wrapper) */
/*-----------------------------------------------------------------------------------*/
#jacket { width: 960px; margin: 0 auto; }
/* #header */
/*-----------------------------------------------------------------------------------*/
#header { }
/* #nav */
/*-----------------------------------------------------------------------------------*/
#nav { }
/* #container */
/*-----------------------------------------------------------------------------------*/
#container { }
/* #content */
/*-----------------------------------------------------------------------------------*/
#content { }
/* #sidebar */
/*-----------------------------------------------------------------------------------*/
#sidebar { }
/* #feets */
/*-----------------------------------------------------------------------------------*/
#feets { }
LeeProbert/Spark Animation and Easing classes usage ( MXML)
/*
Some code used in a project for scaling and moving an object around. Properties of the tweens are bound to properties of the class.
USAGE : In your actionscript you just need to refer to the class id like so shirtMoveToNoScale.play(); you can also use Actionscript to set listeners, handlers etc.
*/
<fx:Declarations>
<s:Power id="powerEase" />
<s:Move
id="shirtMoveToNoScale"
target="{this}"
duration="500"
easer="{powerEase}"
xTo="{moveToPointX}"
yTo="{moveToPointY}"
/>
<s:Parallel
id="shirtMoveTo"
target="{this}"
effectEnd="autoZoomMoveEnd(event)"
duration="500"
>
<s:Scale
easer="{powerEase}"
scaleXTo="{Config.SHIRT_ZOOM_SCALE}"
scaleYTo="{Config.SHIRT_ZOOM_SCALE}"
/>
<s:Move
easer="{powerEase}"
xTo="{moveToPointX}"
yTo="{moveToPointY}"
/>
</s:Parallel>
<s:Parallel
id="shirtScaleUp"
target="{this}"
effectEnd="resetShirtWidthHeight(event)"
duration="500"
>
<s:Scale
easer="{powerEase}"
scaleXTo="{Config.SHIRT_ZOOM_SCALE}"
scaleYTo="{Config.SHIRT_ZOOM_SCALE}"
/>
<s:Move
easer="{powerEase}"
xTo="{Config.ZOOM_IN_X}"
yTo="{Config.ZOOM_IN_Y}"
/>
</s:Parallel>
<s:Parallel
id="shirtScaleDown"
target="{this}"
effectEnd="resetShirtWidthHeight(event)"
duration="500"
>
<s:Scale
target="{this}"
easer="{powerEase}"
scaleXTo="{Config.SHIRT_START_SCALE}"
scaleYTo="{Config.SHIRT_START_SCALE}"
/>
<s:Move
easer="{powerEase}"
xTo="{Config.ZOOM_OUT_X}"
yTo="{Config.ZOOM_OUT_Y}"
/
</s:Parallel>
Here's some example of how to apply Spark easing classes using MXML
ksaver/A simple timer to apply The Pomodoro Technique ( Bash)
#! /usr/bin/env bash
# File: tomatoe.sh
# What the..?: A simple timer to apply The Pomodoro Technique.
# Who the..?: ksaver (at identi.ca).
# Why? : In the Hope of this little script can be useful...
# When?: July 2010.
# Requieres: bash, play, zenity (nix like OS, of course).
# More Info: http://www.pomodorotechnique.com
# License: Public Domain.
# Not any warranty at all.
#---------------------------------------------------------------
scriptname=$(basename $0 .sh)
scriptvers='0.6'
## --- Set preferences ---
minute=60 # Secs in one min. 60 (habitually).
m_resting=5 # Resting time. Default 05 minutes.
m_working=25 # Working time. Default 25 minutes.
s_resting=$(($m_resting*$minute)) # seconds to resting.
s_working=$(($m_working*$minute)) # seconds to working.
audio_warning="/home/$USER/Audio/attention.wav" # some cute audio warning.
## -----------------------
function starting_dialog()
{
zen_dialog --title "$scriptname - $scriptvers" --question \
--text="Starting Tomatoe Timer:\
\n$m_working Mins Working/$m_resting Mins Resting."
return $?
}
function tomatoe_timer()
{
TASK=$1
LIMIT=$2
COUNT=0
while [ $COUNT -lt $LIMIT ]
do
echo $(($COUNT*100/$LIMIT)) # % percentage %
let COUNT=$COUNT+1
sleep 1
done | zen_dialog --title="Cycles: $count_cycle" --progress --auto-close \
--text="Time to $TASK ($(($LIMIT/$minute)) Mins)...\t"
return $?
}
function zen_alert()
{
play "$audio_warning" & # Decomment if you want a sound warning.
zen_dialog --title="Cycles: $count_cycle" --question \
--text="Time to $1 has Finished!\nShall I Continue?"
return $?
}
function zen_dialog()
{
/usr/bin/env zenity "$@"
}
function __main__()
{
count_cycle=1
starting_dialog || exit
while true
do
tomatoe_timer "Working" $s_working
zen_alert "Working" || exit
tomatoe_timer "Slacking" $s_resting
zen_alert "Slacking" || exit
let count_cycle=$count_cycle+1
done
}
## Run script...
__main__
Nerdlr/Default style sheet for FriendFeed Widget ( CSS)
.friendfeed.widget,
div.friendfeed.widget div,
div.friendfeed.widget span,
div.friendfeed.widget img,
div.friendfeed.widget table,
div.friendfeed.widget tr,
div.friendfeed.widget td {
position: relative;
background-color: white;
color: black;
padding: 0;
margin: 0;
border: 0;
text-align: left;
line-height: 1.3em;
width: auto;
float: none;
}
.friendfeed.widget {
color: #222222;
font-family: Arial, sans-serif;
font-size: 10pt;
position: relative;
border: 1px solid #437ec7;
overflow: hidden;
}
.friendfeed.widget a {
background: none;
color: #1030cc;
font-weight: normal;
text-decoration: underline;
margin: 0;
padding: 0;
}
.friendfeed.widget a:visited {
color: #1030cc;
}
.friendfeed.widget div {
margin: 0;
padding: 0;
border: 0;
}
.friendfeed.widget img {
border: 0px;
}
.friendfeed.widget .logo {
background: url("../images/widget-top-border.png?v=1") 0px 0px repeat-x;
}
.friendfeed.widget .logo img {
margin-left: 5px;
}
.friendfeed.widget .feed {
padding-left: 12px;
padding-right: 12px;
margin-top: 10px;
margin-bottom: 10px;
}
.friendfeed.widget .bottom {
background: #cddff6 url("../images/widget-bottom-bg.png?v=1") repeat-x;
border-top: 1px solid #437ec7;
padding: 3px 5px 3px 5px;
}
.friendfeed.widget .bottom a {
font-weight: bold;
text-decoration: none;
}
.friendfeed.widget .bottom a:visited {
color: #1030cc;
}
.friendfeed.widget .clear {
clear: both;
}
.friendfeed.widget img.icon {
width: 16px;
height: 16px;
}
.friendfeed.widget .feed .cluster {
margin-bottom: 1.75em;
}
.friendfeed.widget .feed .cluster .icon {
float: left;
}
.friendfeed.widget .feed .cluster .body {
margin-left: 23px;
}
.friendfeed.widget .feed .entry {
margin-bottom: 1em;
}
.friendfeed.widget .feed .entry .info,
.friendfeed.widget .feed .entry .likes,
.friendfeed.widget .feed .entry .comment,
.friendfeed.widget .feed .entry .expandcomment {
margin-bottom: 6pt;
}
.friendfeed.widget .feed .cluster .summary,
.friendfeed.widget .feed .entry .title,
.friendfeed.widget .feed .entry .media {
margin-bottom: 4pt;
}
.friendfeed.widget .feed .entry .likes,
.friendfeed.widget .feed .entry .expandcomment {
margin-left: 12px;
padding-left: 19px;
}
.friendfeed.widget .feed .entry .comment {
overflow: hidden;
white-space: nowrap;
}
.friendfeed.widget .feed .entry .comment .content {
margin-left: 31px;
}
.friendfeed.widget .feed .entry .info .lock {
width: 8px;
height: 10px;
vertical-align: middle;
padding-right: 4px;
padding-bottom: 3px;
}
.friendfeed.widget .feed .entry .info a,
.friendfeed.widget .feed .entry .info a:visited,
.friendfeed.widget .feed .entry .likes a,
.friendfeed.widget .feed .entry .likes a:visited,
.friendfeed.widget .feed .entry .comment a,
.friendfeed.widget .feed .entry .comment a:visited,
.friendfeed.widget .feed .entry .expandcomment a,
.friendfeed.widget .feed .entry .expandcomment a:visited {
color: #7070cc;
}
.friendfeed.widget .feed .entry .expandcomment {
font-style: italic;
}
.friendfeed.widget .feed .entry .likes {
background: url("../images/smile.png?v=2") left top no-repeat;
}
.friendfeed.widget .feed .entry .comment .quote {
margin-left: 12px;
}
.friendfeed.widget .feed .entry .comment .quote {
background: url("../images/comment-lighter.png?v=2") 0px 2px no-repeat;
}
.friendfeed.widget .feed .entry .comment.friend .quote {
background-image: url("../images/comment-friend.png?v=2");
}
.friendfeed.widget .feed .entry .comment .author {
margin-top: 2px;
}
.friendfeed.widget .feed .entry .media td {
padding-right: 8px;
}
.friendfeed.widget .feed .entry .media img {
border: 1px solid #ccc;
padding: 1px;
}
.friendfeed.widget .feed .entry .media td.more img {
border: 0;
}
.friendfeed.widget .feed .entry .hiddencomments {
display: none;
}
.friendfeed.widget .feed .entry .likes span,
.friendfeed.widget .feed .entry .comment .content,
.friendfeed.widget .feed .entry .commentform,
.friendfeed.widget .feed .entry .expandcomment,
.friendfeed.widget .feed .entry .info,
.friendfeed.widget .feed .entry .info span,
.friendfeed.widget .feed .entry a.via,
.friendfeed.widget .feed .entry a.via:visited {
color: #737373;
}
.friendfeed.widget .feed .entry a.via {
text-decoration: none;
}
.friendfeed.widget .feed .entry a.via:hover {
text-decoration: underline;
}
.friendfeed.widget .feed .cluster .summary a {
color: #1030cc;
text-decoration: underline;
font-weight: normal;
}
.friendfeed.widget .feed .cluster .summary a,
.friendfeed.widget .feed .cluster .summary a:hover {
border: 0;
}
.friendfeed.widget span.searchbold {
font-weight: bold;
color: black;
}
Pádraig Brady/unix subprocess wrapper ( python)
import time, os, select, signal
class subProcess:
"""Class representing a child process. It's like popen2.Popen3
but there are three main differences.
1. This makes the new child process group leader (using setpgrp())
so that all children can be killed.
2. The output function (read) is optionally non blocking returning in
specified timeout if nothing is read, or as close to specified
timeout as possible if data is read.
3. The output from both stdout & stderr is read (into outdata and
errdata). Reading from multiple outputs while not deadlocking
is not trivial and is often done in a non robust manner."""
def __init__(self, cmd, bufsize=8192):
"""The parameter 'cmd' is the shell command to execute in a
sub-process. If the 'bufsize' parameter is specified, it
specifies the size of the I/O buffers from the child process."""
self.cleaned=False
self.BUFSIZ=bufsize
self.outr, self.outw = os.pipe()
self.errr, self.errw = os.pipe()
self.pid = os.fork()
if self.pid == 0:
self._child(cmd)
os.close(self.outw) #parent doesn't write so close
os.close(self.errw)
# Note we could use self.stdout=fdopen(self.outr) here
# to get a higher level file object like popen2.Popen3 uses.
# This would have the advantages of auto handling the BUFSIZ
# and closing the files when deleted. However it would mean
# that it would block waiting for a full BUFSIZ unless we explicitly
# set the files non blocking, and there would be extra uneeded
# overhead like EOL conversion. So I think it's handier to use os.read()
self.outdata = self.errdata = ''
self._outeof = self._erreof = 0
def _child(self, cmd):
# Note sh below doesn't setup a seperate group (job control)
# for non interactive shells (hmm maybe -m option does?)
os.setpgrp() #seperate group so we can kill it
os.dup2(self.outw,1) #stdout to write side of pipe
os.dup2(self.errw,2) #stderr to write side of pipe
#stdout & stderr connected to pipe, so close all other files
map(os.close,[self.outr,self.outw,self.errr,self.errw])
try:
cmd = ['/bin/sh', '-c', cmd]
os.execvp(cmd[0], cmd)
finally: #exit child on error
os._exit(1)
def read(self, timeout=None):
"""return 0 when finished
else return 1 every timeout seconds
data will be in outdata and errdata"""
currtime=time.time()
while 1:
tocheck=[]
if not self._outeof:
tocheck.append(self.outr)
if not self._erreof:
tocheck.append(self.errr)
ready = select.select(tocheck,[],[],timeout)
if len(ready[0]) == 0: #no data timeout
return 1
else:
if self.outr in ready[0]:
outchunk = os.read(self.outr,self.BUFSIZ)
if outchunk == '':
self._outeof = 1
self.outdata += outchunk
if self.errr in ready[0]:
errchunk = os.read(self.errr,self.BUFSIZ)
if errchunk == '':
self._erreof = 1
self.errdata += errchunk
if self._outeof and self._erreof:
return 0
elif timeout:
if (time.time()-currtime) > timeout:
return 1 #may be more data but time to go
def kill(self):
os.kill(-self.pid, signal.SIGTERM) #kill whole group
def cleanup(self):
"""Wait for and return the exit status of the child process."""
self.cleaned=True
os.close(self.outr)
os.close(self.errr)
pid, sts = os.waitpid(self.pid, 0)
if pid == self.pid:
self.sts = sts
return self.sts
def __del__(self):
if not self.cleaned:
self.cleanup()
I have used this for ages to control child processes (and all their children). Some of the existing subprocess module was based on this, but I find this simpler for my uses at least.
Example:
import subProcess
process = subProcess.subProcess("your shell command")
process.read() #timeout is optional
handle(process.outdata, process.errdata)
del(process)
machacks/(BREW) Git tricks, tips and workflows ( Bash)
# Git Autocompletion for your shell
# I use Git primarily from the command line. Luckily, enabling the Git completion for both Bash and Zsh is quite easy if you used Homebrew to install Git. Simply add the following to your ~/.bashrc:
source `brew --prefix git`/etc/bash_completion.d/git-completion.bash
# If you got Git some other way, check if that includes the completion file. If not, you can always clone the git repo, and copy/link it from there.
# Bash-completion is also available via Mac Ports
brew install bash-completion
# To use bash_completion, add the following lines at the end of your .bash_profile:
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
# and also available via fink (for the ancient types)
bash-completion 20060301-3 Command-line completions for bash
# If you use Zsh, like me, there’s a bit more involved. Add the following to your ~/.zshrc (adjust as necessary for your installation method):
# Enable bash completion for git
# This allows git-completion to work properly
source `brew prefix`/etc/git-completion.d
# Update 2011-04-05: If you’re using a newer ZSH (I’ve tested this with 4.3.9), then you can skip all of the above, as Git completion will automagically work for you (if you already have autoload -U compinit && compinit in your .zshrc).
# If your version of ZSH is older, you can download the git completion from the ZSH repository (h/t graywh on Hacker News)
# Alias git to ‘g’
# I also alias git to g, saving me 66% on typing time! Also, I’m lazy. Add the following to your .bashrc or .zshrc:
alias g='git'
# Now, you’ll probably also want to have the Git Autocompletion when you’re using g as well. Add this to your .bashrc or .zshrc:
# Autocomplete for 'g' as well
complete -o default -o nospace -F _git g
git-config(1)
# In here, you can store all the global Git configuration settings. The .gitconfig file uses the INI file format to store settings, but you can also set (and get) all values by using git config. The most basic settings you should do are your name and eMail, both of which are included in every commit you make:
git config --global user.name "machacks"
git config --global user.email "machacks@me.com"
# Not that I’m telling you how to run your life or anything, but you probably want use your own name and eMail address instead of mine.
# Over time, you will accumulate your own set of configs that tweak Git to your liking. Here are a few of my settings that I find very useful:
# Allow all Git commands to use colored output, if possible
git config --global color.ui auto
# Disable the advice shown by Git when you attempt to push something that’s not fast forward-able
git config --global advice.pushNonFastForward false
# Disable “how to stage/unstage/add” hints given by git status:
git config --global advice.statusHints false
# Tell Git which whitespace problems it should recognize, namely any whitespace at the end of a line, as well as mixed spaces and tabs:
git config --global core.whitespace trailing-space,space-before-tab
# See the man page for more possible options on this.
# Allow git diff to do basic rename and copy detection:
git config --global diff.renames copies
# Tell git diff to use mnemonic prefixes (index, work tree, commit, object) instead of the standard a and b notation:
git config --global diff.mnemonicprefix true
# When branching off a remote branch, automatically let the local branch track the remote branch:
git config --global branch.autosetupmerge true
# When pushing without giving a refspec, push the current branch to its upstream branch. See the git config man page for more possible options.
git config --global push.default tracking
# Enable the recording of resolved conflicts, so that identical hunks can be resolved automatically later on.
git config --global rerere.enabled true
# You may also want to investigate the rerere.autoupdate setting.
# Always show a diffstat at the end of a merge:
git config --global merge.stat true
# Now, you’ll notice that for each and every git config I used the --global option. The reason for that is that Git not only looks at your global gitconfig (located at ~/.gitconfig), but also a repository-specific config (.git/config). So you can customize all these settings for each of your repository to your liking, just run the git config command in your repository without the --global flag.
James Costa/WP_get_links ( ActionScript)
<?php
/** function get_linksbyname()
** Gets the links associated with category 'cat_name'.
** Parameters:
** cat_name (default 'noname') - The category name to use. If no
** match is found uses all
** before (default '') - the html to output before the link
** after (default '<br />') - the html to output after the link
** between (default ' ') - the html to output between the link/image
** and it's description. Not used if no image or show_images == true
** show_images (default true) - whether to show images (if defined).
** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
** 'url', 'description' or 'rating'. Or maybe owner. If you start the
** name with an underscore the order will be reversed.
** You can also specify 'rand' as the order which will return links in a
** random order.
** show_description (default true) - whether to show the description if
** show_images=false/not defined
** show_rating (default false) - show rating stars/chars
** limit (default -1) - Limit to X entries. If not specified, all entries
** are shown.
** show_updated (default 0) - whether to show last updated timestamp
*/
function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',
$between = " ", $show_images = true, $orderby = 'id',
$show_description = true, $show_rating = false,
$limit = -1, $show_updated = 0) {
global $wpdb;
$cat_id = -1;
$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
if ($results) {
foreach ($results as $result) {
$cat_id = $result->cat_id;
}
}
get_links($cat_id, $before, $after, $between, $show_images, $orderby,
$show_description, $show_rating, $limit, $show_updated);
}
function bool_from_yn($yn) {
if ($yn == 'Y') return 1;
return 0;
}
/** function wp_get_linksbyname()
** Gets the links associated with the named category.
** Parameters:
** category (no default) - The category to use.
**/
function wp_get_linksbyname($category, $args = '') {
global $wpdb;
$cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
. " show_rating, show_updated, sort_order, sort_desc, text_before_link,
text_after_link, "
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE
cat_name='$category'");
if (! $cat) {
return;
}
if (empty($args)) {
if ($cat->sort_desc == 'Y') {
$cat->sort_order = '_'.$cat->sort_order;
}
get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
$cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
$cat->list_limit, bool_from_yn($cat->show_updated));
} else {
$args = add_query_arg('category', $cat->cat_id, $args);
wp_get_links($args);
}
} // end wp_get_linksbyname
/** function wp_get_links()
** Gets the links associated with category n.
** Parameters:
** category (no default) - The category to use.
** or:
** a query string
**/
function wp_get_links($args = '') {
global $wpdb;
if (!empty($args) && false === strpos($args, '=')) {
// If args is not a query string, it's a category id.
$category = $args;
$cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
. " show_rating, show_updated, sort_order, sort_desc, text_before_link,
text_after_link, "
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE
cat_id=$category");
if ($cat) {
if ($cat->sort_desc == 'Y') {
$cat->sort_order = '_'.$cat->sort_order;
}
get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
$cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
$cat->list_limit, bool_from_yn($cat->show_updated));
}
} else {
parse_str($args);
if (! isset($category)) $category = -1;
if (! isset($before)) $before = '';
if (! isset($after)) $after = '<br />';
if (! isset($between)) $between = ' ';
if (! isset($show_images)) $show_images = true;
if (! isset($orderby)) $orderby = 'name';
if (! isset($show_description)) $show_description = true;
if (! isset($show_rating)) $show_rating = false;
if (! isset($limit)) $limit = -1;
if (! isset($show_updated)) $show_updated = 1;
if (! isset($echo)) $echo = true;
return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
}
} // end wp_get_links
/** function get_links()
** Gets the links associated with category n.
** Parameters:
** category (default -1) - The category to use. If no category supplied
** uses all
** before (default '') - the html to output before the link
** after (default '<br />') - the html to output after the link
** between (default ' ') - the html to output between the link/image
** and its description. Not used if no image or show_images == true
** show_images (default true) - whether to show images (if defined).
** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
** 'url', 'description', or 'rating'. Or maybe owner. If you start the
** name with an underscore the order will be reversed.
** You can also specify 'rand' as the order which will return links in a
** random order.
** show_description (default true) - whether to show the description if
** show_images=false/not defined .
** show_rating (default false) - show rating stars/chars
** limit (default -1) - Limit to X entries. If not specified, all entries
** are shown.
** show_updated (default 0) - whether to show last updated timestamp
** echo (default true) - whether to echo the results, or return them instead
*/
function get_links($category = -1,
$before = '',
$after = '<br />',
$between = ' ',
$show_images = true,
$orderby = 'name',
$show_description = true,
$show_rating = false,
$limit = -1,
$show_updated = 1,
$echo = true) {
global $wpdb;
$direction = ' ASC';
$category_query = '';
if ($category != -1) {
$category_query = " AND link_category = $category ";
}
if (get_settings('links_recently_updated_time')) {
$recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
} else {
$recently_updated_test = '';
}
if ($show_updated) {
$get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
}
$orderby = strtolower($orderby);
if ($orderby == '')
$orderby = 'id';
if (substr($orderby, 0, 1) == '_') {
$direction = ' DESC';
$orderby = substr($orderby, 1);
}
switch($orderby) {
case 'length':
$length = ", CHAR_LENGTH(link_name) AS length";
break;
case 'rand':
$orderby = 'rand()';
break;
default:
$orderby = " link_" . $orderby;
}
if (!isset($length)) {
$length = '';
}
$sql = "SELECT link_url, link_name, link_image, link_target, link_description, link_rating, link_rel $length $recently_updated_test $get_updated FROM $wpdb->links WHERE
link_visible = 'Y' " . $category_query;
$sql .= ' ORDER BY ' . $orderby . $direction;
/* The next 2 lines implement LIMIT TO processing */
if ($limit != -1)
$sql .= " LIMIT $limit";
$results = $wpdb->get_results($sql);
if (!$results) {
return;
}
$output = '';
foreach ($results as $row) {
if (!isset($row->recently_updated)) $row->recently_updated = false;
$output .= $before;
if ($show_updated && $row->recently_updated) {
$output .= get_settings('links_recently_updated_prepend');
}
$the_link = '#';
if (!empty($row->link_url))
$the_link = wp_specialchars($row->link_url);
$rel = $row->link_rel;
if ($rel != '') {
$rel = ' rel="' . $rel . '"';
}
$desc = wp_specialchars($row->link_description, ENT_QUOTES);
$name = wp_specialchars($row->link_name, ENT_QUOTES);
$title = $desc;
if ($show_updated) {
if (substr($row->link_updated_f, 0, 2) != '00') {
$title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')';
}
}
if ('' != $title) {
$title = ' title="' . $title . '"';
}
$alt = ' alt="' . $name . '"';
$target = $row->link_target;
if ('' != $target) {
$target = ' target="' . $target . '"';
}
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
if (($row->link_image != null) && $show_images) {
if (strstr($row->link_image, 'http'))
$output .= "<img src=\"$row->link_image\" $alt $title />";
else // If it's a relative path
$output .= "<img src=\"" . get_settings('siteurl') . "$row->link_image\" $alt $title />";
} else {
$output .= $name;
}
$output .= '</a>';
if ($show_updated && $row->recently_updated) {
$output .= get_settings('links_recently_updated_append');
}
if ($show_description && ($desc != '')) {
$output .= $between . $desc;
}
$output .= "$after\n";
} // end while
if ($echo) {
echo $output;
} else {
return $output;
}
}
/** function get_linkobjectsbyname()
** Gets an array of link objects associated with category 'cat_name'.
** Parameters:
** cat_name (default 'noname') - The category name to use. If no
** match is found uses all
** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
** 'url', 'description', or 'rating'. Or maybe owner. If you start the
** name with an underscore the order will be reversed.
** You can also specify 'rand' as the order which will return links in a
** random order.
** limit (default -1) - Limit to X entries. If not specified, all entries
** are shown.
**
** Use this like:
** $links = get_linkobjectsbyname('fred');
** foreach ($links as $link) {
** echo '<li>'.$link->link_name.'</li>';
** }
**/
function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
global $wpdb;
$cat_id = -1;
$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
if ($results) {
foreach ($results as $result) {
$cat_id = $result->cat_id;
}
}
return get_linkobjects($cat_id, $orderby, $limit);
}
/** function get_linkobjects()
** Gets an array of link objects associated with category n.
** Parameters:
** category (default -1) - The category to use. If no category supplied
** uses all
** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
** 'url', 'description', or 'rating'. Or maybe owner. If you start the
** name with an underscore the order will be reversed.
** You can also specify 'rand' as the order which will return links in a
** random order.
** limit (default -1) - Limit to X entries. If not specified, all entries
** are shown.
**
** Use this like:
** $links = get_linkobjects(1);
** if ($links) {
** foreach ($links as $link) {
** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
** }
** }
** Fields are:
** link_id
** link_url
** link_name
** link_image
** link_target
** link_category
** link_description
** link_visible
** link_owner
** link_rating
** link_updated
** link_rel
** link_notes
**/
function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
global $wpdb;
$sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
if ($category != -1) {
$sql .= " AND link_category = $category ";
}
if ($orderby == '')
$orderby = 'id';
if (substr($orderby,0,1) == '_') {
$direction = ' DESC';
$orderby = substr($orderby,1);
}
if (strcasecmp('rand',$orderby) == 0) {
$orderby = 'rand()';
} else {
$orderby = " link_" . $orderby;
}
$sql .= ' ORDER BY ' . $orderby;
$sql .= $direction;
/* The next 2 lines implement LIMIT TO processing */
if ($limit != -1)
$sql .= " LIMIT $limit";
$results = $wpdb->get_results($sql);
if ($results) {
foreach ($results as $result) {
$result->link_url = $result->link_url;
$result->link_name = $result->link_name;
$result->link_description = $result->link_description;
$result->link_notes = $result->link_notes;
$newresults[] = $result;
}
}
return $newresults;
}
function get_linkrating($link) {
return apply_filters('link_rating', $link->link_rating);
}
/** function get_linksbyname_withrating()
** Gets the links associated with category 'cat_name' and display rating stars/chars.
** Parameters:
** cat_name (default 'noname') - The category name to use. If no
** match is found uses all
** before (default '') - the html to output before the link
** after (default '<br />') - the html to output after the link
** between (default ' ') - the html to output between the link/image
** and it's description. Not used if no image or show_images == true
** show_images (default true) - whether to show images (if defined).
** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
** 'url' or 'description'. Or maybe owner. If you start the
** name with an underscore the order will be reversed.
** You can also specify 'rand' as the order which will return links in a
** random order.
** show_description (default true) - whether to show the description if
** show_images=false/not defined
** limit (default -1) - Limit to X entries. If not specified, all entries
** are shown.
** show_updated (default 0) - whether to show last updated timestamp
*/
function get_linksbyname_withrating($cat_name = "noname", $before = '',
$after = '<br />', $between = " ",
$show_images = true, $orderby = 'id',
$show_description = true, $limit = -1, $show_updated = 0) {
get_linksbyname($cat_name, $before, $after, $between, $show_images,
$orderby, $show_description, true, $limit, $show_updated);
}
/** function get_links_withrating()
** Gets the links associated with category n and display rating stars/chars.
** Parameters:
** category (default -1) - The category to use. If no category supplied
** uses all
** before (default '') - the html to output before the link
** after (default '<br />') - the html to output after the link
** between (default ' ') - the html to output between the link/image
** and it's description. Not used if no image or show_images == true
** show_images (default true) - whether to show images (if defined).
** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
** 'url' or 'description'. Or maybe owner. If you start the
** name with an underscore the order will be reversed.
** You can also specify 'rand' as the order which will return links in a
** random order.
** show_description (default true) - whether to show the description if
** show_images=false/not defined .
** limit (default -1) - Limit to X entries. If not specified, all entries
** are shown.
** show_updated (default 0) - whether to show last updated timestamp
*/
function get_links_withrating($category = -1, $before = '', $after = '<br />',
$between = " ", $show_images = true,
$orderby = 'id', $show_description = true,
$limit = -1, $show_updated = 0) {
get_links($category, $before, $after, $between, $show_images, $orderby,
$show_description, true, $limit, $show_updated);
}
/** function get_linkcatname()
** Gets the name of category n.
** Parameters: id (default 0) - The category to get. If no category supplied
** uses 0
*/
function get_linkcatname($id = 0) {
global $wpdb;
$cat_name = '';
if ('' != $id) {
$cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
}
return $cat_name;
}
/** function get_get_autotoggle()
** Gets the auto_toggle setting of category n.
** Parameters: id (default 0) - The category to get. If no category supplied
** uses 0
*/
function get_autotoggle($id = 0) {
global $wpdb;
$auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
if ('' == $auto_toggle)
$auto_toggle = 'N';
return $auto_toggle;
}
/** function links_popup_script()
** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/
** Show the link to the links popup and the number of links
** Parameters:
** text (default Links) - the text of the link
** width (default 400) - the width of the popup window
** height (default 400) - the height of the popup window
** file (default linkspopup.php) - the page to open in the popup window
** count (default true) - the number of links in the db
*/
function links_popup_script($text = 'Links', $width=400, $height=400,
$file='links.all.php', $count = true) {
if ($count == true) {
$counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
}
$javascript = "<a href=\"#\" " .
" onclick=\"javascript:window.open('$file?popup=1', '_blank', " .
"'width=$width,height=$height,scrollbars=yes,status=no'); " .
" return false\">";
$javascript .= $text;
if ($count == true) {
$javascript .= " ($counts)";
}
$javascript .="</a>\n\n";
echo $javascript;
}
/*
* function get_links_list()
*
* added by Dougal
*
* Output a list of all links, listed by category, using the
* settings in $wpdb->linkcategories and output it as a nested
* HTML unordered list.
*
* Parameters:
* order (default 'name') - Sort link categories by 'name' or 'id'
* hide_if_empty (default true) - Supress listing empty link categories
*/
function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
global $wpdb;
$order = strtolower($order);
// Handle link category sorting
if (substr($order,0,1) == '_') {
$direction = ' DESC';
$order = substr($order,1);
}
// if 'name' wasn't specified, assume 'id':
$cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';
if (!isset($direction)) $direction = '';
// Fetch the link category data as an array of hashesa
$cats = $wpdb->get_results("
SELECT DISTINCT link_category, cat_name, show_images,
show_description, show_rating, show_updated, sort_order,
sort_desc, list_limit
FROM `$wpdb->links`
LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
WHERE link_visible = 'Y'
AND list_limit <> 0
ORDER BY $cat_order $direction ", ARRAY_A);
// Display each category
if ($cats) {
foreach ($cats as $cat) {
// Handle each category.
// First, fix the sort_order info
$orderby = $cat['sort_order'];
$orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
// Display the category name
echo ' <li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2>\n\t<ul>\n";
// Call get_links() with all the appropriate params
get_links($cat['link_category'],
'<li>',"</li>","\n",
bool_from_yn($cat['show_images']),
$orderby,
bool_from_yn($cat['show_description']),
bool_from_yn($cat['show_rating']),
$cat['list_limit'],
bool_from_yn($cat['show_updated']));
// Close the last category
echo "\n\t</ul>\n</li>\n";
}
}
}
?>
Wordpress Links Loop.
mitry/~/.tidyrc ( Other)
// @(#) HTML Tidy Configuration Options
// HTML, XHTML, XML Options Reference {{{1
// add-xml-decl: no
// This option specifies if Tidy should add the XML declaration when
// outputting XML or XHTML. Note that if the input already includes an
// <?xml ... ?> declaration then this option will be ignored.
// If the encoding for the output is different from "ascii", one of
// the utf encodings or "raw", the declaration is always added as
// required by the XML standard.
// add-xml-space: no
// This option specifies if Tidy should add xml:space="preserve" to elements
// such as <PRE>, <STYLE> and <SCRIPT> when generating XML. This is needed if
// the whitespace in such elements is to be parsed appropriately without having
// access to the DTD.
// alt-text: String
// This option specifies the default "alt=" text Tidy uses for <IMG>
// attributes. This feature is dangerous as it suppresses further accessibility
// warnings. You are responsible for making your documents accessible to people
// who can not see the images!
// anchor-as-name: yes
// This option controls the deletion or addition of the name attribute in
// elements where it can serve as anchor. If set to "yes", a name attribute, if
// not already existing, is added along an existing id attribute if the DTD
// allows it. If set to "no", any existing name attribute is removed if an id
// attribute exists or has been added.
// assume-xml-procins: yes
// This option specifies if Tidy should change the parsing of processing
// instructions to require ?> as the terminator rather than >. This option is
// automatically set if the input is in XML.
bare: yes
// This option specifies if Tidy should strip Microsoft specific HTML from Word
// 2000 documents, and output spaces rather than non-breaking spaces where they
// exist in the input.
clean: yes
// This option specifies if Tidy should strip out surplus presentational tags
// and attributes replacing them by style rules and structural markup as
// appropriate. It works well on the HTML saved by Microsoft Office products.
// css-prefix: String
// This option specifies the prefix that Tidy uses for styles rules.
// By default, "c" will be used.
// decorate-inferred-ul: no
// This option specifies if Tidy should decorate inferred UL elements with some
// CSS markup to avoid indentation to the right.
// doctype: auto
// Example: omit, auto, strict, transitional, user
// This option specifies the DOCTYPE declaration generated by Tidy. If set to
// "omit" the output won't contain a DOCTYPE declaration. If set to "auto" (the
// default) Tidy will use an educated guess based upon the contents of the
// document. If set to "strict", Tidy will set the DOCTYPE to the strict DTD.
// If set to "loose", the DOCTYPE is set to the loose (transitional) DTD.
// Alternatively, you can supply a string for the formal public identifier
// (FPI).
//
// For example:
// doctype: "-//ACME//DTD HTML 3.14159//EN"
//
// If you specify the FPI for an XHTML document, Tidy will set the system
// identifier to an empty string. For an HTML document, Tidy adds a system
// identifier only if one was already present in order to preserve the
// processing mode of some browsers. Tidy leaves the DOCTYPE for generic XML
// documents unchanged. --doctype omit implies --numeric-entities yes. This
// option does not offer a validation of the document conformance.
// drop-empty-paras: yes
// This option specifies if Tidy should discard empty paragraphs.
drop-font-tags: yes
// This option specifies if Tidy should discard <FONT> and <CENTER> tags
// without creating the corresponding style rules. This option can be set
// independently of the clean option.
drop-proprietary-attributes: yes
// This option specifies if Tidy should strip out proprietary attributes, such
// as MS data binding attributes.
// enclose-block-text: no
// This option specifies if Tidy should insert a <P> element to enclose any
// text it finds in any element that allows mixed content for HTML transitional
// but not HTML strict.
// enclose-text: no
// This option specifies if Tidy should enclose any text it finds in the body
// element within a <P> element. This is useful when you want to take existing
// HTML and use it with a style sheet.
// escape-cdata: no
// This option specifies if Tidy should convert <![CDATA[]]> sections to normal text.
// fix-backslash: yes
// This option specifies if Tidy should replace backslash characters "\" in
// URLs by forward slashes "/".
// fix-bad-comments: yes
// This option specifies if Tidy should replace unexpected hyphens with "="
// characters when it comes across adjacent hyphens. The default is yes. This
// option is provided for users of Cold Fusion which uses the comment syntax:
// <!--- --->
// fix-uri: yes
// This option specifies if Tidy should check attribute values that carry URIs
// for illegal characters and if such are found, escape them as HTML
// 4 recommends.
// hide-comments: no
// This option specifies if Tidy should print out comments.
hide-endtags: yes
// This option specifies if Tidy should omit optional end-tags when generating
// the pretty printed markup.
// This option is ignored if you are outputting to XML.
// indent-cdata: no
// This option specifies if Tidy should indent <![CDATA[]]> sections.
// input-xml: no
// This option specifies if Tidy should use the XML parser rather than the
// error correcting HTML parser.
// join-classes: no
// This option specifies if Tidy should combine class names to generate
// a single new class name, if multiple class assignments are detected on an
// element.
// join-styles: yes
// This option specifies if Tidy should combine styles to generate a single new
// style, if multiple style values are detected on an element.
// literal-attributes: no
// This option specifies if Tidy should ensure that whitespace characters
// within attribute values are passed through unchanged.
// logical-emphasis: no
// This option specifies if Tidy should replace any occurrence of <I> by <EM>
// and any occurrence of <B> by <STRONG>. In both cases, the attributes are
// preserved unchanged. This option can be set independently of the clean and
// drop-font-tags options.
// lower-literals: yes
// This option specifies if Tidy should convert the value of an attribute that
// takes a list of predefined values to lower case. This is required for XHTML
// documents.
// merge-divs: auto
// Can be used to modify behavior of -c (--clean yes) option. This option
// specifies if Tidy should merge nested <div> such as
// "<div><div>...</div></div>". If set to "auto", the attributes of the inner
// <div> are moved to the outer one. As well, nested <div> with ID attributes
// are not merged. If set to "yes", the attributes of the inner <div> are
// discarded with the exception of "class" and "style".
// merge-spans: auto
// Can be used to modify behavior of -c (--clean yes) option. This option
// specifies if Tidy should merge nested <span> such as
// "<span><span>...</span></span>". The algorithm is identical to the one used
// by --merge-divs.
// ncr: yes
// This option specifies if Tidy should allow numeric character references.
// new-blocklevel-tags:
// Space or comma separated list of tag names. Unless you declare new tags,
// Tidy will refuse to generate a tidied file if the input includes previously
// unknown tags. Note you can't change the content model for elements such as
// <TABLE>, <UL>, <OL> and <DL>. This option is ignored in XML mode.
//
// Example: tagX, tagY, ... new-empty-tags
// new-empty-tags:
// Space or comma separated list of tag names. Unless you declare new tags,
// Tidy will refuse to generate a tidied file if the input includes previously
// unknown tags. Remember to also declare empty tags as either inline or
// blocklevel. This option is ignored in XML mode.
//
// Example: tagX, tagY, ... new-blocklevel-tags
// new-inline-tags:
// Space or comma separated list of tag names. Unless you declare new tags,
// Tidy will refuse to generate a tidied file if the input includes previously
// unknown tags. This option is ignored in XML mode.
//
// Example: tagX, tagY, ... new-blocklevel-tags
// new-pre-tags:
// This option specifies new tags that are to be processed in exactly the same
// way as HTML's <PRE> element. This option takes a space or comma separated
// list of tag names. Unless you declare new tags, Tidy will refuse to generate
// a tidied file if the input includes previously unknown tags. Note you can
// not as yet add new CDATA elements (similar to <SCRIPT>). This option is
// ignored in XML mode.
//
// Example: tagX, tagY, ... new-blocklevel-tags
// numeric-entities: no
// This option specifies if Tidy should output entities other than the built-in
// HTML entities (&amp;, &lt;, &gt; and &quot;) in the numeric rather than the
// named entity form. Only entities compatible with the DOCTYPE declaration
// generated are used. Entities that can be represented in the output encoding
// are translated correspondingly.
// output-html: no
// This option specifies if Tidy should generate pretty printed output,
// writing it as HTML.
// output-xhtml: no
// This option specifies if Tidy should generate pretty printed output, writing
// it as extensible HTML. This option causes Tidy to set the DOCTYPE and
// default namespace as appropriate to XHTML. If a DOCTYPE or namespace is
// given they will checked for consistency with the content of the document. In
// the case of an inconsistency, the corrected values will appear in the
// output. For XHTML, entities can be written as named or numeric entities
// according to the setting of the "numeric-entities" option. The original case
// of tags and attributes will be preserved, regardless of other options.
// output-xml: no
// This option specifies if Tidy should pretty print output, writing it as
// well-formed XML. Any entities not defined in XML 1.0 will be written as
// numeric entities to allow them to be parsed by a XML parser. The original
// case of tags and attributes will be preserved, regardless of other options.
preserve-entities: yes
// This option specifies if Tidy should preserve the well-formed entitites as
// found in the input.
// quote-ampersand: yes
// This option specifies if Tidy should output unadorned & characters as &amp;.
// quote-marks: no
// This option specifies if Tidy should output " characters as &quot; as is
// preferred by some editing environments. The apostrophe character ' is
// written out as &#39; since many web browsers don't yet support &apos;.
// quote-nbsp: yes
// This option specifies if Tidy should output non-breaking space characters as
// entities, rather than as the Unicode character value 160 (decimal).
// repeated-attributes: keep-last
// This option specifies if Tidy should keep the first or last attribute, if an
// attribute is repeated, e.g. has two align attributes.
//
// Example: keep-first, keep-last
replace-color: yes
// replace-color: no
// This option specifies if Tidy should replace numeric values in color
// attributes by HTML/XHTML color names where defined,
// e.g. replace "#ffffff" with "white".
// show-body-only: no
// This option specifies if Tidy should print only the contents of the body tag
// as an HTML fragment. If set to "auto", this is performed only if the body
// tag has been inferred. Useful for incorporating existing whole pages as
// a portion of another page. This option has no effect if XML output is
// requested.
// uppercase-attributes: no
// This option specifies if Tidy should output attribute names in upper case.
// The default is no, which results in lower case attribute names, except for
// XML input, where the original case is preserved.
// uppercase-tags: no
// This option specifies if Tidy should output tag names in upper case. The
// default is no, which results in lower case tag names, except for XML input,
// where the original case is preserved.
word-2000: yes
// word-2000: no
// This option specifies if Tidy should go to great pains to strip out all the
// surplus stuff Microsoft Word 2000 inserts when you save Word documents as
// "Web pages". Doesn't handle embedded images or VML. You should consider
// using Word's "Save As: Web Page, Filtered".
// Diagnostics Options Reference {{{1
// accessibility-check:
// This option specifies what level of accessibility checking, if any, that
// Tidy should do. Level 0 is equivalent to Tidy Classic's accessibility
// checking. For more information on Tidy's accessibility checking, visit the
// Adaptive Technology Resource Centre at the University of Toronto.
//
// Example: 0 (Tidy Classic), 1 (Priority 1 Checks),
// 2 (Priority 2 Checks), 3 (Priority 3 Checks)
// show-errors: 6
// This option specifies the number Tidy uses to determine if further errors
// should be shown. If set to 0, then no errors are shown.
// show-warnings: yes
// This option specifies if Tidy should suppress warnings. This can be useful
// when a few errors are hidden in a flurry of warnings.
// Pretty Print Options Reference {{{1
// break-before-br: no
// This option specifies if Tidy should output a line break before each <BR> element.
indent: auto
// indent: no
// This option specifies if Tidy should indent block-level tags. If set to
// "auto", this option causes Tidy to decide whether or not to indent the
// content of tags such as TITLE, H1-H6, LI, TD, TD, or P depending on whether
// or not the content includes a block-level element. You are advised to avoid
// setting indent to yes as this can expose layout bugs in some browsers.
// indent-attributes: no
// This option specifies if Tidy should begin each attribute on a new line.
indent-spaces: 8
// indent-spaces: 2
// This option specifies the number of spaces Tidy uses to indent content,
// when indentation is enabled.
// markup: yes
// This option specifies if Tidy should generate a pretty printed version of
// the markup. Note that Tidy won't generate a pretty printed version if it
// finds significant errors (see force-output).
punctuation-wrap: yes
// punctuation-wrap:no
// This option specifies if Tidy should line wrap after some Unicode or Chinese
// punctuation characters.
// sort-attributes: none
// This option specifies that tidy should sort attributes within an element
// using the specified sort algorithm. If set to "alpha", the algorithm is an
// ascending alphabetic sort.
//
// Example: none, alpha
// split: no
// Currently not used. Tidy Classic only.
// tab-size: 8
// This option specifies the number of columns that Tidy uses between
// successive tab stops. It is used to map tabs to spaces when reading the
// input. Tidy never outputs tabs.
vertical-space: yes
// This option specifies if Tidy should add some empty lines for readability.
wrap: 0
// wrap: 68
// This option specifies the right margin Tidy uses for line wrapping. Tidy
// tries to wrap lines so that they do not exceed this length.
// Set wrap to zero if you want to disable line wrapping.
// wrap-asp: yes
// This option specifies if Tidy should line wrap text contained within ASP
// pseudo elements, which look like: <% ... %>.
// wrap-attributes: no
// This option specifies if Tidy should line wrap attribute values, for easier
// editing. This option can be set independently of wrap-script-literals.
// wrap-jste: yes
// This option specifies if Tidy should line wrap text contained within JSTE
// pseudo elements, which look like: <# ... #>.
// wrap-php: yes
// This option specifies if Tidy should line wrap text contained within PHP
// pseudo elements, which look like: <?php ... ?>.
// wrap-script-literals: no
// This option specifies if Tidy should line wrap string literals that appear
// in script attributes. Tidy wraps long script string literals by inserting
// a backslash character before the line break.
// wrap-sections: yes
// This option specifies if Tidy should line wrap text contained
// within <![ ... ]> section tags.
// Character Encoding Options Reference {{{1
// ascii-chars: no
// Can be used to modify behavior of -c (--clean yes) option.
// If set to "yes" when using -c, &emdash;, &rdquo;, and other named character
// entities are downgraded to their closest ascii equivalents.
char-encoding: raw
// char-encoding: ascii
// This option specifies the character encoding Tidy uses for both the input
// and output. For ascii, Tidy will accept Latin-1 (ISO-8859-1) character
// values, but will use entities for all characters whose value > 127. For raw,
// Tidy will output values above 127 without translating them into entities.
// For latin1, characters above 255 will be written as entities. For utf8, Tidy
// assumes that both input and output is encoded as UTF-8. You can use iso2022
// for files encoded using the ISO-2022 family of encodings e.g. ISO-2022-JP.
// For mac and win1252, Tidy will accept vendor specific character values, but
// will use entities for all characters whose value > 127. For unsupported
// encodings, use an external utility to convert to and from UTF-8.
//
// Example: raw, ascii, latin0, latin1, utf8, iso2022, mac, win1252,
// ibm858, utf16le, utf16be, utf16, big5, shiftjis
// input-encoding:latin1
// This option specifies the character encoding Tidy uses for the input. See
// char-encoding for more info.
//
// Example: raw, ascii, latin0, latin1, utf8, iso2022, mac, win1252,
// ibm858, utf16le, utf16be, utf16, big5, shiftjis
language: ru
// Currently not used, but this option specifies the language Tidy uses
// (for instance "en").
// newline:
// The default is appropriate to the current platform: CRLF on PC-DOS,
// MS-Windows and OS/2, CR on Classic Mac OS, and LF everywhere else (Unix and
// Linux).
// Default: Platform dependent
// output-bom: auto
// This option specifies if Tidy should write a Unicode Byte Order Mark
// character (BOM; also known as Zero Width No-Break Space; has value of
// U+FEFF) to the beginning of the output; only for UTF-8 and UTF-16 output
// encodings. If set to "auto", this option causes Tidy to write a BOM to the
// output only if a BOM was present at the beginning of the input. A BOM is
// always written for XML/XHTML output using UTF-16 output encodings.
// output-encoding: ascii
// This option specifies the character encoding Tidy uses for the output. See
// char-encoding for more info. May only be different from input-encoding for
// Latin encodings (ascii, latin0, latin1, mac, win1252, ibm858).
//
// Example: raw, ascii, latin0, latin1, utf8, iso2022, mac, win1252,
// ibm858, utf16le, utf16be, utf16, big5, shiftjis
// Miscellaneous Options Reference {{{1
// error-file: -
// This option specifies the error file Tidy uses for errors and warnings.
// Normally errors and warnings are output to "stderr".
// force-output: no
// This option specifies if Tidy should produce output even if errors are
// encountered. Use this option with care - if Tidy reports an error, this
// means Tidy was not able to, or is not sure how to, fix the error, so the
// resulting output may not reflect your intention.
gnu-emacs: yes
// This option specifies if Tidy should change the format for reporting errors
// and warnings to a format that is more easily parsed by GNU Emacs.
// gnu-emacs-file: -
// Used internally.
// keep-time: no
// This option specifies if Tidy should keep the original modification time of
// files that Tidy modifies in place. The default is no. Setting the option to
// yes allows you to tidy files without causing these files to be uploaded to
// a web server when using a tool such as SiteCopy. Note this feature is not
// supported on some platforms.
// output-file: -
// This option specifies the output file Tidy uses for markup. Normally markup
// is written to "stdout".
// quiet: no
// This option specifies if Tidy should output the summary of the numbers of
// errors and warnings, or the welcome or informational messages.
// slide-style: -
// Currently not used. Tidy Classic only.
// tidy-mark: yes
// This option specifies if Tidy should add a meta element to the document head
// to indicate that the document has been tidied. Tidy won't add a meta element
// if one is already present.
// write-back: no
// This option specifies if Tidy should write back the tidied markup to the
// same file it read from. You are advised to keep copies of important files
// before tidying them, as on rare occasions the result may not be what you
// expect.
xma/wordpress functions ( PHP)
//when theme fire up...
add_action('after_setup_theme','themeoptions', 16);
function themeoptions(){
//include additional files
require_once(TEMPLATEPATH . '/theme/themeoptions.php');
load_theme_textdomain( 'mytheme', TEMPLATEPATH.'/languages' );
//sidebar widget
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar-sx',
'before_title' => '<h3>',
'after_title' => '</h3>',
'before_widget' => '',
'after_widget' => '',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar-dx',
'before_title' => '<h3>',
'after_title' => '</h3>',
'before_widget' => '',
'after_widget' => '',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'advertisement',
'before_title' => '<h3 class="hide2">',
'after_title' => '</h3>',
'before_widget' => '',
'after_widget' => '',
));
//various theme support
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats',
array(
'aside', // title less blurb
'gallery', // gallery of images
'link', // quick link to other site
'image', // an image
'quote', // a quick quote
'status', // a Facebook like status update
'video', // video
'audio', // audio
'chat' // chat transcript
)
);
//microformati
add_theme_support( 'structured-post-formats', array( 'link', 'video' ) );
//custom thumbnail size
add_image_size( 'thumb-600', 600, 150, true );
add_image_size( 'thumb-300', 300, 100, true );
//call in theme : <?php the_post_thumbnail( 'thumb-300' ); ?>
//see more on: http://codex.wordpress.org/Function_Reference/add_image_size
//navigation menu
add_theme_support( 'menus' );
if (function_exists('register_nav_menus')) {
register_nav_menus( array(
'main-nav' => __( 'Main Navigation' ),
'footer-nav' => __( 'Footer Navigation'),
) );
}
/* in the theme ...
wp_nav_menu(array(
'container' => false, // remove nav container
'container_class' => 'menu clearfix', // class of container (should you choose to use it)
'menu' => __( 'The Main Menu', 'bonestheme' ), // nav name
'menu_class' => 'nav top-nav clearfix', // adding custom nav class
'theme_location' => 'main-nav', // where it's located in the theme
'before' => '', // before the menu
'after' => '', // after the menu
'link_before' => '', // before each link
'link_after' => '', // after each link
'depth' => 0, // limit the depth of the nav
'fallback_cb' => 'bones_main_nav_fallback' // fallback function
));
} */
//clean wp-head
remove_action( 'wp_head', 'rsd_link' );
// windows live writer
remove_action( 'wp_head', 'wlwmanifest_link' );
// index link
remove_action( 'wp_head', 'index_rel_link' );
// previous link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
// start link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
// links for adjacent posts
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
// WP version
remove_action( 'wp_head', 'wp_generator' );
// remove WP version from css
// i going to add this
// remove injected CSS for recent comments widget
// remove injected CSS from recent comments widget
// remove injected CSS from gallery
// replace jquery
if( !is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', (/*"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js*/ "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"), false, '1.7.1');
wp_enqueue_script('jquery');
}
// disable admin bar
function disable_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'disable_admin_bar' );
/// related post
function related_posts() {
echo '<ul id="related-posts">';
global $post;
$tags = wp_get_post_tags($post->ID);
if($tags) {
foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; }
$args = array(
'tag' => $tag_arr,
'numberposts' => 5, /* you can change this to show more */
'post__not_in' => array($post->ID)
);
$related_posts = get_posts($args);
if($related_posts) {
foreach ($related_posts as $post) : setup_postdata($post); ?>
<li class="related_post"><a class="entry-unrelated" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; }
else { ?>
<?php echo '<li class="no_related_post">' . __( 'No Related Posts Yet!', '' ) . '</li>'; ?>
<?php }
}
wp_reset_query();
echo '</ul>';
}
}
function files for worpdress
jitendraweb/suckerfish dropdown menu for Joomla 1.5 | joomla 1.5 tutorials ( CSS)
/* =======================================
Top Menu aka Main Menu
======================================= */
.moduletable_topmenu{
padding:0;
color: #333;
height: 30px;
margin: 0;
width: 500px;
font-size: 90%
}
.moduletable_topmenu h3 {
background:#666;
color:#fff;
padding:0.25em 0;
text-align:center;
font-size:1.1em;
margin:0;
}
.moduletable_topmenu ul{
list-style: none;
margin: 0;
padding: 0;
}
.moduletable_topmenu li{
margin: 0px 15px 0px 0px;
float: left;
}
.moduletable_topmenu li ul {
position: absolute;
width: 135px;
left: -999em;
border: 1px solid #474748;
border-bottom: none;
top: 22px;
}
.moduletable_topmenu li:hover ul {
left: auto;
}
.moduletable_topmenu li ul li {
width: 135px;
padding: 0;
border-bottom: 1px solid #474748;
}
.moduletable_topmenu li a{
display: block;
padding: 5px;
background-color:#fff;
color: #000;
font-weight: bold;
text-decoration: none;
}
html>body .moduletable_topmenu li a {
width: auto;
}
.moduletable_topmenu li ul li a {
width: 125px;
background-color: #221f20;
color: #fff;
/* ---
filter:alpha(opacity=80);
-moz-opacity: 0.8;
opacity: 0.8;*/
}
.moduletable_topmenu li a:hover,a#active_menu:link,a#active_menu:visited{
color: #e22f00;
text-decoration: none;
/* ---
filter:alpha(opacity=100);
-moz-opacity: 1.0;
opacity: 1.0;*/
}
.moduletable_topmenu li ul li a:hover {
background-color: #e22f00;
color: #fff;
background: url(../images/top_link_bg2_on.png) repeat-y top left;
}
.moduletable_topmenu li:hover ul, .moduletable_topmenu li.sfhover ul {
left: auto;
}
.moduletable_topmenu ul li.active a {
color: #038fd9;
text-decoration: none;
}
.moduletable_topmenu li.parent.active a {
color: #038fd9;
text-decoration: none;
}
.moduletable_topmenu li.parent.active a:hover {
color: #e22f00;
}
.moduletable_topmenu li.parent.active ul li a {
color: #fff;
text-decoration: none;
}
.moduletable_topmenu li.parent.active ul li a:hover {
color: #fff;
text-decoration: none;
}
4) To make this really work there are several things that need to be done, follow along because it requires you editing the index.php file (your template file, now understand that I created my own template) and also adding some js into your template.
In your index.php file it's important to note the name of the div tag that holds your top module position . For example here in my index.php I have code that looks like this:
<div id="header">
<div id="header_container">
<div id="top_menu">
<jdoc:include type="modules" name="top" style="xhtml" />
</div>
<div id="logo">
<a href="http://patronsaintmedia.com" title="Patron Saint Media"><img src="templates/<?php echo $this->template; ?>/images/logo.png" width="107" height="103" /></a>
</div>
</div>
</div>
Notice the div with the id of "top_menu".
<div id="top_menu">
<jdoc:include type="modules" name="top" style="xhtml" />
</div>
This is important because in order to get the suckerfish dropdown in IE to work we need to reference the id of the container for that menu. so instead of placing the id in the
like they do in the typical suckerfish article we will place it in the div tag for the module that will be used ONLY for the holding of the top menu. Yes this is a dirty trick but none the less it works.
Now create a js file, I call mine custom_lib.js and add the following code into it:
sfHover = function()
{
var sfEls = document.getElementById("top_menu").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++)
{
sfEls[i].onmouseover=function()
{
this.className+=" sfhover";
}
sfEls[i].onmouseout=function()
{
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
Place that js file in a folder (within a chosen template you're using) and name that folder "js".
In your chosen template ad this to the head tag:
<script type="text/javascript" src="templates/<?php echo $this->template; ?>/js/custom_lib.js"></script>
5) You're good to go now just modify the styles within the css file and you should be good to go!
here's the suckerfish dropdown menu for Joomla 1.5 that written by tbianco. It's extremely easy and here's what you need to do:
1) Create the main menu module and add a suffix to it of 'topmenu'. I use the underscore to so that the class name in the css is now ".moduletabletopmenu" I want to make sure in my code there is a seperation from the typical ".moduletable" and ".moduletable_topmenu". Besides it's REALLY bad coding practice to run words together unless you are camelCasing them. I am just used to ruby so I have using the underscore for variable names.
2) While in the module for your main menu (under module manager) be sure to check YES for "Always show sub-menu Items". It's in the module param section.
3) It's time to place the CSS code onto the page: (I added the opacity ability just in case you wanted to make the sub menus transparent)
Rajkumar Jain/Installing Perl modules on Windows ( python)
Table Of Contents: 1. Installing Perl Modules on Windows 1.1 Perl Modules 1.2 Getting modules 1.3 Installing modules using PPM tool 1.4 Installing modules manually 2. References 1. Installing Perl Modules on Windows 1.1 Perl Modules A Perl module is a package (has .pm as extension) that can be reused and is defined in a library file whose name is the same as the name of the package. A module may provide following. i) Provide a mechanism for exporting some of its symbols into the symbol table of any other package using it. ii) It may also function as a class definition and make its operations available implicitly through method calls on the class and its objects, without explicitly exporting any symbols. Usually Perl modules are included in a Perl program as following. To include a module ‘MyModule.pm’, write: use MyModule; 1.2 Getting packages The first thing that you will need to do is to get the package for module. Usually zipn files are available for packages. Below are the steps for getting the zip file. i) Go to http://ppm.activestate.com ii) Go to ‘Zips’ tab. iii) Click on one of ActivePerl5xx, ActivePerl6xx, or ActivePerl8xx links based on the build version of Active Perl in your Windows machine. You can go to Start->Settings->Control Panel->Add Remove Programs to find ActivePerl build 5xx, 6xx or 8xx in the list. iv) Click on Windows link. v) Download the zip file you need (for example: Math-Stat.zip) into your local Windows machine in a temp folder (say C:/Test/). vi) Similarly download any other zip files that you need to install. 1.3 Installing modules using PPM tool. The ppm program is the package manager for ActivePerl. It simplifies the task of locating, installing, upgrading and removing Perl packages. PPM is installed automatically with ActivePerl. All PPM operations and configuration can be performed at the command line. You can use 'ppm help' command in command prompt for more information. After downloading zip files for the packages (as discussed in 1.2), you can follow below steps to use these zip files, for installing modules using PPM tool. 1. Unzip the package to a temporary directory (say C:/Test/). 2. Go to command promots and install the package by specifying the name of ppd file directly: ppm install C:\Test\Modulename.ppd If the module installation is successful, you will see ‘Successfully installed…’ message on the command prompt. After installing Math-Stat module, you can include the same in Perl file like following. use Math::Stat; 1.4 Installing modules manually Unfortunately, not all modules can be installed via PPM. Also, many times you may not be able to use PPM tool to install modules, because of you being under-privileged user in Windows machine. In all such cases, if you need to install a module, you should be able to install it manually, as discussed below. After downloading zip files for the packages (as discussed in 1.2), you can use following steps. i) Unzip the package to a temporary directory (say C:/Test/). ii) This will give .ppd file, a readme file and a folder (say, MSWin32-x86-multi-thread-5.8 for Math-Stat module). Ignore .ppd and readme files, then check the content inside this folder. If there is zip or tar file inside, then unzip it. iii) Look for .pm file inside the subfolders (here you will find Stat.pm in blib\lib\Math\ folder. If ActivePerl is installed in C:/Perl/ folder in your Windows machine, then put this .pm file into C:/Perl/site/lib/Math/ folder (If this Math folder does not exist, then crate one here). Please note correspondence between the common portion of path (\lib\Math\) here. This needs to be maintained when placing the .pm file. iv) Look for .html file inside the subfolders again (here you will find Stat.html in blib\html\site\lib\Math\ folder). This file is a help file describing the functions available in corresponding .pm file). It is not mandatory to copy this file, however if you wish to copy, you can copy this into C:\Perl\html\site\lib\Math\ folder (If this Math folder does not exist, then crate one here) in your Windows machine. v) Look for autosplit.ix file inside the subfolders again (here you will find this file in blib\lib\auto\Math\Stat\ location). then there Put this file in C:/Perl/site/lib/auto/Math/Stat/ folder (If this Math folder does not exist, then crate one here). Please note that every package may not have autosplit.ix file. In other words, autosplit.ix file may not be available for every package. If it is not available there, then there is no need to put it. vi) Now, open C:/Perl/site/lib/auto/Math/.packlist file (If this Math folder does not exist, then crate one here) and make an entry corresponding to the .pm file. For example, the entry will be like this in .packlist file. vii) Repeat steps (iii) to (vi) for each of the .pm file present in the zip file for the package.
This discusses about installing Perl modules on Windows, using PPM tool or manually.
ethanol/Slider, a Mootools (1.2.x) class. ( JavaScript)
/*
Copyright (c) 2009 Robert Jan Bast
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Slider.js
Simple class for sliding elements within a container.
Sample HTML, CSS and JS
HTML
<div id="parent">
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<div class="d"></div>
</div>
CSS
div{width:100px;height:100px}
#parent{overflow:hidden;}
.a{background-color:blue}
.b{background-color:red}
.c{background-color:green}
.d{background-color:yellow}
JS
var slider = new Slider('parent'); // default behavior
or var slider = new Slider('parent', {mode:'vertical', endless:true}); // up & down, endlessly
or var slider = new Slider('parent', {endless:true, onStart:function(){this.previous()}}); // reversed, endlessly
*/
var Slider = new Class({
Implements: [Options, Events],
options: {
childrenSelector: 'div',
endless: false,
mode: 'horizontal', // horizontal | vertical
autoSlide: true,
autoDelay: 2000,
fxOptions: {
duration: 2000
},
onStart: function(){
this.next();
},
onFirst: function(){
this.next();
},
onLast: function(){
this.previous();
},
onNext: function(){},
onPrevious: function(){},
onStop: function(){},
onPause: function(){},
onResume: function(){}
},
container: null,
children: [],
stack: {
next: [],
previous: []
},
fx: null,
timeoutId: null,
initialize: function(container, options){
// Grab & extend our container element
this.container = $(container);
// Wtfux?
if (!this.container){
alert('You failed the internet, do not pass start and do not collect awesome fx effects');
}
// Apply options passed
this.setOptions(options);
// Grab all (current) children of our container, based on selector given
this.children = this.container.getElements(this.options.childrenSelector).setStyle('float', 'left');
// Stoopid, durrr
if (this.children.length < 2){
alert('Failure is imminent, it takes two to tango');
}
// Grab all children other than the currently visible one and loop through them
this.children.slice(1,this.children.length).each(
function(el){
// Remove each element from the DOM and push them onto the 'next' stack
this.stack.next.push(el.dispose());
// I bind 'this', because otherwise this.stack is not accessible
}.bind(this)
);
// If autoslide option is true
if (this.options.autoSlide){
// Start! durrr
this.start();
}
},
start: function(){
this.fireEvent('start');
},
stop: function(){
if (this.timeoutId){
$clear(this.timeoutId);
}
this.fireEvent('stop');
},
next: function(){
// Check if we still have elements in the next stack OR if endless mode is set
if (this.stack.next.length || this.options.endless){
// If we have no more elements on the 'next' stack, we assume endless mode is true
if (!this.stack.next.length){
// Grab the last item from the 'previous' stack and push it onto the 'next' stack
this.stack.next.push(this.stack.previous.pop());
}
// Get the current child, use selector given just to be sure we get the right one
var currChild = this.container.getFirst(this.options.childrenSelector);
// Get the next child we want
var nextChild = this.stack.next.shift();
// Generate the options object
var opts = {'0': {}, '1': {}};
// Figure out which mode we are running in
switch (this.options.mode){
// Vertical is ^ v
case 'vertical' :
// So we mess with top margin of current child
opts['0']['margin-top'] = [0, -currChild.getStyle('height').toInt()],
// And with bottom margin of the next child
opts['1']['margin-bottom'] = [-currChild.getStyle('height').toInt(), 0];
// Apply the bottom margin to the to be inserted child and inject it into the dom
nextChild.setStyle('margin-bottom', -currChild.getStyle('height').toInt()).inject(currChild, 'after');
break;
// Horizontal is < >
case 'horizontal' :
default :
// So we mess with left margin of current child
opts['0']['margin-left'] = [0, -currChild.getStyle('width').toInt()],
// And with right margin of the next child
opts['1']['margin-right'] = [-currChild.getStyle('width').toInt(), 0];
// Apply the right margin to the to be inserted child and inject it into the dom
nextChild.setStyle('margin-right', -currChild.getStyle('width').toInt()).inject(currChild, 'after');
break;
}
// Are we in autoslide mode?
if (this.options.autoSlide){
// Is there a timer active?
if (this.timeoutId){
// Clear it
$clear(this.timeoutId);
}
// Generate the fxOptions object by merging default with some extra options
var fxOptions = $merge(this.options.fxOptions, {
// Add a onComplete event
onComplete: function(e){
// When we're done, set a timer again, cause this is like, autoslide mode, mkay
this.timeoutId = this.next.delay(this.options.autoDelay, this);
// Binding 'this' cause otherwise this.next and such are not accessible
}.bind(this)
});
// No autoslide mode
} else {
// Default options are sufficient
var fxOptions = this.options.fxOptions;
}
// Create the fx instance with the custom options, and add a chained function
this.fx = new Fx.Elements($$(currChild, nextChild), fxOptions).start(opts).chain(
function(){
// When we are done, dispose of the current child and put it on the 'previous' stack
this.stack.previous.unshift(currChild.dispose().setStyles({'margin-top':0,'margin-bottom':0,'margin-left':0,'margin-right':0}));
// Again, binding 'this' for accessibility
}.bind(this)
);
// We've moved to the next element, fire event!
this.fireEvent('next', nextChild);
// Ohnoez, no more elements and no endless mode :(
} else {
// Since there are no more elements, fire the last event
this.fireEvent('last');
}
},
previous: function(){
// Check if we still have elements in the previous stack OR if endless mode is set
if (this.stack.previous.length || this.options.endless){
// If we have no more elements on the 'previous' stack, we assume endless mode is true
if (!this.stack.previous.length){
// Grab the last item from the 'next' stack and push it onto the 'previous' stack
this.stack.previous.push(this.stack.next.pop());
}
// Get the current child, use selector given just to be sure we get the right one
var currChild = this.container.getFirst(this.options.childrenSelector);
// Get the previous child we want
var prevChild = this.stack.previous.shift();
// Generate the options object
var opts = {'0': {}, '1': {}};
// Figure out which mode we are running in
switch (this.options.mode){
// Vertical is ^ v
case 'vertical' :
// So we mess with bottom margin of current child
opts['0']['margin-bottom'] = [0, -currChild.getStyle('height').toInt()],
// And with top margin of the previous child
opts['1']['margin-top'] = [-currChild.getStyle('height').toInt(), 0];
// Apply the top margin to the to be inserted child and inject it into the dom
prevChild.setStyle('margin-top', -currChild.getStyle('height').toInt()).inject(currChild, 'before');
break;
// Horizontal is < >
case 'horizontal' :
default :
// So we mess with right margin of current child
opts['0']['margin-right'] = [0, -currChild.getStyle('width').toInt()],
// And with left margin of the next child
opts['1']['margin-left'] = [-currChild.getStyle('width').toInt(), 0];
// Apply the left margin to the to be inserted child and inject it into the dom
prevChild.setStyle('margin-left', -currChild.getStyle('width').toInt()).inject(currChild, 'before');
break;
}
// Are we in autoslide mode?
if (this.options.autoSlide){
// Is there a timer active?
if (this.timeoutId){
// Clear it
$clear(this.timeoutId);
}
// Generate the fxOptions object by merging default with some extra options
var fxOptions = $merge(this.options.fxOptions, {
// Add a onComplete event
onComplete: function(e){
// When we're done, set a timer again, cause this is like, autoslide mode, mkay
this.timeoutId = this.previous.delay(this.options.autoDelay, this);
// Binding 'this' cause otherwise this.previous and such are not accessible
}.bind(this)
});
// No autoslide mode
} else {
// Default options are sufficient
var fxOptions = this.options.fxOptions;
}
// Create the fx instance with the custom options, and add a chained function
this.fx = new Fx.Elements($$(currChild, prevChild), fxOptions).start(opts).chain(
function(){
// When we are done, dispose of the current child and put it on the 'next' stack
this.stack.next.unshift(currChild.dispose().setStyles({'margin-top':0,'margin-bottom':0,'margin-left':0,'margin-right':0}));
// Again, binding 'this' for accessibility
}.bind(this)
);
// We've moved to the previous element, fire event!
this.fireEvent('previous', prevChild);
// Ohnoez, no more elements and no endless mode :(
} else {
// Since there are no more elements, fire the first event
this.fireEvent('first');
}
},
pause: function(){
this.fx.pause();
this.fireEvent('pause');
},
resume: function(){
this.fx.resume();
this.fireEvent('resume');
}
});