Sniptastic! beta

Public Snippets

ALLEGRO_EVENT_QUEUE


ALLEGRO_EVENT QUEUE *event_queue = NULL;

        
Language: C / C++
Posted by robthecoder on 5/17/2012 4:40:59 PM

Get variable in Javascript


function getUrlVar(key){
	var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search); 
	return result && unescape(result[1]) || ""; 
}

        
Language: JavaScript
Posted by jaramire on 5/13/2012 6:28:22 PM

Javascript read get variable


function getQueryVariable(variable) { 
var query = window.location.search.substring(1); 
var vars = query.split("&"); 
for (var i = 0; i < vars.length; i++) { 
var pair = vars[i].split("="); 
if (pair[0] == variable) { 
return unescape(pair[1]); 
} 
} 
return false; 
}

        
Language: JavaScript
Posted by jaramire on 5/13/2012 6:26:36 PM

octree


#region Using Statements
using System;
using System.Threading;
using System.Configuration;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
#endregion

namespace Endurance_7
{
  public class octNode
  {
    #region fields
    public List<gameObject> objects = new List<gameObject>(); //contains the objects in this node
    public List<octNode> nodes = new List<octNode>(); //contains all child nodes
    public octNode parent;
    private BoundingBox bounds;
    private bool isCulled;
    public Vector3 center;
    public float length;
    private VertexPositionColor[] points;
    private int[] index;
    #endregion
    #region initialization
    public octNode(Vector3 newCenter, float newLength)
    {
      center = newCenter;
      length = newLength;

      load(); //loads bounding lines
    }
    #endregion
    //--------------------------------------------------------------------------------------
    //addObjects
    //--------------------------------------------------------------------------------------
    public void addObject(gameObject newObject)
    {
      if (nodes.Count != 0)
      {
        // If we have children, pass the object to them
        bool fits = false;
        foreach (octNode b in nodes)
        {
           
          if (b.contains(newObject.position))
          {
            b.addObject(newObject);
            fits=true;
          }
        }
          if (fits == false)
              objects.Add(newObject);

      }
        else if (objects.Count >= octManager.maxObjectsPerNode)
        {
          // If no childrem, see if we are already at the max capacity
          // and split and redistribute the objects if we are

          objects.Add(newObject);
          split();
        }
        else
        {
          // Otherwise just add the object
          objects.Add(newObject);
        }
    }
    //--------------------------------------------------------------------------------------
        
Language: C#
Posted by pwei on 5/13/2012 1:13:46 PM

test


# -*- coding: utf-8 -*- 
import numpy as np 
import matplotlib.pyplot as plt 
plt.figure(figsize=(8,4)) 
a = plt.text(0.05, 0.05, u"??????????") 
#Microsoft YaHei,FangSong,YouYuan,SimHei,STKaiti,STSong,SimSun-ExtB,Webdings 
plt.text(0.05, 0.95, u "STSong??", fontproperties='STSong' ) 
plt.text(0.05, 0.85, u"STKaiti??", fontproperties='STKaiti') 
plt.text(0.05, 0.75, u"FangSong??", fontproperties='FangSong') 
plt.text(0.05, 0.65, u"YouYuan??", fontproperties='YouYuan') 
plt.text(0.05, 0.55, u"SimHei??", fontproperties='SimHei') 
plt.text(0.05, 0.45, u"Microsoft YaHei????", fontproperties='Microsoft YaHei') 
plt.text(0.05, 0.35, u"STCaiyun????", fontproperties='STCaiyun') 
plt.show()
        
Language: Python
Posted by pwei on 5/13/2012 12:38:06 PM

dd


dd
        
Language: Python
Posted by pwei on 5/13/2012 12:35:41 PM

Simple WordPress Loop


<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

     <?php the_title();?>
     <?php the_content();?>

<?php endwhile; ?>
        
Language: PHP
Posted by nomadone on 5/12/2012 11:47:03 AM

Example WordPress Loop


<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

	<h3 id="post-<?php the_ID(); ?>">
		<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
	</h3>
	<p class="datebox"><?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></p>

	<div class="contentbox">
    	<?php the_content('Read the rest of this entry &raquo;'); ?>
	</div>
    
    <span class="meta">
		Categories: <?php the_category(', '); ?><br /><?php the_tags(); ?><br />Written by: <?php the_author(); ?><br />
		<div class="commentsbox">
			<?php comments_number('no responses','one response','% responses'); ?><br /><a href="<?php comments_link(); ?>">Post a comment</a>	
		</div>
	</span>

	<?php edit_post_link('Edit', '', ''); ?>
	
<?php endwhile; ?>
        
Language: PHP
Posted by nomadone on 5/12/2012 11:40:46 AM

Tags: loop wordpress

Judge object is a array?


function isArray(o) {
    Object.prototype.toString.call(o) === '[object Array]';
}
        
Language: JavaScript
Posted by biossun on 5/12/2012 4:33:42 AM

Judge object is a array?


function isArray(o) {
    Object.prototype.toString.call(o) === '[object Array]';
}
        
Language: JavaScript
Posted by biossun on 5/12/2012 4:33:20 AM

Languages

Popular Tags

Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29