Skip to content

Instantly share code, notes, and snippets.

View fxposter's full-sized avatar

Pavlo fxposter

View GitHub Profile
var Search = Backbone.Model.extend({
setSelectedTagIds: function(ids) {
clearTimeout(this.timeout);
var model = this;
model.set({ selected_tag_ids: ids, update_type: 'tags' });
model.timeout = setTimeout(function() {
model.fetch();
}, 1000);
},
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'rails3-generators'
gem 'pg'
gem 'silent-postgres'
gem 'devise'
gem 'cancan'
gem 'inherited_resources', '~> 1.1.2'
@fxposter
fxposter / sass_initializer.rb
Created June 16, 2011 23:22
asset_path method to be used in sass files
# Usage
# body {
# background: url(asset_path('background.png')) #FFFFFF;
# }
module Sass::Script::Functions
include Sprockets::Helpers::RailsHelper
def asset_path(path)
assert_type path, :String
Sass::Script::String.new(super(path.value), :string)
end
= tabs do |manager|
= manager.tab :about, :name => "About this Expert" do
%p.trader-half
= simple_format(@profile.expert_description)
%ul.info-list
- @profile.contact_services_ordered_by_group.each do |service|
%li= render_service(service)
.cl
%ul.i-blocks.trader-half
%li= twitter_share
var Tag, activeTags, inactiveTags, suggestedTags;
Application.Models.Tag = Backbone.Model.extend({});
Application.Models.Business.Tag = Application.Models.Tag.extend({
activate: function() {
var manager = this.get('manager');
if (!manager) return false;
manager.activateTag(this);
},
deactivate: function() {
claims = customer.claims.where(:deal_id => business.deal_ids)
last_ticket_creation_date = customer.tickets.where(:id.ne => id).order(:created_at.desc).first.try(:created_at)
claims = claims.where(:created_at.gt => tickets.last.created_at) if last_ticket_creation_date
deal_ids = claims.map(&:deal_id).uniq
deals_scope = business.deals.open_up.where(:id.in => deal_ids)
loyality_points = [deals_scope.open_up.max(:price), deals_scope.special.max(:loyalty_bonus), flyer ? flyer.value : 0].max
customer_relation = customer.customer_relations.where(:business => business).first
customer_relation.increment!(:gift_points, loyality_points) if customer_relation
@fxposter
fxposter / gist:1301190
Created October 20, 2011 13:51
DO NOT EVER DO THIS AT HOME
Application.Views.Network.RelationControl = (function () {
var view = { events: {} };
var toggleMap = [
[['accept_profile', 'decline_profile'], ['friendship_request_block']],
[[{ post: 'friend_profile' }, { ajaxDelete: 'unfriend_profile' }], ['trust_block', 'distrust_block']],
[[{ post: 'subscribe_profile' }, { ajaxDelete: 'unsubscribe_profile' }], ['subscribe_block', 'unsubscribe_block']],
[['accept_employment', 'decline_employment'], ['employment_request_block']],
[[{'post':'create_employment'}, {'ajaxDelete':'remove_employment'}], ['employment_block']],
[['promote_to', 'demote_from'], ['employment_role_block']]
];
module Api
extend self
def repository(owner, name)
fetch("repos/show/#{owner}/#{name}")['repository']
end
def organization(name)
fetch("organizations/#{name}/public_members")
end
@fxposter
fxposter / gist:1391475
Created November 24, 2011 14:34
Haml to ERB converter
require 'haml'
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
'use strict';
class Executor {
constructor(maxTasksInParallel) {
this._maxTasksInParallel = maxTasksInParallel;
this._currentTasks = 0;
this._queue = [];
}
start(task) {