Xanax onlineAdderall onlineLevitraviagra without prescriptionadderall onlineadderall without prescriptionPhentermine onlinetramadol onlinevalium online
Jul18

Making wordpress parent navigation items unclickable with jquery

I’m developing a new site that has a navigation that is built dynamically via wordpress’ wp_list_pages function

<?php  wp_list_pages('sort_column=menu_order&title_li=&exclude=6'); ?>

Navigation items that have submenus (css dropdowns) are still clickable, but for this website they have no content. I wanted a way to make those items unclickable. I was unable to find any way with wordpress’ api, but I did find a way with jquery.

$('#navigation_ul > li > a').filter(function() { return $(this).siblings().length == 1 }).attr( 'href', '#' ).attr( 'onClick', 'return false' );

This sets the href to ‘#’, and onClick to ‘return false’ of all navigation links that have submenus

Jun20

Redirect non-www to www in django

In your settings file add

PREPEND_WWW = True

Then run syncdb

python manage.py syncdb
Jun02

Accessing dictionaries inside lists with Django templates

Click here to skip the story and straight to the code

Today while working on the new SVO i ran into an issue with the coding of breadcrumbs. I wanted to pull the breadcrumb code out of each page template and put it into the header template.

This is what i had originally in each template:

<p id="breadcrumbs">
    <a href="/">Home</a><span class="bc_sep">></span>
    <a href="{% url videos %}">Videos</a><span class="bc_sep">></span>
    <a href="{% url company video.company.id video.company.name|slugify %}">{{ video.company.name }}</a><span class="bc_sep">></span>
    <strong>{{ video.name }}</strong>
</p>

This quickly became annoying, repeating this code in every pag’es template. I decided to create a list of dictionaries inside each view to represent the breadcrumbs:

breadcrumbs = []
breadcrumbs.append( { 'home':reverse( 'home' ) } )
breadcrumbs.append( { 'skaters':reverse( 'skaters' ) } )
breadcrumbs.append( { index:'' } )
return render_to_response('index.html', {...'breadcrumbs':breadcrumbs})

Then in my template i loop the list and extract the dictionary:

<p id="breadcrumbs">
{% for breadcrumb in breadcrumbs %} #this loops the list
	{% for text, link in breadcrumb.items %} #this extracts the dictionary inside each list
		{% if link %}
			<a href="{{ link }}">{{ text|capfirst }}</a><span class="bc_sep">></span>
		{% else %}
			<strong>{{ text|capfirst }}</strong>
		{% endif %}
	{% endfor %}
{% endfor %}
</p>

The for loop seems like an “ugly” way to access the inner dictionary but i was unable to find a better method.

Mar27

Flush cache in Windows, Mac, and Ubuntu

Windows: Open a cmd prompt. Type:

ipconfig /flushdns

Mac: Open a terminal. Type:

dscacheutil -flushcache

Ubuntu: Open a terminal. Type:

sudo /etc/init.d/networking restart
Feb22

CSS & Javascript image preloader

While building a photo gallery for a client I ran into an issue where the photos took too long to load and clicking thumbnails before all the photos loaded resulted in ugly transitions.

My solution was to put a semi-transparent “shield” (containing a loading animation) over the gallery. The user will be able to see the images loading, but will be unable to click anything until all images are loaded and the shield is hidden. Here’s the finished product.

Explanation follows the code.

Here’s the html. This goes inside the div that contains your gallery.

<div id="gallery_loader"> <!-- wrapper for shield -->
    <div></div> <!-- this is the actual shield -->
    <img src="animated_loader.gif"><!-- image preloader -->
</div>

…and the CSS:

