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
t = Total.new | |
t.add(shinya, "test") | |
t.add(shinji, "test") | |
t.add(shinnosuke, "test") | |
t.add(shintaro, "test") | |
t.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
require 'mongo' | |
class total | |
def initialize | |
db = URI.parse(ENV['MONGOHQ_URL']) | |
db_name = db.path.gsub(/^\//, '') | |
@mongo = Mongo::Connection.new(db.host, db.port).db(db_name) | |
@mongo.authenticate(db.user, db.password) unless (db.user.nil? || db.user.nil?) | |
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 Test { | |
public static void main(String[] args) { | |
Calc c = new Calc(); | |
c.calc(任意の数字, 0); | |
System.out.println(c.cnt); | |
} | |
} |
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 Calc { | |
public int cnt = 0; | |
public void calc(int n, int m) { | |
cnt++; | |
if (m > n) | |
return; | |
for (int i = 0; i < n; i++) { | |
calc(n, m + 1); |
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
json.extract! @user, :id, :name, :password, :created_at, :updated_at |
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
<p id="notice"><%= notice %></p> | |
<p> | |
<strong>Name:</strong> | |
<%= @user.name %> | |
</p> | |
<p> | |
<strong>Password:</strong> | |
<%= @user.password %> |
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 UsersController < ApplicationController | |
before_action :set_user, only: [:show, :edit, :update, :destroy] | |
# GET /users | |
# GET /users.json | |
def index | |
@users = User.all | |
end | |
# GET /users/1 |