Skip to content

Instantly share code, notes, and snippets.

@banta
banta / install_nodejs.sh
Last active September 16, 2019 10:51
install nodejs
wget https://nodejs.org/dist/latest-v10.x/node-v10.16.3.tar.xz
tar xf node-v10.16.3.tar.xz
sudo mv node-v10.16.3 /usr/local/nodejs
sudo export PATH=$PATH:/usr/local/nodejs/bin
#!/usr/bin/env bash
#
# Rails console script that can be run on AWS Elastic Beanstalk.
#
# Run this script from the app dir (/var/app/current) as root (sudo script/aws-console)
#
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
@banta
banta / README.md
Last active December 9, 2016 08:06
Nairuby Ruby Challenge 8th Dec, 2016

Beautiful Binary String

Alice has a binary string, B, of length n. She thinks a binary string is beautiful if and only if it doesn't contain the substring “010”.

In one step, Alice can change a 0 to a 1 (or vice-versa). Count and print the minimum number of steps needed to make Alice see the string as beautiful.

Input Format
The first line contains an integer, n (the length of binary string B).
The second line contains a single binary string, B, of length.

Constraint

@banta
banta / Code_challenge_002.rb
Last active August 29, 2015 14:27
Code challenge 002
price_ranges = [{c_name: "Company A", range: [1000, 3000]}, {c_name: "Company B", range: [6000, 10000]}, {c_name: "Company C", range: [500, 2500]}]
# Given such a list and the disered price range a shopper wishes to pay, return the companies the shopper should examine.
# @param [Interger, Interger]
#
# @return [Array]
#
# @example
# examine_companies(2500, 5000)
# #=> [{c_name: "Company A", range: [1000, 3000]} {c_name: "Company C", range: [500, 2500]}
@banta
banta / config
Created July 28, 2012 13:30
Heroku Production Configuration
if !Rails.env.development? && !Rails.env.test?
config.middleware.insert_before Rack::Cache, Rack::Static, urls: [config.assets.prefix], root: 'public'
end
@banta
banta / deploy.rb
Created July 27, 2012 12:50 — forked from thbar/deploy.rb
Resque + god + capistrano recipe
# note - you may need to split into a before-deploy (stop) and after-deploy (start) depending on your setup
desc "Hot-reload God configuration for the Resque worker"
deploy.task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join deploy_to, 'current', 'config', 'resque.god'}"
sudo "god start resque"
end
after 'deploy:update_code', 'deploy:update_shared_symlinks'