Skip to content

Instantly share code, notes, and snippets.

View scarfacedeb's full-sized avatar
👀

Andrew Volozhanin scarfacedeb

👀
View GitHub Profile
@scarfacedeb
scarfacedeb / nginxrewrite2.md
Created August 15, 2016 13:12 — forked from esfand/nginxrewrite2.md
Nginx Rewrite
@scarfacedeb
scarfacedeb / nginx.conf
Last active August 29, 2015 14:28 — forked from conorh/nginx.conf
Using Nginx as a caching proxy for Refile with Ruby on Rails
http {
...
proxy_cache_path /data/perch.squaremill.com/shared/image_cache levels=1:2 keys_zone=images:10m;
...
}
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
module RetryableTyphoeus
require 'typhoeus'
include Typhoeus
DEFAULT_RETRIES = 1
class Request < Typhoeus::Request
def original_on_complete=(proc)
@original_on_complete = proc

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
@scarfacedeb
scarfacedeb / httpcors
Last active August 29, 2015 14:00 — forked from gkatsev/httpcors
#!/usr/bin/env python
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied