Skip to content

Instantly share code, notes, and snippets.

amw / proxy.pac
Created Nov 20, 2019
ŚUM proxy auto-config file (modified)
View proxy.pac
function FindProxyForURL(url, host) {
if (shExpMatch(host, "")) { return "DIRECT" };
if (
//shExpMatch(host,"*") ||
shExpMatch(host,"*") ||
shExpMatch(host,"*") ||
shExpMatch(host,"*") ||
View gist:be5392b7f0e34c739910fdd61a3ff678
class Parent:
def get_shared(cls):
cls._SHARED_ONLY_FOR_READING = cls.__name__
return cls.__name__
def print_shared(self):
amw / dispatch.swift
Last active Nov 4, 2016
Swift wrapper for Grand Central Dispatch (GCD)
View dispatch.swift
// dispatch.swift
// Created by Adam Wróbel. Read more at:
import Foundation
internal extension dispatch_queue_t {
amw / compile.log
Created Mar 27, 2016
Swift compiler crashes on incorrect code: type defined inside protocol extension
View compile.log
swiftc -v test.swift
Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)
Target: x86_64-apple-macosx10.9
/Applications/ -frontend -c -primary-file test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -color-diagnostics -module-name test -o /var/folders/0y/7j1jzys50dx1dwrs60r_5d9r0000gn/T/test-23b3ad.o
test.swift:6:8: error: type 'Error' cannot be defined within a protocol extension
enum Error: ErrorType {case IsntOk}
test.swift:10:13: error: initializing from a metatype value must reference 'init' explicitly
throw Error.IsntOk
amw / assets.rake
Created Jan 1, 2016
Capistrano task to verify that asset digests are the same on all hosts
View assets.rake
# lib/capistrano/tasks/assets.rake
require "concurrent/hash"
# This task tests that hash digests of generated JS and CSS files are the same on every
# asset server. This should always be the case if Sprockets and Uglifier do their job
# well, but I've once had a problem with that. Once bitten, twice shy.
# We do not send compiled CSS&JS files to our asset servers, instead we're asking the
# servers to compile and minify them from source. If the process varies between servers
amw / editor.rb
Last active Jul 9, 2017
Open Vim/MacVim or other $EDITOR on each offense in RuboCop
View editor.rb
require "rubocop"
class OpenEditor < RuboCop::Formatter::ProgressFormatter
VimFamily = %w{vim gvim mvim}
def report_file file, offenses
if editor_supports_lines?
offenses.each do |offense|
amw / binary-encoding.rb
Created Jul 11, 2015
BSON::Binary error when data is non-utf8 compatible string
View binary-encoding.rb
require "bson"
require "digest/sha2"
d =
d << "test"
string = d.digest
puts string.encoding
binary = string
puts binary.to_bson
amw / assets.rake
Last active Aug 29, 2015
Preparing compressed (gzipped) Rails assets for Nginx mod_gzip_static
View assets.rake
# lib/tasks/assets.rake
namespace :assets do
ManifestPattern = /^manifest-[0-9a-f]{32}\.json$/
ExtensionsToCompress = %w{.js .css .json}.freeze
desc "GZip assets"
task :compress do
files = Pathname.glob(Rails.root.join('public/assets/**/*')).map do |file|
next unless ExtensionsToCompress
amw / Gemfile
Created Nov 5, 2012
Issues with zendesk api and multipart in rails app
View Gemfile
source ''
gem 'bundler', '~> 1.0'
gem 'railties', '~> 3.2.6'
gem 'actionmailer'
gem 'actionpack'
gem 'activeresource'
gem 'activesupport'
gem "mongoid", "~> 3.0.6"
amw / output
Created Nov 5, 2012
Uninitialized constants in zendesk API
View output
$ruby zentest.rb
W, [2012-11-05T16:32:03.672936 #15942] WARN -- : ZendeskAPI::User - find
W, [2012-11-05T16:32:03.673034 #15942] WARN -- : uninitialized constant ZendeskAPI::Middleware::Response::Gzip::Zlib
W, [2012-11-05T16:32:03.673071 #15942] WARN -- : /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/zendesk_api-0.1.10/lib/zendesk_api/middleware/response/gzip.rb:11:in `block in <class:Gzip>'
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday_middleware-0.9.0/lib/faraday_middleware/response_middleware.rb:48:in `call'
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday_middleware-0.9.0/lib/faraday_middleware/response_middleware.rb:48:in `parse'
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday_middleware-0.9.0/lib/faraday_middleware/response_middleware.rb:39:in `process_response'
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday_middleware-0.9.0/lib/faraday_middleware/response_middleware.rb:32:in `block in call'