#gallery_loader {
    position:absolute; /* Position the wrapper at the top left corner */
    top:0;
    left: 0;
    width:100%; /* cover the entire width of your gallery */
    height:100%; /* cover the entire height of your gallery */
    overflow:hidden; /* hide anything that might overflow */
    z-index:999; /* make sure the shield is on top over everything */
}
#gallery_loader div { /* the actual shield */
    position:absolute; /* Position the shield at the top left corner of the wrapper */
    top:0;
    left:0;
    width:100%; /* Take up the entire wrapper */
    height:100%; /* Take up the entire wrapper */
    background: #fff;
    opacity: .8; /* .8 = 80% opacity for all non-ie browsers*/
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* This and the next style are for IE */
    filter: alpha(opacity=80);
}
#gallery_loader img {
    position:relative;
    display:block; /* Need this so we can center the image */
    margin: 150px auto 0 auto; /* Set this to whatever looks good */
    padding: 30px; /* Adjust to your needs */
    background: #fff;
    border: 1px solid #333;
    -moz-border-radius:5px; /* Round corners in mozilla browsers */
    -webkit-border-radius: 5px; /* Round corners for webkit browsers */
}

Put this inside an included javascript file. This will wait until the page is loaded entirely (images and all) and then fade the loader out. Requires jquery.

$(window).bind("load", function() {
	$('#gallery_loader').fadeOut();
});

#gallery_loader is positioned absolutely and placed on top of everything else (z-index:999). It’s set to take up the entire width/height of its parent. Next comes the shield that will actually do the “blocking” of everything in the gallery. The shield is opacited and set to take up the entire width/height of the wrapper. Finally the animated loading image is loaded and centered.

As you can tell from the HTML, the actual shield is not the container of the loading animation gif. This is because the children of transparent elements can’t be more opaque than their parents. In other words if we put the loading image inside the transparent “shield” (which has an opacity of 80%) it would have a max opacity of 80%. To fix this we put the “shield” underneath the loading image and opacitate it. Here’s a good page on opacity.

Note: If you’re having issues where the loading gif isn’t loading immediately add this right after the opening of your body element

<body>
<img src="animated_loader.gif" style="display:none">
...

This will cause the loading gif to load first.

Here is where i obtained my loading gif

Feb11

Add a category to your magento homepage

  1. In the admin menu navigate to CMS -> Manage pages.
  2. Click Home page to edit it.
  3. Enter this code substituting The category id of the category you want to show for CATEGORY_ID
{{block type="catalog/product_list" category_id="CATEGORY_ID" template="catalog/product/list.phtml"}}

To get the category id go to Catalog -> Manage Categories and click the category you wish to add to your homepage. The category id will be in parenthesis at the top (ID: XX)

Feb01

Adding custom text message sounds to your iphone

For this work your phone must be jailbroken.

  1. Open itunes and go into preferences.
  2. Under the general tab click the import settings button and change import using to aiff encoder.
  3. Right click your text message sound (add the sound to your library if you haven’t already) and go to create aiff version.
  4. Rename the file to sms-received6.caf (if you need it).
  5. Using whatever method you want put the file into your iphone under /System/Library/Audio/UISounds/ (i use iphone explorer). Overwrite the old file.
  6. On your phone go to your text message sound settings and click the last text message sound. You should recognize it.
Dec31

Button 1px “bug” in firefox

When styling a button using the sliding doors technique i found that firefox shifted the span down 1px, thus foiling the entire idea of sliding doors.

To fix it use this:

button::-moz-focus-inner { border: none;}
Dec27

Creating a mac pandora dashboard widget

  • In safari (must use safari) go to pandora.com and login or signup
  • Go to file->Open in dashboard
  • Select the main pandora window and adjust the edges to fit the area you want
  • Click Add on the top right of your screen
  • On the widget click the i on the bottom right and uncheck the only play audio in dashboard option

Tip: To refresh the widget press CMD+R

Dec24

VirtualHost *:80 — mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

Today while setting up an ssl certificate i obtained for my new installation of activecollab i ran into this error:

VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

To fix this add this to the beginning of your virtual host

NameVirtualHost *:443

Also change

<VirtualHost *>

to

<VirtualHost *:443>

Then restart apache