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 'benchmark' | |
| require 'set' | |
| array_size = (ENV['TOTAL'] || 1_000_000).to_i | |
| max_int = array_size / 5 | |
| array = 1.upto(array_size).map { rand(max_int) } | |
| if ENV['CHECK'] | |
| @correct = array.group_by { |e| e }.select { |k, v| v.size > 1 }.keys.sort | |
| 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
| #!/bin/bash -eux | |
| packer_ver=0.5.2 | |
| packer_prefix=/opt | |
| packer_arch=linux_amd64 | |
| mkdir -p ${packer_prefix}/packer-${packer_ver} | |
| cd ${packer_prefix}/packer-${packer_ver} | |
| wget https://dl.bintray.com/mitchellh/packer/${packer_ver}_${packer_arch}.zip | |
| unzip ${packer_ver}_${packer_arch}.zip && rm ${packer_ver}_${packer_arch}.zip |
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 'benchmark' | |
| require 'open3' | |
| require 'htauth/md5' | |
| SALT = | |
| def run_open3 | |
| Open3.popen3('htpasswd', '-nbm', 'username', 'password') { | stdin, stdout, stderr | stdout.read }.strip.split(':')[1] | |
| 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
| #!/bin/sh | |
| sed -i '' -e '$a\' $1 |
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 -eu | |
| # Dump all mysql databases in to separate files | |
| # config | |
| user=backup-db | |
| dir=/home/backup-db/data/mysql | |
| # runtime variables | |
| ts=$(date +%Y%m%d%H%M%S) | |
| dbs=$(sudo -i -u ${user} mysql -N -r -s -e 'SHOW DATABASES' | egrep -v '^information_schema|performance_schema$') |
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 -eux | |
| # http://docs.saltstack.com/en/latest/topics/tutorials/quickstart.html | |
| # bootstrap salt minion | |
| curl -L https://bootstrap.saltstack.com | sh | |
| # make it masterless | |
| sed -i 's/^#file_client: remote$/file_client: local/' /etc/salt/minion |
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
| namespace :deploy do | |
| namespace :git do | |
| before :check, :local_repo do | |
| on release_roles :all do | |
| unless test "[ -d #{fetch(:local_repo_path)} ]" | |
| execute :mkdir, '-p', fetch(:local_repo_path) | |
| execute :git, "init --bare #{fetch(:local_repo_path)}" | |
| 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
| puts Identity.unscoped.group(:provider).count | |
| users = User.includes(:identities).all | |
| duplicated_providers = %w(ldap ldapmain).sort | |
| old_provider = 'ldap' | |
| new_provider = 'ldapmain' | |
| users.each do |u| | |
| next if u.identities.blank? |
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
| import java.io.BufferedReader; | |
| import java.io.InputStreamReader; | |
| import java.net.URL; | |
| public class Ipify { | |
| public static void main(String[] args) throws Exception { | |
| URL url = new URL("http://api.ipify.org"); | |
| BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8")); | |
| for (String line; (line = reader.readLine()) != null;) { | |
| System.out.println(line); |
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 | |
| REMOTE=$1 | |
| if [[ -z "$REMOTE" ]] ; then | |
| REMOTE='origin' | |
| fi | |
| PARSED=$(git remote -v | grep '(fetch)' | grep "^$REMOTE\t" | awk -F "\t| " '{print $2}' | sed -E -e 's/\.git$//' -e 's/^.+@//') | |
| if [[ -z "$PARSED" ]] ; then | |
| echo "Cannot find git remote: $REMOTE" |
OlderNewer