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
require 'digest/md5' | |
hash = {} | |
dirname = "files" | |
Dir.glob("#{dirname}/**/*", File::FNM_DOTMATCH).each do |filename| | |
next if File.directory?(filename) | |
# puts 'Checking ' + filename | |
key = Digest::MD5.hexdigest(IO.read(filename)).to_sym |
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
RSpec::Matchers.define :terminate do |code| | |
actual = nil | |
def supports_block_expectations? | |
true | |
end | |
match do |block| | |
begin | |
block.call |
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
$(function(){ | |
function drawLessonsCount(count) { | |
$(".topbar-nav-main").append("<li style='display: block; color: #fff; padding: 8px 15px;'>Осталось уроков: " + count + "</li>"); | |
} | |
function countLessons() { | |
var count = 0; | |
$(".lessons-left").each(function(index, element) { | |
var text = $(element).text(); |
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 toss | |
(rand * 100) > 60 ? 1 : 2 | |
end | |
# Both players bet on 1 | |
def game | |
toss_1 = toss() | |
toss_2 = toss() | |
if toss_1 == 1 && toss_2 != 1 |
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
(function() { | |
function hideBoringArticles(nodes) { | |
nodes.filter("article.badge-entry-container.badge-entry-entity").each(function(i, el) { | |
if($(el).data("entryVotes") < 20000) { | |
$(el).hide(); | |
} | |
}) | |
} | |
var MutationObserver = window.MutationObserver; |
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
update fb_audiences | |
set facebook_id = replace(facebook_id, '[^0-9]+$', ''); | |
SELECT id, facebook_id | |
FROM fb_audiences | |
WHERE facebook_id ~ '[^0-9]+$' |
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
input = ["red", "green", "blue", "red", "blue"] | |
output = input.each_with_object(Hash.new(0)) do |word, o| | |
o[word] += 1 | |
end | |
p output | |
# {"red"=>2, "green"=>1, "blue"=>2} |
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
SELECT | |
age(now(), query_start) AS duration, | |
state, | |
pid, | |
query, | |
datname, | |
application_name, | |
waiting | |
FROM pg_stat_activity | |
ORDER BY duration DESC NULLS LAST; |
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
ALTER TABLE mc_subscribers ADD COLUMN id BIGSERIAL; | |
UPDATE mc_subscribers SET id = nextval(pg_get_serial_sequence('mc_subscribers', 'id')); | |
ALTER TABLE mc_subscribers ADD PRIMARY KEY (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
#include <stdio.h> | |
long long int myfunc (long long int i, long long int cache[]) | |
{ | |
if(cache[i]) { | |
return cache[i]; | |
} | |
if (i <= 2) { | |
return i; |