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 parse(xml=pricer_xml) | |
flight_indexes = xml.xpath('//r:flightIndex').map do |flight_index| | |
flight_index.xpath('r:groupOfFlights').map do |group| | |
Segment.new( :flights => | |
group.xpath("r:flightDetails/r:flightInformation").map { |fi| | |
Flight.new( | |
:operating_carrier => fi.xpath("r:companyId/r:operatingCarrier").to_s, | |
:marketing_carrier => fi.xpath("r:companyId/r:marketingCarrier").to_s, | |
:departure => fi.xpath("r:location[1]/r:locationId").to_s, | |
:departure_term => fi.xpath("r:location[1]/r:terminal").to_s, |
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
#!/usr/bin/env ruby | |
require 'config/boot.rb' | |
require 'config/environment.rb' | |
# FIXME use real CSV writer | |
File.open 'words.csv', 'w' do |csv| | |
for model in [Country, City] do | |
model.all.each do |c| | |
synonyms = [] | |
synonyms << c.name_en unless c.name_en == c.name |
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
/* Trivial keyboard input layout to english switcher by Alexander V. Zhouravlev. | |
* Compile it with gcc -framework Carbon -o SwitchToEnglish SwitchToEnglish.m */ | |
#import <Carbon/Carbon.h> | |
int main (int argc, const char *argv[]) | |
{ | |
TISInputSourceRef english = TISCopyInputSourceForLanguage(CFSTR("en-US")); | |
if (!english) | |
return 1; |
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
begin | |
require "rubygems" | |
require "bundler" | |
rescue LoadError | |
raise "Could not load the bundler gem. Install it with `gem install bundler`." | |
end | |
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") | |
raise RuntimeError, "Your bundler version is too old." + | |
"Run `gem install bundler` to upgrade." |
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
# должно помочь с кириллицей в .to_yml | |
ruby -lpe 'gsub!(/\\x(..)/){ "%c" % $1.to_i(16) }' |
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
From f1a4da7b54468f815a8478b774da1e0fe47ff0d2 Mon Sep 17 00:00:00 2001 | |
From: codesnik <[email protected]> | |
Date: Sat, 6 Mar 2010 23:54:38 +0300 | |
Subject: [PATCH] migrates to datamapper | |
--- | |
Gemfile | 71 ++++++++---- | |
Gemfile.lock | 174 +++++++++++++++++++++-------- | |
app/controllers/application_controller.rb | 2 +- | |
app/controllers/messages_controller.rb | 26 ++--- |
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
class Message | |
include DataMapper::Resource | |
property :id, Serial | |
property :subject, String | |
property :body, Text | |
property :unread, Boolean, :default => true, :required => true | |
property :created_at, DateTime | |
property :updated_at, DateTime |
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
class Message < ActiveRecord::Base | |
# обновляет updated_at у родительского сообщения, нужно для сортировки | |
belongs_to :parent, :class_name => "Message", :touch => true | |
belongs_to :sender, :class_name => "User" | |
belongs_to :recipient, :class_name => "User" | |
has_many :messages, :foreign_key => :parent_id, :dependent => :delete_all | |
default_scope order('created_at desc') | |
scope :threads, where(:parent_id => nil) | |
scope :unread, where(:unread => true) |
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
-- | |
-- PostgreSQL database dump | |
-- | |
SET statement_timeout = 0; | |
SET client_encoding = 'UTF8'; | |
SET standard_conforming_strings = off; | |
SET check_function_bodies = false; | |
SET client_min_messages = warning; | |
SET escape_string_warning = off; |
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
class CatalogueController < ApplicationController | |
@@rows_on_page = 50 | |
@@companies_on_page = 20 | |
def firms | |
# Возвращаем "304 Not Modified" если страница не устарела | |
if industry.cached_level >= 2 || industry.leaf? | |
if params[:format] != 'xls' | |
# если выводится список компаний (причем не в ExCel) |