Skip to content

Instantly share code, notes, and snippets.

View arzahs's full-sized avatar

Sergey Nelepa arzahs

  • Ukraine, Kiev
View GitHub Profile
@arzahs
arzahs / gist:4e08a5f3b990a879c673
Created August 27, 2015 13:45
How many times the text is found on his every word
print('Input file name: ')
filename = input()
fin = open(filename, 'r')
text = [line.split() for line in fin.readlines()]
countWord = {}
for words in text:
for word in words:
try:
countWord[word]+=1
except KeyError:
@arzahs
arzahs / gist:afe8d0f59fbe6c551d5c
Created August 27, 2015 13:47
Count number of different words in line
words = input();
listwords = len(set(words.split()));
print(listwords);
@arzahs
arzahs / gist:d794976b4eb78b1953f7
Created October 19, 2015 16:32
Ruby:Считать строку и вывести её
a = gets
puts a
@arzahs
arzahs / gist:9618268ecbd6e12d75d2
Created October 19, 2015 18:22
Ruby: Узнать тип/класс
название.class
@arzahs
arzahs / gist:2eb17d9cdbc9f4c93372
Created October 19, 2015 18:26
Ruby:привести к типу
переменная.to_i #integer
переменная.to_f #float
переменная.to_s #string
@arzahs
arzahs / gist:2f65837fd1b1a1590f86
Created October 19, 2015 18:36
Ruby: интерполяция строк
x=5
puts "x=#{x}"
@arzahs
arzahs / gist:4afa9b994413a867dbd7
Last active October 19, 2015 19:19
Ruby: Выполнить код n-ое количество раз
n = 10 #колличество
n.times{
|#номер итерации|
#блок кода
}
@arzahs
arzahs / tic tac toe
Created October 21, 2015 20:30
Ruby: крестики-нолики на руби( tic tac toe)
@table = ['-','-','-','-','-','-','-','-','-']
def cells_show
puts "Number of cells:"
puts "-1-|-2-|-3-"
puts "-4-|-5-|-6-"
puts "-7-|-8-|-9-"
puts "Current situation:"
puts "-#{@table[0]}-|-#{@table[1]}-|-#{@table[2]}-"
puts "-#{@table[3]}-|-#{@table[4]}-|-#{@table[5]}-"
@arzahs
arzahs / OOP example
Created October 22, 2015 10:35
Ruby:OOP example
class Airport
attr_reader :name
attr_reader :planes
def initialize(name)
@name = name
@planes = []
end
def add_plane plane
@arzahs
arzahs / script mailer
Created December 12, 2015 18:10
open online men
document.onkeyup = KeyCheck;
function openTab(url) {
window.open(url, "_blank");
}
function linkTrue(li) {
var online = "icon_mess_blink";
if(li.getElementsByClassName("icon_mess_blink").length !== 0){