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
-- SPENT BY SEEKER | |
DROP TABLE IF EXISTS purchased20; | |
CREATE TEMPORARY TABLE purchased20 AS | |
SELECT t.user_id FROM bucket_transactions t | |
INNER JOIN users u ON (u.id = t.user_id AND u.user_type = 1) | |
WHERE t.transaction_type IN (3, 4) AND | |
t.created_at > '2009-09-16' | |
GROUP BY t.user_id | |
HAVING SUM(t.amount) > 20; |
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
mysql -uroot main_final -e 'select id, login from users where status = 0 order by id' | gzip > status0.csv.gz |
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
namespace :db do | |
desc 'clean unused IVR tables' | |
task :clean_unused_ivr_tables, :suffix1, :suffix2, :needs => :environment do |t, args| | |
def current_version | |
ivr_config_file = File.dirname(__FILE__) + "/../../config/ivr_version.yml" | |
raise 'Missing ivr_version.yml' unless File.exists?(ivr_config_file) | |
ivr_version = YAML.load_file(File.expand_path(ivr_config_file)).to_s | |
raise 'Empty or broken ivr_version.yml' unless ivr_version =~ /\A\d+\Z/ |
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 'pp' | |
logins = %w(vlad marat artyom) | |
change_to = ARGV.first | |
raise 'Enter name as param!' if change_to.nil? | |
change_to.strip! |
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 CreateCustomerToLists < ActiveRecord::Migration | |
def self.up | |
create_table :customer_to_lists, :force => true do |t| | |
t.integer "customer_id", :null => false | |
t.integer "customer_list_id", :null => false | |
end | |
conn = ActiveRecord::Base.connection | |
#convert |
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
DELIMITER $$ | |
DROP PROCEDURE IF EXISTS clear_runaway_conferences$$ | |
CREATE PROCEDURE clear_runaway_conferences() | |
MODIFIES SQL DATA | |
BEGIN | |
DROP TABLE IF EXISTS _in_process; | |
CREATE TEMPORARY TABLE _in_process (`state` VARCHAR(32)); |
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_eval do | |
{ | |
:total_npm => [BucketContribution::Type::NON_PAYABLE_MARKETING, TransactionType::MANUAL_CREDIT_TO_NON_PAYABLE_MARKETING], | |
:total_pm => [BucketContribution::Type::PAYABLE_MARKETING, TransactionType::MANUAL_CREDIT_TO_PAYABLE_MARKETING], | |
:total_deposits => [BucketContribution::Type::DEPOSIT, TransactionType::MANUAL_CREDIT_TO_DEPOSIT], | |
:total_earnings => [BucketContribution::Type::SERVICES_EARNED, TransactionType::MANUAL_CREDIT_SERVICES_EARNED] | |
}.each do |name, i| | |
define_method "#{name}=" do |amount| | |
BucketContribution.delete_all(["user_id = ? AND bucket_type = ?", self.id, i[0] ]) |
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
#!/bin/sh | |
# ubuntu start/stop | |
BIN="/usr/bin/clarity" | |
test -x $BIN || exit 0 | |
CMD="$BIN -- --username=admin --password=secret --port=8989 /var/www/weblogs/ " | |
. /lib/lsb/init-functions |
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 ClearanceUpdateUsersTo088 < ActiveRecord::Migration | |
# TODO: fix mysql columns from UTF8 to ASCII | |
def self.up | |
rename_column :users, :crypted_password, :encrypted_password | |
change_column :users, :encrypted_password, :string, :limit => 128 | |
rename_column :users, :password_salt, :salt | |
change_column :users, :salt, :string, :limit => 128 |
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
# Usage: | |
# | |
# class SomeModel < ActiveRecord::Base | |
# include ModelChange::Tracker | |
# will_track_changes_of :field_1, :field_2, ... field_n | |
# end | |
# | |
# Now, if we update a record, it will generate a new ModelChange record for every column (field_1, field_2...) that has changed. | |
# | |
# Also it will add a has_many relationship between SomeModel and ModelChange, so we can now use |
OlderNewer