Skip to content

Instantly share code, notes, and snippets.

@linusthe3rd
linusthe3rd / circles.cpp
Created January 30, 2011 18:54
The two methods used to create circles in opengl
/*
* Function that handles the drawing of a circle using the triangle fan
* method. This will create a filled circle.
*
* Params:
* x (GLFloat) - the x position of the center point of the circle
* y (GLFloat) - the y position of the center point of the circle
* radius (GLFloat) - the radius that the painted circle will have
*/
void drawFilledCircle(GLfloat x, GLfloat y, GLfloat radius){
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
validates :addressable, :presence => true
validates :street_1, :presence => true
validates :city, :presence => true
validates :state, :presence => true, :length => { :minimum => 2 }
validates :zip_code, :presence => true, :zipcode_format => true, :length => { :minimum => 5, :maximum => 10 }
validates :country, :presence => true
end
test "should create camp" do
assert_difference('Camp.count') do
post :create, :camp => {
:name => "Camp Tester",
:uri => "test-camp",
:email_address => "test@test.com",
:address => {
:street_1 => "mccormick rd",
:city => "barrer",
:state => "MA",
float x = (float) getLocation().getX() / width;
float y = (float) (height - getLocation().getY()) / height;
float w = (float) getSize().getWidth() / width;
float h = (float) getSize().getHeight() /
float radius = (w < h) ? w : h;
gl.glBegin(GL2.GL_TRIANGLE_FAN);
gl.glVertex2f(x, y);
for(int i = 0; i<360; i+=5){
gl.glVertex2f(x + (float)Math.sin(i) * radius, y + (float)Math.cos(i) * radius);
(function() {
//set up your widget
dojo.declare("MyTable", dijit._Widget, {
postCreate: function(){
this.inherited(arguments);
//initialize your default state...
@linusthe3rd
linusthe3rd / gist:705094
Created November 18, 2010 15:08
Example of how to write a refresh method
(function() {
//set up your widget
dojo.declare("MyTable", dijit._Widget, {
/*
* An example of a Refresh method in a widget
*/
refresh: function(){
@linusthe3rd
linusthe3rd / gist:705083
Created November 18, 2010 15:00
Updating a dojo widget's date
function updateTheWidget(){
var newData = getData() // handles the xhr request to retrieve the new set of data
theWidget.attr("data", newData); //update the widget with the new set of data
theWidget.refresh(); //refresh the widget UI
}
(function() {
//set up your widget
dojo.declare("MyTable", dijit._Widget, {
//initiation methods for your widget
destroy: function(){
//destroy your child widgets
//==================
// Track a widget
//==================
var actionButtons = new ActionButtons(); //ActionButtons now needs to be destroyed!!
this._childWidgets.push(actionButtons);
//==================
// Track an event handler
//==================
var handle = dojo.connect( /*your params*/ );
(function() {
//set up your widget
dojo.declare("MyTable", dijit._Widget, {
constructor: function(args){
//other stuff to instantiate
this._childWidgets = [];