Skip to content

Instantly share code, notes, and snippets.

View CaglarGonul's full-sized avatar

ccocoo CaglarGonul

View GitHub Profile
@CaglarGonul
CaglarGonul / 1. Subject.java
Created April 8, 2013 13:20
A built in observer pattern. It seems it is no different than my callback implementation in Java
package com.chp2.observerpattern.custom;
/**
* The objects who will broadcast events will implement this interface
*/
public interface Subject {
public void registerObserver(Observer o);
public void removeObserver(Observer o);
public void notifyObservers();
}
@CaglarGonul
CaglarGonul / 1. CallBack.java
Created April 10, 2013 14:42
This time I understood what a closure is...
package com.fs;
public interface CallBack {
void m(int e);
}
@CaglarGonul
CaglarGonul / cl.c
Created April 11, 2013 19:55
From Dan Grossman course. How to use closures in C.
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
typedef struct List list_t;
struct List {
void * head;
list_t * tail;
};
list_t * makelist (void * x, list_t * xs) {
@CaglarGonul
CaglarGonul / SimpleWS.java
Created May 4, 2013 13:38
A simple web service implementation.
package org.example.simplecalculationsservice;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
@CaglarGonul
CaglarGonul / 01.Beverage.java
Last active December 24, 2015 00:09
Beverage class which holds the abstract information of a beverage.
package com.v1;
import java.util.ArrayList;
import java.util.List;
public abstract class Beverage {
String description ;
List<ICondiment> condiments = new ArrayList<ICondiment>();
public void addCondiment(ICondiment condiment){