Skip to content

Instantly share code, notes, and snippets.

View thrashr888's full-sized avatar
🐮
moo

Paul Thrasher thrashr888

🐮
moo
View GitHub Profile
float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
/* `Rounded Corners
----------------------------------------------------------------------------------------------------*/
.round_all {
-khtml-border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
@thrashr888
thrashr888 / gist:286679
Created January 26, 2010 08:38 — forked from 3n/gist:283188
/* css to make <div id="new">NEW</div> into this: http://bit.ly/5sf4sq */
#new {
display:block;
width:40px;
height:30px;
padding-top:10px;
background-color:#F72F3C;
color:white;
text-align:center;
// rotates elements
// requires prototype.js
(function (){
var total = 4;
var i = 1; // counter
var pre = 'news-text-'; // the prefix for the name of the element id
var time = 5; // seconds
setInterval(function(){
for(c=1; c<total; c++){
<?php
/**
* This function just adds a question mark at the end of a string, in a semi-smart way. Should work in most cases.
* @author Paul Thrasher (@thrashr888)
* @date 3/18/2010
*/
function format_question($text, $end = "?"){
$text = ucfirst(trim($text));
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
set :application, "wishcraftdesign"
set :project_name, "wishcraft"
set :application_url, "http://wishcraftdesign.com/site/"
set :scm, :git
set :repository, "git@github.com:thrashr888/Wish-craft.com.git"
set :user, "thrashr888" # your GitHub username
set :scm_passphrase, "xxxxxxxx" # your GitHub password
set :use_sudo, false
// =========================
// SetInterval
// =========================
// While not truly accurate, setInterval is still fairly good, time-wise.
// Better for things like a "one second tick" but not great for expensive
// code executed at small intervals as iterations can "stack".
// (ECMAScript 5 strict mode compatible)
/**
* from Secrets of the JavaScript Ninja by John Resig
* Example:
*
* var hello = tmpl("Hello, <%= name %>!");
* alert(hello({name: "world"}));
*/
(function() {
var cache = {};
this.tmpl = function tmpl(str, data) {