Skip to content

Instantly share code, notes, and snippets.

View zedtux's full-sized avatar

Guillaume Hain zedtux

View GitHub Profile
@zedtux
zedtux / kubernetes-secret-for-gitlab.sh
Created January 25, 2019 11:24
Kubernetes command to generate the docker-registry secret for Gitlab
echo "Creating the gitlab-registry secret ..."
# Save the JSON to create the gitlab-registry docker-registry secret
GITLAB_REGISTRY_SECRET_JSON=$(
kubectl create secret --namespace=$KUBE_NAMESPACE \
docker-registry gitlab-registry \
--docker-server="$CI_REGISTRY" \
--docker-username="${CI_DEPLOY_USER:-$CI_REGISTRY_USER}" \
--docker-password="${CI_DEPLOY_PASSWORD:-$CI_REGISTRY_PASSWORD}" \
--docker-email="$GITLAB_USER_EMAIL" \
--output json \
@zedtux
zedtux / gitlab-ci.sh
Created January 25, 2019 11:02
Gitlab AutoDevOps create_secret function extract
function create_secret() {
echo "Create secret..."
if [[ "$CI_PROJECT_VISIBILITY" == "public" ]]; then
return
fi
kubectl create secret -n "$KUBE_NAMESPACE" \
docker-registry gitlab-registry \
--docker-server="$CI_REGISTRY" \
--docker-username="${CI_DEPLOY_USER:-$CI_REGISTRY_USER}" \
@zedtux
zedtux / # node - 2018-06-20_14-53-33.txt
Created June 20, 2018 13:10
node on macOS 10.14 - Homebrew build logs
Homebrew build logs for node on macOS 10.14
Build date: 2018-06-20 14:53:33
@zedtux
zedtux / capybara.rb
Created March 16, 2018 06:47
Capybara configuration to be used with the SeleniumHQ/docker-selenium Docker image (https://github.com/SeleniumHQ/docker-selenium)
# Capybara defaults to CSS3 selectors rather than XPath.
# If you'd prefer to use XPath, just uncomment this line and adjust any
# selectors in your step definitions to use the XPath syntax.
# Capybara.default_selector = :xpath
Capybara.register_driver :chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: {
args: [
'--disable-default-apps',
@zedtux
zedtux / google_authenticator.rb
Created March 12, 2018 07:37
Google Authenticator OTP calculator (Used in my Cucumber tests)
module DeviseGoogleAuthenticatorHelpers
#
# Returns a valid One Time Password for the Google Authenticator gem.
#
# @param user [User] instance for which a valid OPT is requested.
# @return [Integer] first valid calculated OTP
#
def a_valid_otp_for(user)
calculate_otps_from(user.gauth_secret).first
end
@zedtux
zedtux / google_authenticator.rb
Created March 12, 2018 07:37
Google Authenticator OTP calculator (Used in my Cucumber tests)
module DeviseGoogleAuthenticatorHelpers
#
# Returns a valid One Time Password for the Google Authenticator gem.
#
# @param user [User] instance for which a valid OPT is requested.
# @return [Integer] first valid calculated OTP
#
def a_valid_otp_for(user)
calculate_otps_from(user.gauth_secret).first
end
@zedtux
zedtux / stack.yml
Created March 10, 2018 10:56
Another extract of a Docker Cloud Stack file with the restorelast command from the docker-pg_dump-to-swift Docker image
pg-dump2swift-restore:
command: restorelast
environment:
- OS_CONTAINER_NAME=app-production-db-backups
- OS_PASSWORD=<mot de passe swift>
- OS_REGION=<region>
- OS_TENANT_NAME=<numéro de tenant swift>
- OS_USERNAME=<nom d'utilisateur swift>
- PGDATABASE=app_production
image: 'yourcursus/docker-pg_dump-to-swift:9.5'
@zedtux
zedtux / stack.yml
Created March 10, 2018 10:53
Docker Cloud stack extract allowing to backup each nights a PostgreSQL DB
pg-dump2swift:
environment:
- OS_CONTAINER_NAME=app-production-db-backups
- OS_PASSWORD=<mot de passe swift>
- OS_REGION=<region>
- OS_TENANT_NAME=<numéro de tenant swift>
- OS_USERNAME=<nom d'utilisateur swift>
- PGDATABASE=app_production
image: 'yourcursus/docker-pg_dump-to-swift:9.5'
links:
@zedtux
zedtux / users_controller_spec.rb
Last active March 7, 2018 13:31
Unit tests for the simplest Rails API ever example with RSpec
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
describe 'index' do
context 'without any user' do
before { get :index }
it { is_expected.to respond_with 200 }
it 'should return an empty list' do
expect(JSON.parse(response.body)).to eql([])
end
@zedtux
zedtux / users_controller.rb
Created March 7, 2018 13:07
The most simple Rails API ever
class UsersController < ApplicationController
def index
render json: User.all
end
end