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 Array | |
def insert_and_delete(idx, y) | |
move_elem = self[idx] | |
self.delete_at(idx) | |
self.insert(y, move_elem) | |
end | |
end | |
def insert_sort(arr) | |
num_of = arr.size - 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
ary = [10, 5, 3, 4, 20, 50, 15] | |
#配列を受けて二つに割る。 | |
def split_ary(ary, pivot_idx = 0) | |
left = [] | |
right = [] | |
pivot = 0 | |
ary.each_with_index do |val, index| | |
next if index == pivot_idx | |
if val < ary[pivot_idx] |
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
ary = [10, 5, 3, 4, 20, 50, 15] | |
#配列を受けて二つに割る。 | |
def split_ary(ary, pivot_idx = 0) | |
return ary if ary.empty? | |
left = [] | |
right = [] | |
ary.each_with_index do |val, index| | |
next if index == pivot_idx | |
if val < ary[pivot_idx] |
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 dubble(a) | |
if a.is_a?(Fixnum) | |
result = a * 2 | |
end | |
p result | |
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
module A | |
hoge = "hoge" | |
module B | |
fuga = "fuga" | |
def self.b | |
p hoge | |
end | |
def self.c | |
p fuga |
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 index(idx, arr) | |
# 終了条件 | |
return p arr[0] if idx == 0 | |
# 頭1つ落とす | |
index idx - 1, arr[1..-1] | |
end | |
index 3, [1, 2, 3, 4, 5] |
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
articles_table = Article.arel_table | |
# subquery | |
articles = articles_table | |
.project(Arel.star) # project = select | |
.where(articles_table[:type].eq('daily')) | |
.or(articles_table[:type].eq('weekly')) # or | |
.and(articles_table[:type].not_eq('monthly')) #!= | |
.and(articles_table[:active].eq(1)) # = | |
.and(articles_table[:created_at].gt(Date.today)) # > |
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
var https = require("https"); | |
exports.handler = function(event, context) { | |
console.log('Received event:', JSON.stringify(event, null, 2)); | |
// テキストが送られた時 | |
var msg = event.entry[0].messaging[0].message.text; | |
console.log(msg); | |
// 画像が送られた時 | |
// console.log(event.entry[0].messaging[0].message.attachments[0].payload.url); | |
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( $ ){ | |
$.fn.incr = function() { | |
return this.html(parseInt(this.html()) + 1); | |
}; | |
$.fn.decr = function() { | |
return this.html(parseInt(this.html()) - 1); | |
}; | |
})( jQuery ); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<input type="button" id="decr" name="name" value="-"> | |
<span id="num"></span> | |
<input type="button" id="incr" name="name" value="+"> |
OlderNewer