Skip to content

Instantly share code, notes, and snippets.

View Osmose's full-sized avatar

Osmose Osmose

View GitHub Profile
def someMethod(blah)
# Do some stuff
if somecondition
var1
else
var2
end
end
# Does this perform a single query with the filters or does it perform the first part and filter within Ruby after?
Zombie.where(:type => "Left 4 Dead").order(:name).limit(2)
# Class for a table called "zombies" in MySQL with some columns
class Zombie < ActiveRecord::Base
validates_presence_of :name #name column must exist before saving to DB
validates_uniqueness_of :name #names must be unique
has_many :weapons #The weapons table will have a column describing ownership by zombies
end
# Class for "weapons" table
class Weapon < ActiveRecord::Base
belongs_to :zombie #Other half of ownership, column will be called "zombie_id"
def somemethod
# do stuff!
if somecondition
value
elsif another_condition
somethingelse
else
anothervalue
end
end
# Renders "tags/form" with the @form instance variable defined
<%= render :partial => 'tags/form',
:locals => {:form => post_form} %>
# Renders "customer"; the value in :object is defined as a local variable customer in the partial
<%= render :partial => "customer", :object => @new_customer %>
#include "mpi.h"
#include <stdio.h>
#include <math.h>
int main( int argc, char *argv[])
{
int n, i, k;
double PI25DT = 3.141592653589793238462643;
double pi, h, sum, x, recv_sum;
#include "mpi.h"
#include <stdio.h>
int main(int argc, char *argv[]) {
int numprocs, myid;
int rows;
int pagesPerProcessor;
int begin;
int pageCount;
{-
- Author: Michael Kelly, mkelly01@my.fit.edu
- Course: CSE 4510, Spring 2011
- Project: game, The Triangle Game
-}
module Main where
import List(delete)
-- Main function
#include "mpi.h"
#include <stdio.h>
double getInMat(double* matrix, int width, int col, int row) {
return matrix[(row * width) + col];
}
void setInMat(double* matrix, int width, int col, int row, double val) {
matrix[(row * width) + col] = val;
}
{-
- Author: Michael Kelly, mkelly01@my.fit.edu
- Course: CSE 4510, Spring 2011
- Project: endo1, Saving Endo, Part I
-}
module Main where
-- Main function
main :: IO()