Skip to content

Instantly share code, notes, and snippets.

View alesya-h's full-sized avatar

Alesya Huzik alesya-h

View GitHub Profile
#!/usr/bin/env ruby
RubyVM::InstructionSequence.compile_option = {tailcall_optimization: true, trace_instruction: false}
def parse_line(line)
case line.strip
when /^\s*\[\s*(.+?)\s*\]\s*$/ then {section: $1}
when /^\s*(.+?)\s*=\s*(.+?)\s*$/ then {key: $1, value: $2}
when /^\s*$/ then {}
else {error: line}
end
class ConfigParseError < StandardError
def initialize(file_name,line,text)
@file_name,@line,@text = file_name,line,text
super("Error in config file #{@file_name} at line #{line}. Line content \"#{@text}\" is incorrect.")
end
end
class ConfigReader
LINE_CONTINUE = /\\\s*$/
def self.read_config(file_name)
(ql:quickload "cl-ppcre")
(ql:quickload "anaphora")
(defpackage :ini-parser
(:use :common-lisp :anaphora)
(:export :read-config-from-file))
(in-package :ini-parser)
(defparameter +empty-line+ (format nil "~%"))
@alesya-h
alesya-h / gist:4242505
Created December 8, 2012 23:26
Suming boxes and temperature to get length
type length = int;;
type boxes = int;;
type temperature = int;;
let make_len x : length = x;;
let make_box x : boxes = x;;
let make_temp x : temperature = x;;
let sum_len (a:length) (b: length) : length = a+b;;
sum_len (make_box 5) (make_temp 10);;
-record(deal, {name, timestamp, cost, quantity}).
-define(deal_spec(Name, Timestamp, Cost, Quantity), is_atom(Name), is_integer(Timestamp), is_float(Cost), is_integer(Quantity), Timestamp >=0).
-record(report_in, {name, from_timestamp, to_timestamp, by_timestamp}).
-define(report_in_spec(Name, FromTimestamp, ToTimestamp, ByTimestamp),
is_atom(Name),
is_integer(FromTimestamp),
is_integer(ToTimestamp),
is_integer(ByTimestamp),
FromTimestamp >= 0,
@alesya-h
alesya-h / treemap.rb
Created December 2, 2012 20:05
Стаааарый тримапер
#!/usr/bin/env ruby
require 'rmagick'
class Array
alias :head :first
def tail
self[1..-1]
end
end
module Treemap
@alesya-h
alesya-h / 1.sh
Created November 6, 2012 20:08
Задания по unix shell для Юли
[10:58:40] Yuliya Sadouskaya: собственно задание:
[11:00:02] Yuliya Sadouskaya:
написаны задания. Необходимо в правом столбике написать команды, которые необходимо выполнить для выполнения задания. Для каждого задания необходимо написать только одну команду. Если в скобках указана команда или переменная, тогда их обязательно надо использовать при выполнении задания.
[11:00:15] Yuliya Sadouskaya: трудности с командами:
1.Ввести в файл list.txt всю информацию (файлы и каталоги), которая находится в текущем каталоге. Всю информацию надо сортировать по времени.
2.Создать файл ups.txt, в котором находится случайное число ($RANDOM)
3.Дополнить файл list.txt информацией, какой драйвер подключен к терминалу
4.Создать каталоги dir и dir2 ($HOME, $PWD)
5.Копировать файл list.txt на каталог dir с названием list2.dat, и всю информацию из файла показать на экране(cat)
@alesya-h
alesya-h / jk.vhdl
Created September 19, 2012 17:43
JK-триггер на VHDL
library ieee;
use ieee.std_logic_1164.all;
entity jk_trigger is
port (
Clk, Clr, Set, J, K : in std_logic;
Q,notQ : out std_logic);
end jk_trigger;
@alesya-h
alesya-h / adder.vhdl
Created September 19, 2012 17:42
Сумматор на VHDL
library ieee;
use ieee.std_logic_1164.all;
entity adder is
port (
i0 : in std_logic;
i1 : in std_logic;
ci : in std_logic;
s : out std_logic;
@alesya-h
alesya-h / mg3.lisp
Created September 19, 2012 17:39
Лаба 3 по машинной графике
(ql:quickload (list "cl-opengl" "cl-glu" "cl-glut"))
(defclass my-window (glut:window)
()
(:default-initargs :width 250 :height 250 :title "lab 3"
:mode '(:single :rgb :depth)))
(defvar *angle* 0)
(defvar *window*)