Skip to content

Instantly share code, notes, and snippets.

Ivan Shikhalev shikhalev

Block or report user

Report or block shikhalev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View i2pd-pac.js
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".i2p")) {
return "PROXY 127.0.0.1:4444";
} else {
return "DIRECT";
}
}
@shikhalev
shikhalev / demo01.rb
Last active Aug 29, 2015
Примеры для статьи про Rack
View demo01.rb
# encoding: utf-8
require 'pp'
require 'rack'
app = proc do |env|
[
200,
{ 'Content-Type' => 'text/plain' },
[ env.pretty_inspect ]
@shikhalev
shikhalev / intro01.rb
Last active Aug 29, 2015
Для статьи «Средства самопознания в RUby»
View intro01.rb
# encoding: utf-8
def log msg, file, line
$stderr.puts "[#{file}:#{line}] #{msg}"
end
log 'Сообщение', __FILE__, __LINE__
@shikhalev
shikhalev / demo00.rb
Created Nov 18, 2014
Для статьи «Метапрограммирование в Ruby: разбор примера»
View demo00.rb
# encoding: utf-8
require './prop00'
class Alpha
property :alpha, :beta
attr_accessor :gamma
end
a = Alpha.new
@shikhalev
shikhalev / demo01.rb
Created Feb 24, 2014
Примеры к статье «Ruby и многозадачность»
View demo01.rb
# encoding: utf-8
puts 'begin'
th = Thread.new do
(1..3).each { |i| puts i }
end
# sleep 0
puts '---'
@shikhalev
shikhalev / demo01.rb
Created Jan 7, 2014
Примеры к статье «Блоки и контекст»
View demo01.rb
# encoding: utf-8
class Alpha
attr_accessor :alpha
def beta
self.alpha = 1
alpha = 2
end
@shikhalev
shikhalev / 01_c.rb
Created Oct 12, 2013
Примеры для статьи «Распределенный Ruby»
View 01_c.rb
# encoding: utf-8
require 'drb'
# DRb.start_service
a = DRbObject.new nil, 'druby://localhost:9000'
p a.alpha(1)
p a.alpha(nil)
p a.alpha("beta")
@shikhalev
shikhalev / i2p-pac.js
Created Sep 18, 2013
proxy.pac for i2p
View i2p-pac.js
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".i2p")) {
return "PROXY 127.0.0.1:4444";
} else {
return "DIRECT";
}
}
@shikhalev
shikhalev / dzyn.js
Last active Dec 22, 2015
Немного дзынь-буддизму
View dzyn.js
var Tetrao = {
BLOCKS : [
'p', 'blockquote', 'div', 'address'
],
LINE_WIDTH : 80,
normalize : function (s) {
s = s.replace(new RegExp(' ', 'gm'), ' ');
@shikhalev
shikhalev / deco.rb
Created Aug 18, 2013
Samples for «decorators»
View deco.rb
# encoding: utf-8
class Module
def decorator name, &wrapper
define_singleton_method name do |*names, **opts|
if names.length != 0
@ignore_wrap = true
names.each do |nm|
define_method nm, &wrapper.call(instance_method(nm), **opts)
You can’t perform that action at this time.