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
/* | |
* @author Jack Bracken | |
* DFA to recognise the regular expression (0|1 0* 1 0* 1)* | |
* using enums. | |
*/ | |
interface State { | |
public State next(Token word); | |
} |
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
require 'net/http' | |
require 'json' | |
require 'uri' | |
class GitHub < Plugin | |
def help(plugin, topic="") | |
"Github plugin, print information about github user" | |
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
function krisKindle() { | |
"use strict"; | |
var peopleInKrisKindle, bag, key, giver,firstGiver, receiver, sendMail; | |
sendMail = function(giver, receiver) { | |
var email = peopleInKrisKindle[giver], | |
subject = "Secret Santa", | |
message = "You have to get a gift for " + receiver; | |
MailApp.sendEmail(email, subject, message); | |
}; | |
peopleInKrisKindle = { |
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
int i = 0; | |
System.out.println("OUTPUT:"); | |
if(true) { | |
i++; | |
System.out.println(i); | |
} | |
/* |
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 game_over? | |
count = 0 | |
token = last_token = "" | |
@board.each_index do |col| | |
# Look ahead then track back in each column | |
0.upto(2) do |y| | |
# If the space we are looking at is empty then skip it | |
next if @board[col][y].eql?(EMPTY_SPACE) | |
next unless @board[col][y].eql?(@board[col][y + 3]) |
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
<head> | |
<!-- Basic Meta Info --> | |
<meta charset="utf-8"> | |
<title> | |
Congratulations! | |
</title> | |
<meta name="description" content="On your engagement!"> | |
<meta name="author" content="Alan, Grace, Jack, Paul, Shaun and Erik"> | |
<!-- Mobile Specific Metas --> |
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
[~]$ javac Test.java | |
Test.java:4: error: variable i might not have been initialized | |
System.out.print(i); | |
^ | |
1 error | |
[~]$ cat Test.java | |
public class Test { | |
public static void main(String[] args) { | |
int i; | |
System.out.print(i); |
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
[~]$ cat Test.java | |
public class Test { | |
private int i; | |
public int getI() { | |
return i; | |
} | |
public static void main(String[] args) { | |
Test t = new Test(); | |
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 authenticate_user_from_token! | |
user_token = request.headers['Auth-Token'].presence || params[:auth_token].presence || nil | |
user = user_token && User.find_by_authentication_token(user_token.to_s) | |
if user | |
@current_user = user | |
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
class CreateSomeModel < ActiveRecord::Migration | |
create_table :some_model do |t| | |
# SomeModel :active should always default to false | |
t.boolean :active, null: false, default: false | |
end | |
end | |
class SomeModel < ActiveRecord::Base | |
# But Model scope will override it | |
default_scope{ where(active: true) } |
OlderNewer