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 / 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/
@alekpopovic
alekpopovic / brew-install-kali-tools.sh
Created October 24, 2022 09:16 — forked from MattyBonBon/brew-install-kali-tools.sh
Script to install kali tools that are already included in homebrew
#
# Created from crossmatching katoolin listing & brew search
# to execute:
# $ sh "/path/to/file"
#
echo "Checking for 🍺..."
if test ! $(which brew); then
echo "Installing homebrew (🍺)..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@alekpopovic
alekpopovic / docker-compose.yml
Created October 12, 2022 10:46 — forked from cmackenzie1/docker-compose.yml
Docker Compose for DynamoDB Local and Admin UI
version: '3.7'
services:
dynamodb-local:
image: amazon/dynamodb-local:latest
container_name: dynamodb-local
ports:
- "8000:8000"
dynamodb-admin:
image: aaronshaf/dynamodb-admin
@alekpopovic
alekpopovic / gh-deploy.sh
Created October 5, 2022 13:32 — forked from patarapolw/gh-deploy.sh
Vite on Github Pages with HTML5 History Mode
#!/usr/bin/env bash
set -e
rm -rf dist
GH=1 yarn build
GIT_URL=$(git remote get-url origin)
cd dist
@alekpopovic
alekpopovic / bigkeys (new)
Created October 3, 2022 15:24 — forked from michael-grunder/bigkeys (new)
redis-cli --bigkeys (new)
➜ src git:(cli_improved_bigkeys) ✗ time ./redis-cli --bigkeys
# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type. You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).
[00.00%] Biggest hash found so far '530f8e1db5876:1:hash:146377' with 44 fields
[00.00%] Biggest list found so far '530f8ed14a8b0:17:list:269378' with 193 items
[00.00%] Biggest set found so far '530f8da537194:83:set:63043' with 432 members
[00.00%] Biggest string found so far '530f8f2de7045:95:string:333887' with 345 bytes
@alekpopovic
alekpopovic / osx_setup.md
Created September 30, 2022 10:50 — forked from mcls/osx_setup.md
Setup mac for ruby dev
@alekpopovic
alekpopovic / nginx-server-block-generator.sh
Created September 28, 2022 11:36 — forked from 0xAliRaza/nginx-server-block-generator.sh
A handy shell script to create Nginx server-block (virtual host).
#!/usr/bin/env bash
#
# Nginx - new server block
# Functions
ok() { echo -e '\e[32m'$1'\e[m'; } # Green
die() {
echo -e '\e[1;31m'$1'\e[m'
exit 1
}