Skip to content

Instantly share code, notes, and snippets.

Pavel Forkert fxposter

Block or report user

Report or block fxposter

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
@fxposter
fxposter / node->pod.txt
Created Jul 10, 2016
coreos-kubernetes
View node->pod.txt
node->pod (works)
Taken from node:
[root@w1 ~]# tcpdump -vv -i flannel.1
tcpdump: listening on flannel.1, link-type EN10MB (Ethernet), capture size 262144 bytes
08:50:29.430554 IP (tos 0x0, ttl 64, id 24079, offset 0, flags [DF], proto TCP (6), length 60)
w1.49866 > 10.2.58.2.http: Flags [S], cksum 0x7234 (incorrect -> 0xdab7), seq 1767611758, win 28200, options [mss 1410,sackOK,TS val 443233 ecr 0,nop,wscale 7], length 0
08:50:29.431862 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto TCP (6), length 60)
10.2.58.2.http > w1.49866: Flags [S.], cksum 0x03c1 (correct), seq 3687243300, ack 1767611759, win 27960, options [mss 1410,sackOK,TS val 400868 ecr 443233,nop,wscale 7], length 0
View README.md

chef-server-ctl cleanse

apt-get purge -y chef-server apt-get purge -y chef-server-core

rm -rf /etc/opscode /etc/chef-server /opt/chef-server /opt/opscode /var/opt /var/log/chef-server

dpkg -i chef-server_11.0.11-1.ubuntu.11.04_amd64.deb

chef-server-ctl reconfigure

@fxposter
fxposter / net-http-keepalive-without-block.rb
Created Oct 28, 2015
Net/HTTP with keep-alive, but without block
View net-http-keepalive-without-block.rb
http = Net::HTTP.new(uri.host, uri.port)
http.start
request1 = Net::HTTP::Get.new(uri1)
response1 = http.request(request1)
request2 = Net::HTTP::Get.new(uri2)
response2 = http.request(request2)
http.finish
View gist:78a088533b0cee1ccb11
Step 2 : RUN ! find /usr/local/bundle -iname '*.so' | xargs -I {} ldd {} | grep 'not found'
---> Running in 464610a57692
libmysqlclient.so.18 => not found
libmysqlclient.so.18 => not found
libmysqlclient.so.18 => not found
2015/10/23 16:02:08 Failed to process json stream error: The command '/bin/sh -c ! find /usr/local/bundle -iname '*.so' | xargs -I {} ldd {} | grep 'not found'' returned a non-zero code: 1
@fxposter
fxposter / base.rb
Created Oct 22, 2015
Default Rails template
View base.rb
# rails new app_name -d mysql --skip-bundle -m path/to/this/template.rb
comment_lines 'Gemfile', "gem 'turbolinks'"
comment_lines 'Gemfile', "gem 'jbuilder'"
comment_lines 'Gemfile', "gem 'sass-rails'"
comment_lines 'Gemfile', "gem 'coffee-rails'"
comment_lines 'Gemfile', "gem 'uglifier'"
comment_lines 'Gemfile', "gem 'sdoc'"
gsub_file 'Gemfile', "gem 'mysql2'", "gem 'mysql2', '~> 0.3.20'"
View hacking-chef.rb
@chef.eval_and_check_for_changes do |frame|
template "/etc/default/#{service_id}" do
source "service.erb"
variables :name => service_id, :port => frame.eval{@service.port}
mode 0755
end
end
@fxposter
fxposter / chef-docker.rb
Created Oct 20, 2015
Docker logrotate in chef recipe
View chef-docker.rb
logrotate_app 'docker' do
path ['/var/lib/docker/containers/*/*.log', '/var/log/docker.log']
rotate 30
frequency 'daily'
options %w[notifempty missingok compress delaycompress copytruncate]
end
View README.md

Представьте что у вас есть некий класс API, который вы хотите использовать. Но вместо того чтобы всегда и везде писать api.method(args) вы хотите просто писать use_dsl { method(args) } внутри вашего обьекта.

Имея следующие классы, соответственно, API и его клиента реализуйте метод use_dsl так, чтобы получить такой вот результат:

client = Client.new(ThirdPartyAPI.new)

client.run_local_variable
# Output:
View executor.js
'use strict';
class Executor {
constructor(maxTasksInParallel) {
this._maxTasksInParallel = maxTasksInParallel;
this._currentTasks = 0;
this._queue = [];
}
start(task) {
View docker.sh
$ docker ps -a
3b64a3316725 image:tag "entrypoint.sh" 13 days ago Dead
252a55928f11 image2:tag "forever index.js" 2 weeks ago Dead
$ docker rm 3b64a3316725 252a55928f11
Error response from daemon: Cannot destroy container 3b64a3316725: Driver aufs failed to remove root filesystem 3b64a3316725c30f7d9d9c77c52addf595e8ba08cb75e56cf513353a78bbf31b: rename /var/lib/docker/aufs/mnt/3b64a3316725c30f7d9d9c77c52addf595e8ba08cb75e56cf513353a78bbf31b /var/lib/docker/aufs/mnt/3b64a3316725c30f7d9d9c77c52addf595e8ba08cb75e56cf513353a78bbf31b-removing: device or resource busy
Error response from daemon: Cannot destroy container 252a55928f11: Driver aufs failed to remove root filesystem 252a55928f11a95d9f885383f53275b3d134dfb5f95bebec5e5c41c59ba8ee15: rename /var/lib/docker/aufs/mnt/252a55928f11a95d9f885383f53275b3d134dfb5f95bebec5e5c41c59ba8ee15 /var/lib/docker/aufs/mnt/252a55928f11a95d9f885383f53275b3d134dfb5f95bebec5e5c41c59ba8ee15-removing: de
You can’t perform that action at this time.