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
# 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 / 0-README.md
Last active Apr 4, 2019
Docker on CentOS Linux
View 0-README.md

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 / migrating_mysql_to_rds.txt
Last active Dec 15, 2018
MySQL DB Migration from localhost to AWS RDS
View migrating_mysql_to_rds.txt
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
View ldap_test.rb
# ---- 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 / 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
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 = Class.new(StandardError)
def authorize_user!
raise Unauthorized unless current_user
end
end
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 = Time.at(Time.now.to_i) # suppress usec
serial = 0xdeadbeafdeadbeafdeadbeafdeadbeaf
exts = [
@zmajstor
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
end
end
@zmajstor
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
zmajstor / _form.html.haml
Last active Dec 23, 2015
Rails nested form (Add/Remove nested resource without Controller for nested resource) inspired by http://davidlesches.com/blog/rails-nested-forms-using-jquery-and-simpleform and http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html * 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|
.duplicatable_nested_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.