Skip to content

Instantly share code, notes, and snippets.

View fxposter's full-sized avatar

Pavlo fxposter

View GitHub Profile
class NativeSerializer
def encode
value.inspect
end
def decode(value)
eval(value)
end
end
package org.fxposter.wavelets;
import com.sun.imageio.plugins.bmp.BMPImageReader;
import sun.awt.image.ByteInterleavedRaster;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.color.ColorSpace;
import java.awt.image.*;
class Asset < ActiveRecord::Base
belongs_to :owner, :polymorphic => true
class User < self
has_attached_file :image, :styles => { :original => "160x160>" }
before_create :destroy_previous_asset
end
protected
def destroy_previous_asset
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']]
];