This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require "curses" | |
Curses.init_screen | |
Curses.setpos(0,0); Curses.addstr("(0,0)-------------------Y") | |
Curses.setpos(1,0); Curses.addstr("|") | |
Curses.setpos(2,0); Curses.addstr("|") | |
Curses.setpos(3,0); Curses.addstr("|") | |
Curses.setpos(4,0); Curses.addstr("|") |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require "curses" | |
Curses.init_screen # スクリーンを初期化 | |
string = "Hello World!" | |
Curses.setpos(Curses.lines / 2, Curses.cols / 2 - (string.length / 2)) | |
# カーソル一位置 | |
Curses.addstr(string) # カーソル位置に string を挿入(上書) | |
Curses.refresh # スクリーンを更新(addstrしたやつが表示される) |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require "curses" | |
include Curses | |
init_screen # スクリーンを初期化 | |
string = "Hello World!" | |
setpos(lines / 2, cols / 2 - (string.length / 2)) | |
# カーソル一位置 | |
addstr(string) # カーソル位置に string を挿入(上書) |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require "curses" | |
Curses.init_screen # スクリーンを初期化 | |
Curses.start_color # 色を有効にする | |
Curses.init_pair(1, Curses::COLOR_BLACK, Curses::COLOR_WHITE) | |
Curses.init_pair(2, Curses::COLOR_BLACK, Curses::COLOR_BLUE) | |
Curses.init_pair(3, Curses::COLOR_WHITE, Curses::COLOR_RED) | |
# 色のペアを登録する |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require "curses" | |
Curses.init_screen | |
Curses.start_color | |
Curses.init_pair(1, Curses::COLOR_BLACK, Curses::COLOR_WHITE) | |
string = "割と眠い" | |
Curses.setpos(Curses.lines / 2 - 1, Curses.cols / 2 - (string.length / 2) - 10) |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require "curses" | |
Curses.init_screen | |
Curses.start_color | |
Curses.init_pair(1, Curses::COLOR_BLACK, Curses::COLOR_WHITE) | |
Curses.init_pair(2, Curses::COLOR_WHITE, Curses::COLOR_GREEN) | |
win = Curses.stdscr.subwin(5,30,3,10) | |
# subwin(window行数,window列数,行位置,列位置) |
This file contains hidden or 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 はメソッドを定義するキーワードです。 | |
def factorial(n) | |
if n < 0 | |
return false | |
elsif n == 0 || n == 1 | |
return 1 | |
else | |
return n * factorial(n-1) | |
end | |
end |
This file contains hidden or 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次元配列で保持 | |
girls = [ ["Suzumiya","Haruhi"], | |
["Senjogahara","Hitagi"], | |
["Nanasaki","Ai"], | |
["Tsutsukakushi","Tsukiko"], | |
["Ayanami","Rei"] ] | |
# 乱数生成 | |
x = rand(5); y = rand(5) |
This file contains hidden or 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 'twitter' | |
TW_CONSUMER_KEY = " your consumer key " | |
TW_CONSUMER_SECRET = " your consumer secret " | |
TW_ACCESS_TOKEN = " your access token " | |
TW_ACCESS_TOKEN_SECRET = " your access token secret " | |
# ログイン | |
# ログイン不要な操作もありますがこれやっとけば大抵問題ない(適当 | |
twClient = Twitter::REST::Client.new do |config| |
This file contains hidden or 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
#<Twitter::SearchResults:0x00000001aa3150 | |
@attrs={ | |
:statuses=>[ | |
{ | |
:metadata=>{ | |
:result_type=>"recent", | |
:iso_language_code=>"ja" | |
}, | |
:created_at=>"Fri Dec 20 01:54:58 +0000 2013", | |
:id=>4138499781806*****, |
OlderNewer