Skip to content

Instantly share code, notes, and snippets.

Avatar

Baurzhan Konurbayev baurzhan-konurbayev

View GitHub Profile
View gist:5eb4eebeaa0da3f5bc2fdf560e977f75
# encode from binary file to base64txt
powershell -C "& {$outpath = (Join-Path (pwd) 'out_base64.txt'); $inpath = (Join-Path (pwd) 'data.jpg'); [IO.File]::WriteAllText($outpath, ([convert]::ToBase64String(([IO.File]::ReadAllBytes($inpath)))))}"
# decode from base64txt to binary file
powershell -C "& {$outpath = (Join-Path (pwd) 'outdata2.jpg'); $inpath = (Join-Path (pwd) 'out_base64.txt'); [IO.File]::WriteAllBytes($outpath, ([convert]::FromBase64String(([IO.File]::ReadAllText($inpath)))))}"
View example.rb
# recipe1.rb, which I am writing test for
powershell_script "Check if service needs to be restarted" do
code XXXX
notifies :restart, windows_service[resource_from_other_collection], :delayed
action :run
end
# recipe2.rb, which I am writing test for
windows_service "resource_from_other_collection" do
action :nothing
View git-pre-receive-hook.sh
#!/bin/sh
#
# For each ref, validate the commit.
#
# - It disallows deleting branches without a /.
# - It disallows non fast-forward on branches without a /.
# - It disallows deleting tags without a /.
# - It disallows unannotated tags to be pushed.
View gist123.java
public List<Evaluation> findEvaluationsAssignedToUser(String login, Integer tenderId, Integer proposalId) {
Connection connection = null;
PreparedStatement preparedStatement = null;
List<Evaluation> evaluations = new ArrayList<>();
System.out.println("from EvaluationDaoImpl findEvaluationsAssignedToUser start" + evaluations);
try {
System.out.println("from findEvaluationsAssignedToUser page login" +login+" tenderId "+ tenderId+" proposalId "+proposalId);
connection = ConnectionPool.getInstance().getConnection();
preparedStatement = connection.prepareStatement(PREPARED_STATEMENT_EVALUATION_FIND_BY_USER);
preparedStatement.setString(1, login);
View chef reading
https://github.com/facebook/chef-cookbooks/blob/master/README.md
https://github.com/facebook/chef-utils/blob/master/Philosophy.md
Example cookbook: https://github.com/facebook/chef-cookbooks/tree/master/cookbooks/fb_cron
View java task 8
import java.util.Random;
public class ConnectDemo {
public static void main(String[] args) {
ConnectionManager connMngr =new ConnectionManager();
connMngr.createConnection();
connMngr.createConnection();
connMngr.createConnection();
connMngr.createConnection();
View stove 5 gem version error
Stove experienced an error!
E: ArgumentError
E: wrong number of arguments (2 for 1)
E: /home/baurzhan/.chefdk/gem/ruby/2.1.0/bundler/gems/stove-942341752e19/lib/stove/cookbook/metadata.rb:60:in `gem'
/opt/chefdk/chef-repo/cookbooks/sys_dns/metadata.rb:18:in `from_file'
/home/baurzhan/.chefdk/gem/ruby/2.1.0/bundler/gems/stove-942341752e19/lib/stove/cookbook/metadata.rb:160:in `instance_eval'
/home/baurzhan/.chefdk/gem/ruby/2.1.0/bundler/gems/stove-942341752e19/lib/stove/cookbook/metadata.rb:160:in `from_file'
/home/baurzhan/.chefdk/gem/ruby/2.1.0/bundler/gems/stove-942341752e19/lib/stove/cookbook/metadata.rb:28:in `from_file'
/home/baurzhan/.chefdk/gem/ruby/2.1.0/bundler/gems/stove-942341752e19/lib/stove/cookbook.rb:112:in `load_metadata!'
/home/baurzhan/.chefdk/gem/ruby/2.1.0/bundler/gems/stove-942341752e19/lib/stove/cookbook.rb:57:in `initialize'
View gist:19b19205e8d4f2fb9305e36f9055c218
def install_gem(gem_name, gem_source, gem_version, gem_options, gem_compile_time)
# Chef::Log.warn("gem_name #{gem_name} gem_version #{gem_version} gem_source #{gem_source}")
# Install gem from private gem server
res = Chef::Resource::ChefGem.new gem_name, run_context
res.clear_sources true
res.compile_time gem_compile_time
res.options if gem_options
res.version gem_version
res.source gem_source
res.run_action :install
View gist:8be138b93bfac481de9888d8d93fd9c5
ohai 'reload' do
action :nothing
end.run_action(:reload)
cookbook_file '/opt/ohai/plugins/openstack_v2.rb' do
mode '0755'
notifies :reload, 'ohai[reload]', :immediately
source 'ohai.openstack_v2.rb'
action :nothing
end.run_action(:create)