Skip to content

Instantly share code, notes, and snippets.

Zoran Majstorovic zmajstor

  • Zagreb, Croatia
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
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 = [
View login_test.rb
require "minitest/mock"
require "test_helper"
class LoginTest < ActionDispatch::IntegrationTest
fixtures :pkis, :organizations, :users
def setup
@ldap_mock =
@ldap_mock.expect :tap,
zmajstor / my_view.html.erb
Created Oct 9, 2015
call ajax on SELECT change (in rails view)
View my_view.html.erb
<script type="text/javascript">
$(document).on("change", "#my_select", callAjax);
headers: { 'X-CSRF-Token': '<%= form_authenticity_token.to_s %>' },
timeout: 30000, // timeout after 30 seconds
async: true,
function callAjax() {
zmajstor /
Last active Aug 29, 2015
simple role-based authorization by current controller#action
zmajstor / foo.html.erb
Created Jul 2, 2015
Ajax in Rails View with X-CSRF-Token
View foo.html.erb
<%= check_box_tag "foo[delivered]", nil, foo.delivered, data: { id: }, class: "delivered" %>
<script type="text/javascript">
headers: { 'X-CSRF-Token': '<%= form_authenticity_token.to_s %>' },
timeout: 30000, // timeout after 30 seconds
async: true,
cache: false,
// dataType: "json", // The type of data that you're expecting back from the server
You can’t perform that action at this time.