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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
helper_method :current_user | |
private | |
def current_user | |
@current_user ||= User.find(session[:user_id]) if session[:user_id] | |
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
gem "omniauth-twitter" |
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 'rubygems' | |
require 'active_record' | |
require 'mysql2' | |
require 'yaml' | |
dbconfig = YAML::load(File.open('database.yml')) | |
ActiveRecord::Base.establish_connection(dbconfig) | |
class Duck < ActiveRecord::Base | |
end | |
puts Duck.count |
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 Kary | |
{ | |
public static void main(String[] args) | |
{ | |
int i = Integer.parseInt(args[0]); | |
int k = Integer.parseInt(args[1]); | |
int v = 1; | |
while (v <= i/k) | |
v *= k; | |
int n = 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
public class Hadamard | |
{ | |
public static void main(String[] args) | |
{ | |
int N = Integer.parseInt(args[0]); | |
boolean[][] H = new boolean[N][N]; | |
H[0][0] = true; | |
for(int n = 1; n < N; n += n) | |
{ | |
for(int i = 0; i < n; 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
public class Calendar | |
{ | |
public static boolean isLeapYear(int year) | |
{ | |
if((year % 4 ==0 && year % 100 != 0) || (year % 400 == 0)) | |
return true; | |
return false; | |
} | |
public static String getMonth(int month) | |
{ |
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 Mine | |
{ | |
public static void main(String[] args) | |
{ | |
int M = Integer.parseInt(args[0]); | |
int N = Integer.parseInt(args[1]); | |
double p = Double.parseDouble(args[2]); | |
boolean[][] mine = new boolean[M+2][M+2]; | |
for(int i = 1; i <= M; 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
public class Post | |
{ | |
public static void halfHeight(double i) | |
{ | |
StdDraw.setPenRadius(.01); | |
StdDraw.line(i, 0, i, 1); | |
} | |
public static void fullHeight(double i) | |
{ | |
StdDraw.setPenRadius(0.01); |
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 Ruler | |
{ | |
public static String ruler(int N) | |
{ | |
if (N <= 0) return ""; | |
if (N == 1) return "1"; | |
return ruler(N-1) + N + ruler(N-1); | |
} | |
public static void drawRuler(String a) |
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 BP | |
{ | |
public static String binary(int N) | |
{ | |
if(N / 2 == 0) return "" + N; | |
return binary(N/2) + "" + N % 2; | |
} | |
public static void main(String[] args) | |
{ | |
int N = Integer.parseInt(args[0]); |
OlderNewer