This file contains 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
# Not so good | |
i=0 | |
while i<=colnum-1 do #adding the columns | |
database.alter_table tabname.to_sym do | |
add_column colnames[i], String | |
i+=1 | |
end | |
end | |
# Better |
This file contains 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
# For given shop, category, competitor shop, old&new prefixes and prefix shop: | |
# - find urls for category products competitors(by competitorshop_id) | |
# - generate urls with new prefixes(often 'html' -> 'html?prefix=PR') | |
# - add urls with prefixes to tasks | |
# All in one SQL request. Be careful while debugging, young padawan. | |
# example: shop_id 11245, category_id 1318231, competitorshop_id 12933, | |
# old_prefix 'pr=Q49', new_prefix 'pr=Q51', prefixshop_id 1390 | |
def fill_prefix_shop_for_competitor(shop_id, category_id, competitorshop_id, old_prefix, new_prefix, prefixshop_id, force = false) | |
Db.session do |db| | |
query =<<-SQL |
This file contains 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
loop do | |
$stdout.write "content: #{$stdin.read}" | |
sleep 1 | |
end |
This file contains 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
def check_share?(url, uid) | |
# According to documentation from: | |
# http://api.mail.ru/docs/reference/rest/stream.getByAuthor/ | |
request_url = "http://www.appsmail.ru/platform/api?" + request_params(url, uid) | |
responce = HTTParty.get(request_url) | |
end | |
private | |
def request_params(url, uid) |
This file contains 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
params = 'app_id='+ mailru.app_id + | |
'method=stream.share' + | |
'session_key=' + mailru.session.session_key + | |
'url=' + encodeURIComponent(data.url) | |
network_url = 'http://www.appsmail.ru/platform/api?method=stream.share' + | |
'&app_id=' + mailru.app_id + | |
'&session_key=' + mailru.session.session_key + | |
'&sig=' + hex_md5(mailru.session.oid + params + mailru.private_key) + | |
// '&sig=' + mailru.session.sig + |
This file contains 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
params = 'app_id='+ mailru.app_id + | |
'ext_perm=stream' + | |
'method=users.hasAppPermission' + | |
'session_key=' + mailru.session.session_key + | |
'url=' + encodeURIComponent(data.url) | |
network_url = 'http://www.appsmail.ru/platform/api?method=users.hasAppPermission' + | |
'&app_id=' + mailru.app_id + | |
'&session_key=' + mailru.session.session_key + | |
'&sig=' + hex_md5(mailru.session.oid + params + mailru.private_key) + |
This file contains 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 UsersToPayQuery | |
def self.find | |
# Select users who have no errors in groups, likes and shares, have wmr and have balanse to pay. | |
# A bit strange indentation. But it's easier to read this SQL in console with this indendation. | |
User.where(" | |
NOT EXISTS( | |
SELECT id FROM shares | |
WHERE shares.error = 1 | |
AND shares.declined = false | |
AND shares.user_id = users.id) |
This file contains 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
Show hidden characters
{ | |
"tab_size": 2, | |
"translate_tabs_to_spaces": true, | |
"highlight_line": true, | |
"caret_style": "wide", | |
"ensure_newline_at_eof_on_save": true | |
} |
This file contains 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
<snippet> | |
<content><![CDATA[ | |
do | |
${1:code} | |
end]]></content> | |
<description>do...end block</description> | |
<tabTrigger>doe</tabTrigger> | |
<scope>source.ruby</scope> | |
</snippet> |
This file contains 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
# Path to your oh-my-zsh configuration. | |
ZSH=$HOME/.oh-my-zsh | |
HISTSIZE=1000 | |
SAVEHIST=1000 | |
setopt append_history | |
setopt inc_append_history | |
setopt extended_history | |
setopt hist_find_no_dups | |
setopt hist_ignore_all_dups | |
setopt hist_reduce_blanks |