Skip to content

Instantly share code, notes, and snippets.

View vlad-shatskyi's full-sized avatar

Volodymyr Shatskyi vlad-shatskyi

View GitHub Profile
module Scraper::BookingCom
class RoomBot < BotBase
include Scraper::ScrapingCommon
HTTP_RESPONSE_VALIDATORS = [
:nil_response, :status_404, :status_200, :html,
->(url, resp) { raise(CustomExceptions::InvalidUrlError, url) if resp.uri.path.include?("searchresults") }
]
def scrape
module Scraper::BookingCom
class RoomBot < BotBase
include Scraper::ScrapingCommon
HTTP_RESPONSE_VALIDATORS = [
:nil_response, :status_404, :status_200, :html,
->(url, resp) { raise(CustomExceptions::InvalidUrlError, url) if resp.uri.path.include?("searchresults") }
]
def scrape
module Main where
import System.Environment
import System.IO (hFlush, stdout)
ask :: (Show a, Read b) => a -> IO b
ask question = do
putStr $ show question
hFlush stdout
answer <- getLine
calculatePadding :: Int -> Int
calculatePadding = ceiling . log . fromIntegral
Defaulting the following constraint(s) to type ‘Double’
(RealFrac b0)
arising from a use of ‘ceiling’ at src/Cat/Decorators.hs:21:22-28
(Num b0)
arising from a use of ‘fromIntegral’
at src/Cat/Decorators.hs:21:38-49
def foo
def bar
puts "bar"
end
end
def foo
def bar
puts "bar"
end
end
@vlad-shatskyi
vlad-shatskyi / gems.rb
Last active December 15, 2015 14:58
Installs all the required gems in the specified file or directory.
#!/usr/bin/env ruby
def installed?(gem_name)
require gem_name
true
rescue LoadError
false
end
def required_gems(file_name)
@vlad-shatskyi
vlad-shatskyi / test.rb
Created March 30, 2013 11:42
mechanize
require 'mechanize'
require 'json'
agent = Mechanize.new
headers = {
'X-Requested-With' => 'XMLHttpRequest',
'Content-Type' => 'application/x-www-form-urlencoded',
'Accept' => '*/*',
'Cookie' => 'removed'
}
@vlad-shatskyi
vlad-shatskyi / notifyosd.zsh
Last active December 15, 2015 11:49 — forked from ihashacks/notifyosd.zsh
Displays a notification when a command, that takes over 10 seconds to execute, finishes and only if the current window isn't the terminal. Add to your .zshrc: [ -e path/to/notifyosd.zsh ] && . path/to/notifyosd.zsh
function active-window-id {
echo `xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}'`
}
# end and compare timer, notify-send if needed
function notifyosd-precmd() {
if [ ! -z "$cmd" ]; then
cmd_end=`date +%s`
((cmd_time=$cmd_end - $cmd_start))
fi