Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View zmajstor's full-sized avatar

Zoran Majstorovic zmajstor

View GitHub Profile
@zmajstor
zmajstor / 0-README.md
Last active December 12, 2023 11:39
Docker on CentOS Linux

NGINX reverse-proxy with Let's Encrypt Certs with Docker Compose

Acts as a single reverse proxy with SSL offloading for any number of dockerized web projects on a single server, using 2 awesome projects:

jwilder/nginx-proxy

  • the reverse proxy is be the only container that actually needs to expose any ports to the world.
  • base image is just a regular nginx
  • the only container that actually exposes anything to the outside world, both port 80 and 443
@zmajstor
zmajstor / simpleApiPost.js
Created February 13, 2023 16:38
Simple HTTPS Post using node:https
const NODE_HTTPS = require('node:https')
const NODE_URL = require('node:url')
// resolves to response status code is success
const simpleApiPost = ({ endpointURL, body, bearerToken }) => new Promise((resolve, reject) => {
try {
const options = {
...NODE_URL.parse(endpointURL),
port: 443,
method: 'POST',
@zmajstor
zmajstor / usdTecajNaDan.gs
Last active February 12, 2023 10:07
USD srednji_tecaj in Google Sheets via HNB API V3
// Custom Functions in Google Sheets:
// https://developers.google.com/apps-script/guides/sheets/functions
//
function usdTecajNaDan(value) {
function formatDatum(value) {
switch (typeof value) {
case "string":
return value;
case "object":
// assuming it's a date object
@zmajstor
zmajstor / ldap_test.rb
Last active April 16, 2021 08:25
LDAP test
# ---- edit data below ------------
LDAP_HOST = 'promdmnet.cloudapp.net'
LDAP_PORT = 636 # 636 or 389
LDAP_BASE = "dc=promdm, dc=net"
LDAP_BIND_USER = "ldapbind@promdm.net" # format is username@domain
LDAP_BIND_PASS = "ldapbindpassword"
samaccountname = "zm"
password = "userpassword"
# ----- edit end ------------------
@zmajstor
zmajstor / pksc7_verify.rb
Created May 23, 2015 21:40
OpenSSL::PKCS7#verify test
require 'openssl'
require 'base64'
require "test/unit"
BODY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Status</key>\n\t<string>Idle</string>\n\t<key>UDID</key>\n\t<string>b7ebaaa53fda9be2f7787eff7c1f4aca4e36f79d</string>\n</dict>\n</plist>\n"
SIGNATURE_BASE64 = "MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIIHTCCA20wggJVoAMCAQICEESzOh1IytmdQqbap8VUON0wDQYJKoZIhvcNAQEFBQAwSTETMBEGCgmSJomT8ixkARkWA25ldDEWMBQGCgmSJomT8ixkARkWBnByb21kbTEaMBgGA1UEAxMRUHJvbWRtTkVUUm9vdENBdjEwHhcNMTIwOTI1MDgyODI2WhcNMzIwOTI1MDgzODI1WjBJMRMwEQYKCZImiZPyLGQBGRYDbmV0MRYwFAYKCZImiZPyLGQBGRYGcHJvbWRtMRowGAYDVQQDExFQcm9tZG1ORVRSb290Q0F2MTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN43J/4Pimp7CEO7mA7V9A+Dj9NX1Cz0x97SncGqkh+x1xz6Ofoiq9vV2UC5DYIvGf3VVWErPwSXVQJ1Jd/uksCkVktC9zUfInYTb8dSGZ3MdrIntT83XWCkzPAjPZHOicBvU0hRCoY6r/FoQbVAIH+FnuEaGmXM+SYVbed6OLf3RN3DJPFw7y0xiJr3DRg
# https://4sysops.com/archives/monitor-file-changes-in-windows-with-powershell-and-pswatch
# install with:
# iex ((new-object net.webclient).DownloadString("http://bit.ly/Install-PsWatch"))
Import-Module pswatch
watch ".\scss" | ForEach-Object {
write-host "Change made on $($_.Path)"
$sassc = 'C:\sassctest\proba-npm\proba-npm\sassc.exe'
$params = 'scss/style.scss css/style.css'.split(" ")
@zmajstor
zmajstor / migrating_mysql_to_rds.txt
Last active December 15, 2018 14:08
MySQL DB Migration from localhost to AWS RDS
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Procedural.Importing.External.Repl.html
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql_rds_stop_replication.html
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql_rds_reset_external_master.html
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_BestPractices.html
https://www.elitmus.com/blog/technology/setting-up-amazon-rds-as-a-slave-to-a-self-managed-mysql-server/
https://plusbryan.com/mysql-replication-without-downtime
https://www.borfast.com/blog/2014/02/15/how-to-add-a-slave-to-a-mysql-replication-setup-with-no-downtime/
http://stackoverflow.com/a/32716003
https://www.bonusbits.com/wiki/HowTo:Configure_iptables_to_Allow_Access_to_Common_Services_on_Linux
@zmajstor
zmajstor / info.rake
Created February 14, 2017 17:20
Herokuised Capistrano Tasks
namespace :info do
desc 'Show deployed revisions (releases)'
task :releases do
on roles(:app) do
within deploy_path do
with rails_env: "#{fetch(:stage)}" do
deployed_releases = capture(:tac, revision_log)
puts "=== #{fetch(:application)} releases:"
puts deployed_releases
@zmajstor
zmajstor / application_controller.rb
Last active December 15, 2016 10:39
current_user helpers without Devise
class ApplicationController < ActionController::Base
include SessionsHelper
Unauthorized = Class.new(StandardError)
def authorize_user!
raise Unauthorized unless current_user
end
end
require 'openssl'
require "minitest/autorun"
class OpenSSL::TestASN1 < Minitest::Test
def test_decode
subj = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=TestCA")
key = OpenSSL::TestUtils::TEST_KEY_RSA1024
now = Time.at(Time.now.to_i) # suppress usec
serial = 0xdeadbeafdeadbeafdeadbeafdeadbeaf
exts = [