Skip to content

Instantly share code, notes, and snippets.

View scicco's full-sized avatar

scicco

View GitHub Profile
@scicco
scicco / tcp_proxy.sh
Created February 20, 2018 14:53
tcp proxy using netcat
#!/bin/sh -e
# found here: https://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html
if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dst-host> <dst-port>"
exit 0
fi
@scicco
scicco / register_gitlab_runner.sh
Last active March 7, 2023 16:32
register_gitlab_runner.sh
#!/bin/bash
docker run --name gitlab-runner-register -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v gitlab-runner-config:/etc/gitlab-runner \
gitlab/gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:latest \
--url "<GITLAB_URL_HERE>" \
--registration-token "<TOKEN_HERE>" \
@scicco
scicco / run_gitlab_runner.sh
Created March 7, 2023 16:31
run_gitlab_runner.sh
#!/bin/bash
docker run -d \
--name gitlab-runner \
--restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v gitlab-runner-config:/etc/gitlab-runner \
gitlab/gitlab-runner
docker logs -f gitlab-runner
@scicco
scicco / stop_gitlab_runner.sh
Created March 7, 2023 16:30
stop_gitlab_runner.sh
#!/bin/bash
docker ps -a | grep runner | cut -d' ' -f1 | xargs -d $'\n' bash -c 'for arg do docker stop -t 1 "$arg"; docker rm "$arg"; done' _
@scicco
scicco / clear_github_runner.sh
Created March 7, 2023 16:29
clear_github_runner.sh
#!/bin/bash
docker volume rm gitlab-runner-config
docker volume create gitlab-runner-config
@scicco
scicco / yarn_licences_csv.rb
Last active February 8, 2023 16:14
yarn_licences_csv.rb
# "@ampproject/remapping", # name
# "2.2.0", # version
# "Apache-2.0", # license
# "git+https://github.com/ampproject/remapping.git", # repository
# "Unknown", # homepage
# "Justin Ridgewell" # author
require 'json'
require 'csv'
# Read data from the JSON file
file = File.read('yarn_licenses.json')
@scicco
scicco / rails_new_api_service
Created January 4, 2022 09:28
create new Rails API service
rails new my_api_service \
--skip-action-mailer \
--skip-action-mailbox \
--skip-action-cable \
--skip-action-text \
--skip-asset-pipeline \
--skip-javascript \
--skip-hotwire \
--skip-bootsnap \
--skip-system-test \
@scicco
scicco / devise_pwned_passwords_hooks.rb
Created March 15, 2021 14:31
Devise - Check if existing user has weak passwords and force password change
Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
if user.class.respond_to?(:pwned_password_check_on_sign_in) && user.class.pwned_password_check_on_sign_in
password = auth.request.params.fetch(opts[:scope], {}).fetch(:password, nil)
is_pwned = password && auth.authenticated?(opts[:scope]) && user.respond_to?(:password_pwned?) && user.password_pwned?(password)
if is_pwned
Devise.sign_out_all_scopes
if defined?(::Devise::Models::Recoverable) && user.respond_to?(:send_reset_password_instructions)
user.send_reset_password_instructions
message = :pwned_recoverable
else
#!/bin/bash
for listfile in /var/lib/dpkg/info/*.list; do
listfilename=$(basename -- "$listfile")
listfilename="${listfilename%.*}"
echo ${listfilename}
#break
output=$(file ${listfile}| awk '{print $2}')
#echo "${output}"
if [[ $output == *"data"* ]]; then
echo "${listfile} is DATA!"
#!/bin/bash
for listfile in /var/lib/dpkg/info/*.list.broken; do
#echo ${listfile##*/}
listfilename=$(basename -- "$listfile")
listfilename="${listfilename%.*}"
echo "list file name: ${listfilename}"
if [ -f "/var/lib/dpkg/info/${listfilename}" ]; then
output=$(file "/var/lib/dpkg/info/${listfilename}" | awk '{print $2}')
echo $output
#break