Skip to content

Instantly share code, notes, and snippets.

View mignev's full-sized avatar

Marian Ignev mignev

View GitHub Profile
@reorx
reorx / hash_ring.py
Last active August 18, 2022 14:59
Consistent hash implementation in Python.
# -*- coding: utf-8 -*-
"""
hash_ring
~~~~~~~~~~~~~~
Implements consistent hashing that can be used when
the number of server nodes can increase or decrease (like in memcached).
Consistent hashing is a scheme that provides a hash table functionality
in a way that the adding or removing of one slot
does not significantly change the mapping of keys to slots.
@daveshah
daveshah / crawler.rb
Last active January 1, 2016 13:09
Crawling the clinic site for all our css yo'
require 'anemone'
require 'nokogiri'
require 'set'
@url = "http://my.clevelandclinic.org/default.aspx"
@moss_garbage = "layouts/1033/styles"
@css_link_set = Set.new
@flash_link_set = Set.new
@vimishor
vimishor / 503.html
Last active December 31, 2015 05:59
Custom 503 page while deploy on openshift | License: MIT
<!DOCTYPE html>
<html>
<head>
<title>Deploy in progress. Please try again in few minutes</title>
<style type="text/css" />
body {color: #666; text-align: center; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; sans-serif; margin:0; width: 800px; margin: auto; font-size: 14px; }
h1 { font-size: 56px; line-height: 100px; font-weight: normal; color: #456; }
h2 { font-size: 24px; color: #666; line-height: 1.5em; }
h3 { color: #456; font-size: 20px; font-weight: normal; line-height: 28px; }
hr { margin: 18px 0; border: 0; border-top: 1px solid #EEE; border-bottom: 1px solid white; }

Install routing plugin

yum install rubygem-openshift-origin-routing-activemq.noarch

Create routing-plugin configuration file

cp /etc/openshift/plugins.d/openshift-origin-routing-activemq.conf.example /etc/openshift/plugins.d/openshift-origin-routing-activemq.conf

Add routinginfo user into activemq.xml configuration file. See files below.

# The initial was for Varnish 2.1, this has been updated for Varnish 3.
# The upgrade changes were based on the docs here:
# https://www.varnish-cache.org/docs/3.0/installation/upgrade.html
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render json: user.as_json(auth_token: user.authentication_token, email: user.email), status: :created
return
else
@fabiofl
fabiofl / gist:5873100
Created June 27, 2013 00:41
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
@ogrrd
ogrrd / dnsmasq OS X.md
Last active October 16, 2025 11:59
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@caruccio
caruccio / rh-openshift-error-codes.txt
Created January 8, 2013 00:36
RedHat Openshift error codes (extracted from source files - grep+python). Neither comprehensive or 100% correct, but it is a start...
SHOW_APPLICATION:
404 Not Found:
101: "Application '#{id}' not found"
127: "Domain '#{domain_id}' not found"
UPDATE_CARTRIDGE:
404 Not Found:
163: "Cartridge '#{cartridge_name}' for application '#{app_id}' not found"
101: "Application '#{app_id}' not found for domain '#{domain_id}'"
@boris317
boris317 / build.sh
Created October 1, 2012 15:42
OpenShift action hooks for python tornado deployment.
#!/bin/bash
#
# .openshift/action_hooks/build
#
DIR=$( cd "$( dirname "$0" )" && pwd )
source $DIR/../env.sh
if [ ! -d $X_OPENSHIFT_VENV ]; then
echo "[build] $(virtualenv --distribute $X_OPENSHIFT_VENV)"