<?php $my_query = new WP_Query('cat=10&showposts=4'); ?>
<?php $count = 0; ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
<?php $count++; ?>
<?php if ($count == 1) : ?>
<div id="featured">
<div class="span-24 last" id="details">HTML Ipsum Presents</div>
<!-- end details -->
<h2 class="clear"><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2>
<p class="clear"><?php the_content('read more...'); ?></p>
</div>
<hr/>
<?php elseif ($count == 4) : ?>
<div class="span-8 last">
<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
<p class="clear"><?php the_content('read more...'); ?></p>
</div>
<?php else : ?>
<div class="span-8 border">
<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
<p class="clear"><?php the_content('read more...'); ?></p>
</div>
<?php endif; ?>
<?php endwhile; ?>
Tag Archive for loop
WordPress Loop, Style displayed posts differently
Fastest loop iteration
// fastest way to iterate through a loop
// - set var to :int
// - count down from desired loop count to zero
// - on each count we test the Boolean value of j (j<1 makes it false)
// - instead of counting down with j-- we use j += -1 because adding negative
// numbers is faster than subtracting
//
for(var j:int=10; j; j += -1){}
fix for looping sound pause issue in AS3
private var st:SoundTransform = new SoundTransform(0);
private const max:int = int.MAX_VALUE;
private var context:SoundLoaderContext = new SoundLoaderContext(2000, true);
private var bkdSound:URLRequest = new URLRequest("background.mp3");
private var bkdS:Sound = new Sound();
private var pausePoint:Number = 0.00;
private var paused:Boolean = false;
function init():void{
bkdS.load(bkdSound, context);
//START PLAYING THE SOUND
bkdChannel = bkdS.play(0, max, st);
}
function pauseSound():void{
if(!paused){
//THIS PART IS THE KEY YOU NEED TO % INTO THE LENGTH OF THE SOUND
pausePoint = bkdChannel.position % bkdS.length;
bkdChannel.stop();
paused = true;
}else{
//USE THIS TO RESUME//
bkdChannel = bkdS.play(pausePoint, max, st );
paused = false;
}
}
Generate and recurse through the alphabet
puts ("a".."z").to_a
#=> [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
("a".."z").each{|letter| puts letter}
jQuery loop and hide on child elements of multiple parents
var counter;
$("#ukn-clusters ul.ukn-component-main li ul").each(function() {
counter = 1;
$(this).children("li").each(function() {
if (counter > 3) $(this).addClass('ukn-cluster-hidden').hide()
counter++;
});
});
Iterate through years and months
for year in `seq 2006 2010` do for month in `seq 1 12` do echo $year $month done done
How to detect missing values using Arrays
Question:
How do I exclude observations from my PROC FREQ analysis when a value is missing from a list of variables?
Answer:
In the SAS DATA step, you can create a new variable ("miss" in the example below) that is set equal to 1 when a variable has a missing value, 0 otherwise. Use the ARRAY statement and a DO loop to check for missing values across a list of variables; the syntax is:
read more at...
<a href="http://studysas.blogspot.com/2008/11/how-to-detect-missing-values-using.html
" >http://studysas.blogspot.com/2008/11/how-to-detect-missing-values-using.html
source
Array Splitter (random => odd & even)
//get an array and by using it, create two different array which are odd and even
void arraySplitter(int *&array, int size, int &sizeEven, int &sizeOdd, int *&array2)
{
int even = 0;
int odd = 0;
//determine how many member of given array is even and how many of them is odd
for (int i = 0; i < size; i++)
{
if(array[i]%2==0)
{
even++;
}
else
{
odd++;
}
}
//by using even and odd parameter, creates two different array
//which will be used soon
int *arrayOdd= new int[even];
int *arrayEven = new int[odd];
int m = 0;
int n = 0;
//creates arrays which has only even or odd members
for (int i = 0; i < size; i++)
{
if(array[i]%2==0)
{
arrayEven[m] = array[i];
m++;
}
else
{
arrayOdd[n] = array[i];
n++;
}
}
//returns arrays with pass by referance
array = arrayEven;
array2 = arrayOdd;
}
Loop through a DataReader
Dim objDR As SqlClient.SqlDataReader
Dim objCommand As SqlClient.SqlCommand
Dim ConnectionString As String = "YOUR CONNECTION STRING HERE"
Dim objConnection As SqlClient.SqlConnection
Dim ssql As String
objConnection = New SqlClient.SqlConnection(ConnectionString)
ssql = "SELECT * FROM someTable"
If objConnection.State <> ConnectionState.Open Then
objConnection.Open()
End If
objCommand = New SqlClient.SqlCommand(ssql, objConnection)
objDR = objCommand.ExecuteReader(CommandBehavior.CloseConnection)
objCommand = Nothing
If objDR.HasRows Then
While objDR.Read()
' do your code here
' the following gives access
' to the table's field:
' objDR.Item("someField")
End While
End If
objDR.Close()
objDR = Nothing
Use a Generic Dictionary
' Declaring a generic dictionary; adding values.
' Where the Key and Value (String, String) can be any object.
Dim xGD As New Generic.Dictionary(Of String, String)
xGD.Add("key1", "value1")
' Getting access to a value:
Dim value as String = xGD("key1")
' Looping:
For Each xKVP As Generic.KeyValuePair(Of String, String) In xGD
Consoe.Writeline(xKVP.Key & ", " & xKVP.Value)
Next