This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GemHelper | |
GEMS = [{ name: 'my_gem', version: '~> 0.0.2' }] | |
def self.install_dependencies | |
GemHelper::GEMS.each do |gem| | |
version = Gem::Requirement.create gem[:version] | |
installed = Gem::Specification.each.any? do |spec| | |
gem[:name] == spec.name && version.satisfied_by?(spec.version) | |
end | |
next if installed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> require 'rubocop' | |
=> true | |
irb(main):002:0> Rubocop | |
NameError: uninitialized constant Rubocop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -x | |
curl -w "\n" -X DELETE http://localhost:9200/testing; | |
curl -w "\n" -X POST http://localhost:9200/testing/group -d '{"name":"default","description":"This is the default group.","id":null}'; | |
# This next request returns 0 hits | |
curl -w "\n" -X GET http://localhost:9200/testing/group/_search; | |
sleep 1; | |
# After waiting one second, this request returns the previously created document | |
curl -w "\n" -X GET http://localhost:9200/testing/group/_search; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ruby | |
if ENV['USER'] != 'root' | |
puts "I need to run with sudo!" | |
exit(1) | |
end | |
bad_rule = 'deny ip from any to any' | |
rule_id = nil | |
rules = `ipfw list`.split(/\n/) | |
rules.each do |rule| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sed -i -e '/^PermitRootLogin/d' /etc/ssh/sshd_config | |
echo 'PermitRootLogin without-password' >> /etc/ssh/sshd_config | |
service ssh restart || service sshd restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth' | |
require 'oauth/request_proxy/rack_request' | |
module OAuth | |
module RequestProxy | |
class RackRequest | |
proxies Grape::Request | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HTTParty | |
module ClassMethods | |
private | |
alias_method :orig_perform_request, :perform_request | |
def perform_request(http_method, path, options, &block) | |
if path.include? '@' | |
options ||= {} | |
scheme_auth, host_uri = path.split('@') | |
scheme, creds = scheme_auth.split('//') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt-get update | |
apt-get upgrade -y | |
apt-get autoremove -y | |
apt-get autoclean -y | |
apt-get install ufw -y | |
apt-get install denyhosts -y | |
# Configure firewall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://developer.ibm.com/answers/questions/462237/error-groot-must-be-grub-root-device-on-ubuntu/ | |
sed -i -e 's/LABEL=cloudimg-rootfs/(hd0)/' /boot/grub/menu.lst | |
apt-get update > /dev/null | |
apt-get install unattended-upgrades -y | |
timeout 20m unattended-upgrade | |
apt-get autoremove -y | |
apt-get autoclean -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DOMAIN=$(hostname -f) | |
export PASSPHRASE=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 128; echo) | |
subj=" | |
C=$1 | |
ST=$2 | |
O=$3 | |
localityName=$4 | |
commonName=$DOMAIN | |
organizationalUnitName=$5 |