Skip to content

Instantly share code, notes, and snippets.

View vlad-shatskyi's full-sized avatar

Volodymyr Shatskyi vlad-shatskyi

View GitHub Profile
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
names = File.read('names.txt').split(',').map { |str| str[1..-2] }
letters = ('A'..'Z').to_a.join
sum = 0
names.each_with_index do |name, i|
score = 0
name.each_char do |char|
score += (letters.index(char) + 1) * (i + 1)
end
sum += score
user = User.find(1)
site = Site.new
site.url = "http://www.google.com"
site.name = "Google"
user.sites << site
if user.save
'cool'
File.foreach( "dictionary.txt" ) do |line|
md = line.match(/\A([A-Z]+)/)
puts md[0] if md
end
def foo(dep, sym)
dep = dep.partition(/[<>=]{1,2}/)
name = dep[0]
intervall = Version.get_interval dep[1..2].join
pkg = Package.new(name, intervall)
unless Pacman.installed? pkg
if Pacman.available? pkg
@dependencies[sym] << pkg
else
pkg = AurQuery.getpkg pkg
<table style="float: left; margin-left: 20px;">
<% if @user == current_user %>
<caption>My Holidays</caption>
<thead>
<tr>
<th>Start Date</th>
<th>End Date</th>
<th>Description</th>
<th>State</th>
<th>Type</th>