Skip to content

Instantly share code, notes, and snippets.

public interface iSocket {
public iSocket accept() throws IOException;
public InputStream getInputStream() throws IOException;
public OutputStream getOutputStream() throws IOException;
public void close() throws IOException;
public boolean isClosed();
}
@LNA
LNA / bookshelf.rb
Last active August 29, 2015 14:15
Dependency Injection
class BookShelf
def initialize(books, magazines, flowers)
@books = books
@magazines = magazines
@flowers = flowers
end
def find(book)
@books.find(book)
end
@LNA
LNA / how_to_use_it.rb
Last active August 29, 2015 14:15
Polymorphism
vogue_magazine = Magazine.new(vogue)
self_magazine = Magazine.new(self)
# How many pages are there in vogue magazine?
vogue_magazine.pages
# How many pages are there in self magazine?
self_magazine.pages
if (requestURI.equals("/patch-content.txt")) {
String fileOneString = "../cob_spec/public" + requestURI;
System.out.println(fileOneString);
FileWriter fw = new FileWriter(fileOneString, APPEND);
fw.write(DEFAULT_RESPONSE);
System.out.println("it gets here");
} else if (Arrays.asList("/file1", "/file2", "/image.jpeg", "/image.png", "/image.gif", "/text-file.txt").contains(requestURI)) {
byte[] body = pageBuilder.getBody(requestURI);
out.write(body);
@LNA
LNA / parameter_decode
Last active August 29, 2015 14:14
Parameter Decode, Partial Content, And Patch HTTP Requests
GET /parameters?variable_1=Operators%20%3C%2C%20%3E%2C%20%3D%2C%20!%3D%3B%20%2B%2C%20-%2C%20*%2C%20%26%2C%20%40%2C%20%23%2C%20%24%2C%20%5B%2C%20%5D%3A%20%22is%20that%20all%22%3F&variable_2=stuff HTTP/1.1
@LNA
LNA / headers.html
Created January 29, 2015 16:59
Headers Vrs. Body
[~] curl -v http://justinjackson.ca/words.html
* Adding handle: conn: 0x7fe4a2004000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fe4a2004000) send_pipe: 1, recv_pipe: 0
* About to connect() to justinjackson.ca port 80 (#0)
* Trying 104.130.236.182...
* Connected to justinjackson.ca (104.130.236.182) port 80 (#0)
> GET /words.html HTTP/1.1
@LNA
LNA / iterate.java
Created January 27, 2015 16:42
Read multiple lines for a request
String Line = buff.readLine();
while((line=buff.readLine())!=null){
System.out.println(line);
}
@LNA
LNA / gist:57bf0d6f91414e608996
Last active August 29, 2015 14:14
Exercism Process Fail. Everything passes when I comment out the tests that test email. Soooo....
rake aborted!
Command failed with status (1): [ruby -I"lib" -I"/Users/latoyaallen/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib" "/Users/latoyaallen/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/acceptance/account_test.rb" "test/acceptance/authentication_test.rb" "test/acceptance/nits_test.rb" "test/acceptance/static_page_test.rb" "test/acceptance/team_test.rb" "test/api/assignments_test.rb" "test/api/comments_test.rb" "test/api/exercises_test.rb" "test/api/iterations_test.rb" "test/api/looks_test.rb" "test/api/stats_test.rb" "test/api/submissions_test.rb" "test/api/users_test.rb" "test/api_test.rb" "test/app/comment_threads_test.rb" "test/app/exercises_test.rb" "test/app/helpers/fuzzy_time_test.rb" "test/app/helpers/markdown_test.rb" "test/app/helpers/ng_esc_test.rb" "test/app/helpers/site_title_helper_test.rb" "test/app/helpers/submissions_helper_test.rb" "test/app/nitpick_test.rb" "test/app/notifications_test.rb" "test/app/presenters/languages_test.rb" "test/app/presenters/profile_
@LNA
LNA / cob_spec_test_set_up
Created January 21, 2015 17:01
http://localhost:9090/HttpTestSuite?edit
!3 Test Parameters
!define TEST_SYSTEM {slim}
!path target/Fixtures-1.0.jar
!3 User-Defined Variables
!define SERVER_START_COMMAND {java -jar /Users/latoyaallen/projects/httpServer/jars/httpServer.jar}
!define PUBLIC_DIR {/Users/latoyaallen/projects/cob_spec/public/}
!contents -R2 -g -p -f -h
@LNA
LNA / fix_me.rb
Last active August 29, 2015 14:13
<<<<<<< HEAD
# This is where the code that was pushed to master by your teammate was added. It was added
# after you created the current branch you are working on. That's why you have conflicts!
=======
# This is where some dead code, that your team mate deleted would be.