Skip to content

Instantly share code, notes, and snippets.

View zaiste's full-sized avatar
🌀
Loading...

Jakub Neander zaiste

🌀
Loading...
View GitHub Profile
@timnovinger
timnovinger / proxy.pac
Created May 10, 2010 04:19
Proxy PAC file for watching UK telly outside of the UK
// ========================================================
// Route traffic through UK based proxy
// ========================================================
function FindProxyForURL(url, host) {
// --------------------------------------------------------
// No longer work still it seems
// --------------------------------------------------------
// 92.52.125.20:80
require 'active_support/basic_object'
ActiveRecord::Base.class_eval do
class WithoutCallbacks < ActiveSupport::BasicObject
def initialize(target, types)
@target = target
@types = types
end
def respond_to?(method, include_private = false)
# encoding: utf-8
module Mongoid #:nodoc:
module Associations #:nodoc:
module EmbeddedCallbacks
# bubble callbacks to embedded assocaitions
def run_callbacks(*args)
# now bubble callbacks down
self.associations.each_pair do |name, meta|
if meta.association == Mongoid::Associations::EmbedsMany
@mhenrixon
mhenrixon / _form.html.haml
Created May 18, 2011 11:02
A complete sample of how to perform nested polymorphic uploads in rails using carrierwave
=semantic_form_for [:admin, @dog], validate: true, html: {multipart: true} do |f|
=f.inputs do
=f.input :name
=f.input :kennel_name
=f.input :birthdate
=f.input :gender, as: :radio, collection: {'Tik' => 'F', 'Hane' => 'M'}
=f.input :father_id, as: :select, collection: @dogs
=f.input :mother_id, as: :select, collection: @bitches
=f.semantic_fields_for :pictures do |pic|

Sprockets Railtie Setup

This file at actionpack/lib/sprockets/railtie.rb defines the Sprockets::Railtie, defining another Railtie for Rails. This Railtie is responsible for detecting if the application at-hand is using CoffeeScript, and if so will set config.app_generators.javascript_engine on the application to be :coffee.

Next, this defines an initializer called sprockets.set_configs which sets up ActionController::Base to either use or not use sprockets depending on the configuration option config.assets.enabled.

Finally, this file defines an after_initialize hook for the application which is the real meat of this Railtie. If assets are disabled (with the config.assets.enabled config option set to false) then this after_initialize hook will do nothing.

If assets are enabled then, this initializer first makes a call to an asset_environment protected method near the bottom of this file which requires the sprockets gem, creates a new Sprockets::Environment object, and then co

@mrsweaters
mrsweaters / nginx_virtual_host
Created October 23, 2011 17:10 — forked from scottlowe/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
upstream example-workers {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a single worker for timing out).
server unix:/tmp/example.co.uk.socket fail_timeout=0;
}
server {
listen 80; # default;
server_name example.co.uk;
root /home/example.co.uk/website/public;
@fireyy
fireyy / proxy.pac
Created November 29, 2011 02:58 — forked from ayanamist/proxy.pac
My Pac File for Auto Proxy
var PROXY = {};
PROXY.direct = "DIRECT";
PROXY.goagent = "PROXY 127.0.0.1:8087";
PROXY.vps = "PROXY 127.0.0.1:8123";
PROXY.edu = "PROXY 127.0.0.1:4080";
PROXY.adblock = "PROXY 127.0.0.1:8080";
PROXY.acc = PROXY['goagent'];
var DEFAULT = PROXY['direct'];
var ADBLOCK = {
@du-song
du-song / simple.pac
Created December 16, 2011 20:30
relatively short PAC file for bypassing GFW and blocking ads on iPhone.
function FindProxyForURL(url, host) {
var p = "PROXY example.server:1989";
if (shExpMatch(host, "*twitter.com*")) return p;
if (shExpMatch(host, "*t.co")) return p;
if (shExpMatch(host, "*bit.ly")) return p;
if (shExpMatch(host, "*j.mp")) return p;
if (shExpMatch(host, "*facebook.com*")) return p;
if (shExpMatch(host, "*facebook.net*")) return p;
if (shExpMatch(host, "*fbcdn.net")) return p;
if (shExpMatch(host, "*twimg.com")) return p;
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@amacdougall
amacdougall / focus.vim
Created March 6, 2012 23:38
Simple vim script for a single centered text column.
" Name: focus.vim
" Author: Alan MacDougall <smoke@alanmacdougall.com>
" License: Public Domain
"
" Focus on a single column of text, showing it in a distraction-free format.
" Save this as ~/.vim/scripts/focus.vim (or whatever you please), and invoke
" it with :source <filename>. Of course, you could certainly hook that up to a
" :command, or a macro, or a Vimscript function...
" collapse current splits and divide screen in three