This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gist_is_neat() | |
puts "check me out, I'm embedded code" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ListQueue extends LinkedList<Object> | |
{ | |
// write your code here | |
} | |
public class MainClass | |
{ | |
public static void main( String[] args ) | |
{ | |
LinkedList<Object> q = new ListQueue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ListQueue extends LinkedList<Object> | |
{ | |
public boolean isEmpty() { return size() == 0; } | |
public boolean add( Object x ) | |
{ | |
addLast( x ); | |
return true; | |
} | |
public Object remove() { return removeFirst(); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation 1 | |
class Base | |
## returns a positive integer from 1..100, inclusive | |
def get_number | |
5 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation 2 | |
class Base | |
## gets the number of files in the current directory, otherwise raises DiskError | |
def get_number | |
5 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation 3 | |
class Base | |
def get_number | |
raise NotImplementedError | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_random_number | |
8 ## <-- number was chosen at random | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
struct listnode { | |
int head; | |
struct listnode *tail; | |
}; | |
struct listnode *cons(int data, struct listnode *list) { | |
struct listnode *newlist = malloc(sizeof (struct listnode)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bad code | |
var url_request = getJSON("https://librivox.org/api/feed/audiobooks/title/^" + input + "?&format=json"); | |
url_request.response // -> null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// good code | |
getJSON("https://librivox.org/api/feed/audiobooks/title/^" + input + "?&format=json", | |
function(url_request) { | |
url_request.response // -> Object { books: Array[50] } | |
}); |
OlderNewer