Skip to content

Instantly share code, notes, and snippets.

View Shinya-T's full-sized avatar

Shinya Shinya-T

  • Fukuoka City, JP
View GitHub Profile
@Shinya-T
Shinya-T / call_tota.rb
Created July 3, 2014 15:33
call_tota.rb
t = Total.new
t.add(shinya, "test")
t.add(shinji, "test")
t.add(shinnosuke, "test")
t.add(shintaro, "test")
t.count
@Shinya-T
Shinya-T / total.rb
Created July 3, 2014 15:31
total.rb
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?)
@Shinya-T
Shinya-T / Test.java
Created June 17, 2014 08:14
Test.java
public class Test {
public static void main(String[] args) {
Calc c = new Calc();
c.calc(任意の数字, 0);
System.out.println(c.cnt);
}
}
@Shinya-T
Shinya-T / Calc.java
Created June 17, 2014 08:11
Calc.java
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);
@Shinya-T
Shinya-T / show.json.jbuilder
Created June 8, 2014 11:28
show.json.jbuilder
json.extract! @user, :id, :name, :password, :created_at, :updated_at
@Shinya-T
Shinya-T / show.html.erb
Created June 8, 2014 11:27
show.html.erb
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= @user.name %>
</p>
<p>
<strong>Password:</strong>
<%= @user.password %>
@Shinya-T
Shinya-T / users_controller.rb
Created June 8, 2014 11:11
users_controller.rb
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