Skip to content

Instantly share code, notes, and snippets.

View DemitryT's full-sized avatar

Demitry Toumilovich DemitryT

View GitHub Profile
@DemitryT
DemitryT / test.rb
Created November 20, 2015 09:34
test
test
{
"id": "eb85349d-03c3-44f4-a77b-824f7221d116",
"imp": [
{
"id": "eb85349d-03c3-44f4-a77b-824f7221d116",
"banner": {
"h": 250,
"w": 300,
"ext": {
"bcont": [ 1, 3, 4, 6, 8, 10, 11, 12, 14, 15 ],
@DemitryT
DemitryT / theory.rb
Last active August 29, 2015 14:11
theory.rb
class User < ActiveRecord::Base
MAILCHIMP_API_KEY = 'm23lm092m3'
# You shouldn't add these credentials in the model or even check these into github. They should either
# be added via the Heroku toolbelt to the settings or at least stored in a separate settings file.
has_many :orders
has_many :packages, through: :orders
before_save :assign_referral_code, on: :create
@DemitryT
DemitryT / lightbox.js
Created December 12, 2012 20:21
new lightbox js
/*
Lightbox v2.51
by Lokesh Dhakar - http://www.lokeshdhakar.com
For more information, visit:
http://lokeshdhakar.com/projects/lightbox2/
Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
- free for use in both personal and commercial projects
@DemitryT
DemitryT / test.rb
Created November 2, 2012 20:57
test.rb
def is_mobile_device?
if current_company
current_company.mobile_optimized? && !session[:full_site].present? && super || session[:mobile_view].present?
else
!session[:full_site].present? && super || session[:mobile_view].present?
end
end
@DemitryT
DemitryT / migration.rb
Created September 24, 2012 18:02
migration
class ChangeAgentProfilesContactForm < ActiveRecord::Migration
def self.up
change_column :settings, :agent_profiles_contact_form, :boolean, :default => true, :null => false
end
def self.down
change_column :settings, :agent_profiles_contact_form, :boolean
end
end
@DemitryT
DemitryT / admin.js
Created August 29, 2012 14:10
admin.js
function updateMapMarkerOnShowAddressChange() {
// added the if statement below
if($("setting_rentals_details_map_marker_box")) {
var boxRadioButton = $("setting_rentals_details_map_marker_box");
var initialMapMarkerBox = boxRadioButton.checked;
}
var rentAddressCheckbox = $('setting_show_rental_address');
var pinRadioButton = $("setting_rentals_details_map_marker_pin");
// added the if statement below
@DemitryT
DemitryT / sql.sql
Created July 12, 2012 20:39
sql.sql
SELECT `companies`.* FROM `companies` INNER JOIN `company_services`
ON `company_services`.`company_id` = `companies`.`id`
WHERE (company_services.id is not null) AND (active = 1 AND staging = 0 AND trulia_feed = 1);
@DemitryT
DemitryT / users_controller.rb
Created June 4, 2012 20:03
users_controller.rb
if current_company.has_rentals?
property_ids = []
@lead.rental_saved_searches.each do |rss|
if rss.rental_search.send(current_company.rental_property_type) == true
@lead_details[:saved_searches][:rentals] << rss
end
end
if current_company.rentals_lead_plan.to_sym == :one
@lead.favorite_rental_properties.each do |frp|
if frp.rental_property_type == current_company.rental_property_type
@DemitryT
DemitryT / process_kill
Created May 15, 2012 16:22
handy command to kill a process in one line
ps aux|grep script/rails|grep -v grep|awk '{print $2}'|xargs kill -9