Skip to content

Instantly share code, notes, and snippets.

View killthekitten's full-sized avatar
🇺🇦

Nikolay Shebanov killthekitten

🇺🇦
View GitHub Profile
@killthekitten
killthekitten / gist:2930846
Created June 14, 2012 14:57
Задачки
1
JavaScript
3
howManyYears += 1;
Оператор += в js допускает конкатенацию числа со строкой, соответственно нужно убрать кавычки. В оригинале мы получаем 10, а без кавычек - необходимую единицу.
2
Ruby
2
if (howManyYears != 0)
@killthekitten
killthekitten / stuff.cpp
Created December 11, 2012 21:48
Gistflow stuff
"Gistflow.com"
@killthekitten
killthekitten / index.html
Last active December 10, 2015 00:29
XMas written with CoffeeScript flavor
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<pre>
</pre>
@killthekitten
killthekitten / README.md
Last active December 10, 2015 11:59 — forked from oguzbilgic/README.md

MyApp

Very short description of the application.

1. Ruby, Rails & Rubygems

Application is written in ruby language, using Ruby on Rails web framework.

@killthekitten
killthekitten / custom_searcher.rb
Last active December 10, 2015 20:08 — forked from ashga/product_decorator.rb
Dumb way to filter products by multiple properties in Spree.
class CustomSearch < Spree::Core::Search::Base
protected
def add_search_scopes(base_scope)
statement = nil
search.each do |property_name, property_values|
property = Spree::Property.find_by_name(property_name.gsub("_any", ""))
next unless property
substatement = product_property[:property_id].eq(property.id).and(product_property[:value].eq(property_values.first))
@killthekitten
killthekitten / arrow.css.scss
Created February 19, 2013 07:04
Arrow button in Sass
$gl-padding: 17px;
$gl-real-height: 70px;
$gl-height: $gl-real-height - $gl-padding * 2;
$gl-arrow-width: $gl-real-height / 2;
$gl-arrow-height: $gl-real-height / sqrt(3);
$gl-arrow-degree: -1 * rad-to-deg(atan($gl-arrow-width / $gl-arrow-height));
$gl-margin-vertical: -1 * (($gl-arrow-height - 1) / 2);
$gl-margin-horizontal: -1 * (($gl-arrow-width + 1) / 2);
@mixin gl-arrow($first-color, $second-color) {
.b-box {
overflow: hidden;
margin: 0 0 20px 0;
border-radius: 7px;
box-shadow: 1px 1px 2px rgba(0, 0, 0, .2);
background: #f4f4f4;
> header {
border-radius: 7px 7px 0 0;
padding: 8px 0 8px 0px;
<table>
<tr class='entry_header'>
<th>Task</th>
<% @timesheet.date_range.each do |week_date| %>
<th><%= week_date.to_formatted_s(:short) %></th>
<% end %>
</tr>
<tr class="fields">
<td><%= f.collection_select(:task_id, @tasks, :id, :name, prompt: true) %></td>
<%= f.fields_for :time_entries do |builder|%>
class TariffSchemeFeeRule < ActiveRecord::Base
belongs_to :tariff_scheme
belongs_to :fee_rule
belongs_to :currency
validates :currency_id, uniqueness: { scope: [:fee_rule_id, :tariff_scheme_id] }, presence: true
end
class TariffScheme < ActiveRecord::Base
accepts_nested_attributes_for :tariff_scheme_fee_rules, allow_destroy: true
class BulkValidator
attr_accessor :items, :bulk_validations
def initialize(items, validations)
@items = items
@bulk_validations = build_bulk_validations(validations)
end
def candidates
bulk_validations.each do |validation|