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 UniqunessCheck { | |
public boolean isUnique(String str){ | |
boolean isUnique = true; | |
for(int i = 0; i < str.length(); i++){ | |
for(int k = 0; k < str.length(); k++){ | |
if(i != k){ | |
if(str.charAt(i).equals(str.charAt(k))){ | |
isUnique = false; | |
break; | |
} |
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 boolean isUnique(String str) { | |
boolean isUnique = true; | |
HashSet<Character> hs = new HashSet<>(); | |
for(char c: str.toCharArray()){ | |
if(!hs.contains(c)){ | |
hs.add(c); | |
}else{ | |
isUnique = false; | |
break; | |
} |
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 FizzBuzz { | |
public void getResultOfFizzBuzz(){ | |
for(int i = 1; i <= 100; i++){ | |
if(calcRemainder(i, 3) == 0 && calcRemainder(i, 5) == 0){ | |
System.out.println("FizzBuzz"); | |
}else if(calcRemainder(i, 3) == 0){ | |
System.out.println("Fizz"); | |
}else if(calcRemainder(i, 5) == 0){ | |
System.out.println("Buzz"); | |
}else{ |
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 int fibonacci(int n){ | |
if(n == 0) return 0; | |
if(n == 1 || n == 2) return 1; | |
return fibonacci(n - 2) + fibonacci(n - 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
# 以下2つのファイルを require する | |
require "rails_admin/config/actions" | |
require "rails_admin/config/actions/base" | |
module RailsAdmin | |
module Config | |
module Actions | |
class DisplayOrderAction < RailsAdmin::Config::Actions::Base | |
RailsAdmin::Config::Actions.register(self) | |
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 する | |
require Rails.root.join('lib', 'display_order_action.rb') | |
RailsAdmin.config do |config| | |
config.actions do | |
dashboard # mandatory | |
index # mandatory | |
new | |
export | |
bulk_delete |
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
<%= form_tag("", method: "put") do %> | |
<table class="table table-striped table-bordered"> | |
<tr> | |
<th>Name</th> | |
<th>Order</th> | |
</tr> | |
<% @objects.each do |object| %> | |
<tr> | |
<td><%=object.name%></td> | |
<td><input type="number" value="<%=object.order%>" name="products[][order]"></td> |
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
# ほぼオリジナルのパクリ(https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/config/actions/edit.rb) | |
# 今回必要になる部分を追記する | |
module RailsAdmin | |
module Config | |
module Actions | |
class Edit < RailsAdmin::Config::Actions::Base | |
RailsAdmin::Config::Actions.register(self) | |
register_instance_option :member do |
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
/ オリジナル:https://github.com/sferik/rails_admin/blob/master/app/views/rails_admin/main/edit.html.haml | |
= rails_admin_form_for @object, url: edit_path(@abstract_model, @object.id), as: @abstract_model.param_key, html: { method: "put", multipart: true, class: "form-horizontal denser", data: { title: @page_name } } do |form| | |
/ ↓ 挿入部分 ↓ | |
- if @model_name == "Brand" or @model_name == "Item" | |
%table.table{:class => "table-striped table-bordered"} | |
%caption 画像の表示順編集 | |
%tr | |
%th ID | |
- if @model_name == "Product" | |
%th Name |
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 Rails.root.join('lib', 'display_order_action.rb') | |
RailsAdmin.config do |config| | |
config.actions do | |
dashboard # mandatory | |
index # mandatory | |
new | |
export | |
bulk_delete | |
show |
OlderNewer