Skip to content

Instantly share code, notes, and snippets.

View chelseakomlo's full-sized avatar

Chelsea Komlo chelseakomlo

View GitHub Profile
@chelseakomlo
chelseakomlo / sales_engine_helper.rb
Created February 25, 2013 02:57
Module Frank and I created for SalesEngine, to take the place of the "find by" and "find by all" searches in each class. module SalesEngine
module SalesEngine
module Helper
def attribute(name)
define_method name do
instance_variable_get "@#{name}"
end
@chelseakomlo
chelseakomlo / gist:5035826
Created February 26, 2013 04:16
For some reason, the stub to work for remaining slices wouldn't stick, and it kept coming back as a random number.
describe "#slice" do
context "when given no parameters" do
it "returns removes one slice of the apple" do
apple = Fruit::Apple.new
apple.stub(:remaining_slices).and_return(5)
expect(apple.slice).to eq 1
end
it "reports the correct number of remaining slices" do
apple = Fruit::Apple.new
@chelseakomlo
chelseakomlo / gist:5397911
Created April 16, 2013 17:39
SendConfirmationEmail class
class SendConfirmationEmail
@queue = :confirmation_email
def self.perform(order_user_email, confirmation_code, confirmation_hash)
UserMailer.order_confirmation(order_user_email, confirmation_code, confirmation_hash)
end
end
@chelseakomlo
chelseakomlo / gist:5493176
Created May 1, 2013 01:23
Refactoring with Franklinclass PopularityCounterProtocol
def self.increase_popularity ; end
def self.popular ; end
end
class RedisPopularityCounter
#
@chelseakomlo
chelseakomlo / gist:a7ad9e231aa364f90440
Created February 18, 2015 22:11
Example of Async JS Test
describe('fetchCurrentUser', function() {
it('creates a parsed user', function(done) {
var simulatedAjaxResponse = {
firstName: "Tomas",
lastName: "Jakobsen"
};
$.ajax = function(){ return Q(simulatedAjaxResponse); }
var userPromise = fetchCurrentUser();
@chelseakomlo
chelseakomlo / gist:ef7a50ec1f945181c9e1
Created February 18, 2015 22:20
Basic jasmine test
describe("Included matchers:", function() {
it("The 'toBe' matcher compares with ===", function() {
var a = 12;
var b = a;
expect(a).toBe(b);
expect(a).not.toBe(null);
});
});
// structs
// first way of creating structs
#include <stdio.h>
#include <stdlib.h>
struct Person {
char *name;
int age;
#include <stdio.h>
#include <stdlib.h>
typedef struct person1 {
char *name;
}Person1;
struct Person2 {
char *name;
};
#include <stdio.h>
// miniunit
// source: http://www.jera.com/techinfo/jtns/jtn002.html
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
#define mu_run_test(test) do { char *message = test(); tests_run++; \
if (message) return message; } while (0)
extern int tests_run;
@chelseakomlo
chelseakomlo / receive steps server
Last active September 13, 2015 00:08
Socket programming
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <netdb.h>
#include <string.h>
#include <netinet/in.h>
int main(int argc, char *argv[]) {