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 / phx-1.4-upgrade.md
Created October 14, 2024 09:32 — forked from chrismccord/phx-1.4-upgrade.md
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@alekpopovic
alekpopovic / README.md
Created October 4, 2024 21:14 — forked from JonathanTurnock/README.md
Get Current Jenkins Git Commit Hash

To Display the current git commit hash execute the following snipped:

git rev-parse --short HEAD

To Extract this to use in a Jenkinsfile use the sh function with the script and returnStdout parameter set to true:

def commitHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true)
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@alekpopovic
alekpopovic / encrypt_decrypt.rb
Created September 16, 2024 21:13 — forked from wteuber/encrypt_decrypt.rb
Simply encrypt and decrypt Strings in Ruby.
require 'openssl'
class String
def encrypt(key)
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = Digest::SHA1.hexdigest key
s = cipher.update(self) + cipher.final
s.unpack('H*')[0].upcase
end
@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
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.