Skip to content

Instantly share code, notes, and snippets.

View alekpopovic's full-sized avatar
🏠
Working from home

Aleksandar Popovic alekpopovic

🏠
Working from home
View GitHub Profile
@alekpopovic
alekpopovic / docker-container.sh
Created April 29, 2024 11:20 — forked from maglnet/docker-container.sh
Sample Docker Startup Script
#!/bin/bash
WEB_PORT=8080
WEB_CONTAINER_NAME="zf2-web"
MYSQL_CONTAINER_NAME="zf2-mysql"
MYSQL_PASSWORD="mypassword"
MYSQL_LOCAL_PORT=13306
@alekpopovic
alekpopovic / Dockerfile
Created April 24, 2024 13:40 — forked from remarkablemark/Dockerfile
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@alekpopovic
alekpopovic / debug.rake
Created January 30, 2024 13:55 — forked from jameslafa/debug.rake
Easily debug rake task
desc "switch rails logger to stdout"
task :verbose => [:environment] do
Rails.logger = Logger.new(STDOUT)
end
desc "switch rails logger log level to debug"
task :debug => [:environment, :verbose] do
Rails.logger.level = Logger::DEBUG
end
@alekpopovic
alekpopovic / person.rb
Created November 18, 2023 19:12 — forked from davidbella/person.rb
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then
@alekpopovic
alekpopovic / person.rb
Created November 18, 2023 19:12 — forked from pangui/person.rb
require 'json'
class Person
@age = nil
attr_accessor :json_field, :age
def initialize *args
# useful for Rails ApplicationRecord models
args[0].each{|key, value| self.send("#{key}=".to_sym, value)}
# uncomment next line for inherited classes
# super *args
@alekpopovic
alekpopovic / JenkinsSecrets.md
Created October 11, 2023 10:01 — forked from ju4nlu/JenkinsSecrets.md
Using Jenkins Secrets and embedding them in a pipeline

1. Add new Secret to Jenkins Credentials

First of all we need to add the secret to the Jenkins Credentials management system. To do so, navigate through the menus to section

Jenkins > Credentials > System > Global credentials (unrestricted) > Add credentials

Then select the kind of secret that you need and specify its value.

@alekpopovic
alekpopovic / README.md
Created September 16, 2023 21:24 — forked from vavdoshka/README.md
ArgoCD and ArgoWorkflows SSO config with AWS Cognito

ArgoCD and ArgoWorkflows SSO config with AWS Cognito

So you have fantastic ArgoCD or mind-boggling ArgoWorkflows (this guide covers both), and if you want to secure the Authentication with AWS Cognito, let's dive right in.

I found many different sources unveiling some pieces of the required configuration but no resources where one can see the whole picture. I hope this guide will be one of such places. This guide will mean no DEX usage, just rely on Argo's built-in OpenID Connect flow.

Table of contents

@alekpopovic
alekpopovic / Install update WordPress puglins directly.md
Created August 2, 2023 08:06 — forked from dianjuar/Install update WordPress puglins directly.md
Install update WordPress plugins without providing ftp access

Install WordPress plugins directly (without FTP)

Put this on your wp-config.php

/* That's all, stop editing! Happy blogging. */
define('FS_METHOD', 'direct');
@alekpopovic
alekpopovic / change_author_git_commit.md
Created May 22, 2023 21:37 — forked from albertodebortoli/change_author_git_commit.md
Change the author of a commit in Git

Using Interactive Rebase

git rebase -i -p <some HEAD before all of your bad commits>

Then mark all of your bad commits as "edit" in the rebase file, and when git asks you to amend each commit, do

git commit --amend --author "New Author Name <email@address.com>"

edit or just close the editor that opens, and then do

@alekpopovic
alekpopovic / unicorn.rb
Created May 18, 2023 11:33 — forked from kripy/unicorn.rb
Heroku Sequel Fork
# Using Sequel with Sinatra (Unicorn) on Heroku and getting this error:
# Sequel::DatabaseDisconnectError - PG::ConnectionBad: PQconsumeInput() SSL error: decryption failed or bad record mac.
# Need to do some forking.
# In unicorn.rb:
worker_processes 4 # amount of unicorn workers to spin up
timeout 30 # restarts workers that hang for 30 seconds
preload_app true # avoid regeneration of jekyll site for each fork
before_fork do |server, worker|
Signal.trap 'TERM' do