Skip to content

Instantly share code, notes, and snippets.

class Particpant < AR::Base
delegate :require_name?, :require_email?, :require_phone?, :to => :project, :allow_nil => true
with_options :on => :update do
validates_presence_of :name, :if => :require_name?
validates_presence_of :email, :if => :require_email?
validates_presence_of :phone, :if => :require_phone?
end
@reagent
reagent / email.rb
Created October 17, 2012 04:51 — forked from efatsi/email.rb
class Email
def initialize(address)
@address = address
end
def address
@address.strip
end
class EmailCollection
include Enumerable
delegate :each, :to => :email_addresses
def initialize(raw_email_addresses)
@raw_email_addresses = raw_email_addresses
end
def valid_emails
select {|e| e.match(email_regex) }
class Bar
def initialize(name)
@name = name
end
def to_str
@name
end
int main(int argc, char *argv[])
{
int val = 5;
switch(val) {
case 0: do {
case 5:
printf("Got here, value is %d\n", val);
case 4:
printf("Got here, value is %d\n", val);
@reagent
reagent / 2p1s.c
Created November 6, 2012 13:42
2 pointers, 1 string
#include <stdio.h>
int
main (int argc, char *argv[])
{
char *name = "Patrick";
char *other = name;
printf("Name is: %s\n", name);
printf("Other is: %s\n", other);
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
if (argc <= 1) {
printf("Error: You must supply a value\n");
return 1;
}
#include <stdlib.h>
#include <string.h>
char *
str_upcase(char *source)
{
int i = 0;
int shift = 0;
char ch = '\0';
@reagent
reagent / 001_health_check.rb
Created November 21, 2012 16:12
Middleware Response Handler
class HealthCheck
class Middleware
def initialize(application)
@application = application
end
def call(environment)
if environment['PATH_INFO'] == '/health-check'
if HealthCheck.healthy?
@reagent
reagent / .gitignore
Last active December 11, 2015 03:58
Simple buffer library
main
*.o