Skip to content

Instantly share code, notes, and snippets.

View regonn's full-sized avatar
🍵
Tea.

regonn regonn

🍵
Tea.
View GitHub Profile
function steamrollArray(arr) {
while (hasArrElement(arr)){
arr = expandArrElement(arr);
}
return arr;
}
function hasArrElement(arr) {
for (var i = 0; i < arr.length; i++ ) {
if (Array.isArray(arr[i])){
@regonn
regonn / gist:89cc08033e56800da3cd
Created October 6, 2014 08:22
Herokuアプリの権限のあるユーザを一覧で表示
# 実行前に下の設定が必要です
# $ rbenv exec gem install heroku-api
# $ export HEROKU_API_KEY=your_heroku_api_key
require 'heroku-api'
heroku = Heroku::API.new
apps = heroku.get_apps.body
apps.each do |app|
puts app['name']
collaborators = heroku.get_collaborators(app['name']).body
B(3,3)
=B(2,B(3,2))
=B(2,B(2,B(3,1)))
=B(2,B(2,B(2,B(3,0))))
=B(2,B(2,B(2,B(2,1))))
=B(2,B(2,B(2,B(1,B(2,0)))))
=B(2,B(2,B(2,B(1,B(1,1)))))
=B(2,B(2,B(2,B(1,B(0,B(1,0))))))
=B(2,B(2,B(2,B(1,B(0,B(0,1))))))
=B(2,B(2,B(2,B(1,B(0,2)))))
def B(string) #現在の計算式を後ろから見ていき最初に現れるB()を取得する関数
i = 1
num_n = 0
num_m = 0
while(string[-i] == ")")
i += 1
end
j = 0
while(string[-i] != ",")#数字が何桁になってもいいように数字を取得(すべて文字列で扱っているため)
num_n += string[-i].to_i * (10**j)
def B(m,n)
if(m==0 && n>0)
return f(n)
end
if(m>0 && n==0 )
return B(m-1,1)
end
if(m>0 && n>0)
return B(m-1,B(m,n-1))
end
<%= form_for(@item) do |f| %>
<% if @item.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2>
<ul>
<% @item.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
json.array!(@items) do |item|
json.extract! item, :name, :price, :description
json.url item_url(item, format: :json)
end
<h1>Listing items</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>Description</th>
<th></th>
<th></th>
class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.string :name
t.integer :price
t.text :description
t.timestamps
end
end
class ItemsController < ApplicationController
before_action :set_item, only: [:show, :edit, :update, :destroy]
def index
@items = Item.all
end
def show
end