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
ChuckJHardy / example_activejob.rb
Last active Jun 17, 2019
Example ActiveJob with RSpec Tests
View example_activejob.rb
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
def perform(*args)*args)
chinchang / xmlToJson.js
Last active Aug 21, 2019
Function to convert XML to JSON
View xmlToJson.js
* Changes XML to JSON
* Modified version from here:
* @param {string} xml XML DOM tree
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) {
janko / keyword_arguments.rb
Last active Jul 24, 2018
Ruby keyword arguments advantages and use cases
View keyword_arguments.rb
# 1. Simple assertion of required arguments
# - You can forget #fetch
# - You get a better error, and always on the line where method is defined
def search(options = {})
query = options.fetch(:query)
search() # => KeyError: key not found :query

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets!

Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

bruno- / gist:eddd6298deaa4940c52c
Created Aug 13, 2014
signing git commits - cheat sheet
View gist:eddd6298deaa4940c52c



  • faking other user's commits is easy with --author flag $ git commit --author='Foo Bar <>' -m 'some commit'

  • signing commits ensures:

    • someone else can't commit as myself
    • I really commited all the commits I sign
janko / application.rb
Created Jun 7, 2014
Custom error pages in Rails
View application.rb
module MyApp
class Application < Rails::Application
# ...
config.exceptions_app = self.routes
"RDS::ResourceNotFound" => :not_found,
# ...
janko / ldap.rb
Last active Aug 29, 2015
Example Faraday integration with the LDAP protocol, with caching to the database.
View ldap.rb
require "faraday"
module Faraday
class Adapter
class NetLdap < Faraday::Adapter
def call(env)
# LDAP request, and call `save_response(env, status, body, headers)`
bruno- /
Last active Aug 20, 2019
Easy Rails deployment with Capistrano

Goals of this tutorial:

  • deploy a new Rails app with capistrano
  • make it fast (total process takes less than 5 minutes)
  • make it simple (no unecessary config)
  • manual ssh to the server not required

Rails application stack:

  • nginx
  • unicorn
  • postgresql
javan / application_controller.rb
Created Nov 30, 2013
Prevent cross-origin js requests
View application_controller.rb
class ApplicationController < ActionController::Base
before_filter :ensure_xhr
def ensure_xhr
if request.get? && request.format && (request.format.js? || request.format.json?)
head :forbidden unless request.xhr?
mitfik / ruby_csr_example.rb
Created Feb 27, 2012
Ruby example of CSR with openssl
View ruby_csr_example.rb
require 'openssl'
def gen_key(name)
key = 1048
file =, "w")
def get_key(name)
You can’t perform that action at this time.