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 / Makefile
Created May 16, 2023 15:27 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@alekpopovic
alekpopovic / README.md
Created March 27, 2023 10:41 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@alekpopovic
alekpopovic / obj.html.erb
Created March 15, 2023 13:01
ruby varst to js object
<%=
name = "Aleksandar"
age = 41
city = "Mozgovo"
%>
<script>
var object = JSON.parse('{"name":"<%= name %>", "age":"<%= age %>", "city":"<%= city %>"}')
console.log(object)
</script>
@alekpopovic
alekpopovic / create-vanilla-cluster.sh
Created March 12, 2023 01:50 — forked from fgauna12/create-vanilla-cluster.sh
Create vanilla AKS cluster with Azure CNI and Virtual Network
#!/bin/bash
set -ex
echo "Creating cluster with base name $1 on $2"
if [ -z "$1" ]
then
echo "Please provide the name of the cluster."
exit -1
@alekpopovic
alekpopovic / kube_service_create.sh
Created February 7, 2023 23:02 — forked from ganesh-karthick/kube_service_create.sh
PgAdmin Kubernetes service depoyment example
#!/usr/bin/env bash
kubectl create -f pgadmin.yaml
sleep 15s
kubectl logs pgadmin-76gjgvvjh-yghg
## Access pgAdmin
## https://<IP>:31560
## username/password: [email protected] / password
@alekpopovic
alekpopovic / heroku-remote.md
Created January 25, 2023 12:43 — forked from randallreedjr/heroku-remote.md
Add a Heroku remote to an existing git repo

Working with git remotes on Heroku

Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. heroku create. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful.

Adding a new remote

Add a remote for your Staging app and deploy

Note that on Heroku, you must always use master as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax local_branch:destination_branch seen below (in this example, we push the local staging branch to the master branch on heroku.

$ git remote add staging https://git.heroku.com/staging-app.git
@alekpopovic
alekpopovic / iframechange.js
Created January 20, 2023 10:59 — forked from hdodov/iframechange.js
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
@alekpopovic
alekpopovic / controller.go
Created December 10, 2022 17:21 — forked from goodylili/controller.go
Updates to LogRocket's Gin Gonic tutorial article
package controllers
import (
"Go-Tutorials/models"
"github.com/gin-gonic/gin"
"net/http"
)
type CreateBookInput struct {
Title string `json:"title" binding:"required"`
@alekpopovic
alekpopovic / ruby.yml
Created November 25, 2022 17:25 — forked from tadast/ruby.yml
Example github actions config for Rails with postgres using DATABASE_URL
name: Ruby
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@alekpopovic
alekpopovic / application_helper.rb
Created November 3, 2022 15:34 — forked from kinopyo/application_helper.rb
Rails: Detect if mobile agent
# from https://github.com/ruby-china/ruby-china/blob/master/app/helpers/application_helper.rb
MOBILE_USER_AGENTS = 'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' +
'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' +
'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' +
'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' +
'webos|amoi|novarra|cdm|alcatel|pocket|iphone|mobileexplorer|mobile'
def mobile?
agent_str = request.user_agent.to_s.downcase
return false if agent_str =~ /ipad/