Skip to content

Instantly share code, notes, and snippets.

View Orphist's full-sized avatar
🏠
Working from home

Max Surkov Orphist

🏠
Working from home
View GitHub Profile
require 'rubygems'
require 'active_support/core_ext'
require 'cgi'
require 'yaml'
require 'nokogiri'
require 'open-uri'
require 'pp'
require 'curb'
require 'json'
*.db
*.swp
@Orphist
Orphist / gist:7611724
Last active December 29, 2015 03:59
Goliath examples
classHello< Goliath::API use Goliath::Rack::Params use Goliath::Rack::JSONP use Goliath::Rack::Validation::RequestMethod, %w(GET) use Goliath::Rack::Validation::RequiredParam, {:key => 'echo'}defresponse(env) [200, {}, {pong: params['echo’]}]endendMiddlewareNo rackup file
22. classBonjour< Goliath::APIdefresponse(env) [200, {}, "bonjour!"]endendclassRackRoutes< Goliath::API map '/version'do run Proc.new { |env| [200, {}, ["Version 0.1"]] }end get "/bonjour", Bonjournot_found('/') do# run Proc. new { ... }endendRoutingsimple, but powerful
23. classAsyncUpload< Goliath::APIdefon_headers(env, headers)env.logger.info'received headers: '+headersenddefon_body(env, data)env.logger.info'received data chunk: '+ dataenddefon_close(env)env.logger.info'closing connection'enddefresponse(env)# called when request processing is completeendendAsync Request Processingdon’t need to wait for the full request…
24. classStream< Goliath::APIdefresponse(env)pt=EM.add_periodic_timer(1) { env.stream_send("hello") }EM.add_timer(10) do
@Orphist
Orphist / gist:7622421
Created November 24, 2013 01:59
There is a high chance that your JRuby installation is somewhere else, except you have a rbenv/ruby-build setup. Change that prior installing it. You must download that file to ~/Library/LaunchAgents/. Load the plist launchctl load ~/Library/LaunchAgents/jruby-nailgun-server.plist If you need debug output, open the Console.app from Mac OSX and …
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
@Orphist
Orphist / gist:7629216
Created November 24, 2013 16:44
kgbi-1.ru
uri = 'http://kgbi-1.ru/svai'
type='Сваи квадратного сечения'
content = open(uri).read
content.encode('utf-8')
doc = Nokogiri::HTML(content)
rows = doc.css('table.table1 tr')
e=rows[0]
puts "#{e.css('td:nth(1) text()').text.strip.chomp} #{e.css('td:nth(2) text()').text.strip.chomp} #{e.css('td:nth(3) text()').text.strip.chomp} #{e.css('td:nth(4) text()').text.strip.chomp} #{e.css('td:nth(5) text()').text.strip.chomp}"
@Orphist
Orphist / gist:7800832
Last active December 30, 2015 08:09
rulezz
[CDATA[прибл.
[менее
[до
[От
[- 50 … +70
От \+(\d)0С до \+(\d\d)0С=+\1…+\2°C
\+(\d{1,3})0С\s?…\+(\d{1,3})0С=+\1…+\2°C
. при укладке слоем 10мм.=del
кгм2..-
#!/usr/bin/env bash
set -o errtrace
set -o errexit
facter_version=$1
puppet_version=$2
target_volume=$3
@Orphist
Orphist / gist:7866921
Last active December 30, 2015 18:19
kirpi4
# encoding: utf-8
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'pp'
require 'curb'
require File.dirname(__FILE__) + '/proxied_curl'
require 'iconv'
require 'anemone'
# require 'mongo'
@Orphist
Orphist / gist:7890975
Created December 10, 2013 14:00
common task
mongorestore --db aggreagator_development /Users/surkov/Downloads/dump/aggregator-staging/
# encoding: utf-8
#Оцените качество магазина на Яндекс.Маркете.
module Scraper
include FileProcs
class Object
def send_chain(*args)
o=self
args.each do |arg|