Skip to content

Instantly share code, notes, and snippets.

Zoran Majstorovic zmajstor

Block or report user

Report or block zmajstor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View watch.ps1
# install with:
# iex ((new-object net.webclient).DownloadString(""))
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 /
Last active Apr 4, 2019
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:


  • 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 / migrating_mysql_to_rds.txt
Last active Dec 15, 2018
MySQL DB Migration from localhost to AWS RDS
View migrating_mysql_to_rds.txt
View ldap_test.rb
# ---- edit data below ------------
LDAP_PORT = 636 # 636 or 389
LDAP_BASE = "dc=promdm, dc=net"
LDAP_BIND_USER = "" # format is username@domain
LDAP_BIND_PASS = "ldapbindpassword"
samaccountname = "zm"
password = "userpassword"
# ----- edit end ------------------
zmajstor / info.rake
Created Feb 14, 2017
Herokuised Capistrano Tasks
View info.rake
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 / application_controller.rb
Last active Dec 15, 2016
current_user helpers without Devise
View application_controller.rb
class ApplicationController < ActionController::Base
include SessionsHelper
Unauthorized =
def authorize_user!
raise Unauthorized unless current_user
View openssl_asn1_decode_test.rb
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 = # suppress usec
serial = 0xdeadbeafdeadbeafdeadbeafdeadbeaf
exts = [
zmajstor / MyModel.rb
Created Jan 6, 2014
Rails (ActiveRecord) after_save callback for single field change
View MyModel.rb
class MyModel < ActiveRecord::Base
after_save :do_something, if: :my_filed_changed?
def do_something
# my_filed has been changed ... do something
zmajstor / application.html.erb
Created Nov 2, 2013
conditional include of css, js based on controller (previously disable require_tree . in application.css/js)
View application.html.erb
<% if current_page?(controller: 'foo_bar') %>
<%= stylesheet_link_tag "foo", media: "all" %>
<%= javascript_include_tag "bar" %>
<% end %>
zmajstor / _form.html.haml
Last active Dec 23, 2015
Rails nested form (Add/Remove nested resource without Controller for nested resource) inspired by and * to destroy the associated model: add the _destroy key to the attributes hash, with a…
View _form.html.haml
= simple_form_for @portfolio do |f|
= f.input :title, label: 'Portfolio Title'
= f.simple_fields_for :assets do |assets_form|
= assets_form.association :stock
= assets_form.input :amount, :input_html => { min: 0 }
= link_to 'Remove', '', :class => 'destroy_duplicate_nested_form'
= assets_form.input :id, as: :hidden
You can’t perform that action at this time.