This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| # from the cache for up to 1 hour. | |
| # 2. Varnish will pass X-Forwarded-For headers through to the backend | |
| # 3. Varnish will remove cookies from urls that match static content file | |
| # extensions (jpg, gif, ...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'carrierwave/processing/mini_magick' | |
| class ImageUploader < CarrierWave::Uploader::Base | |
| include CarrierWave::MiniMagick | |
| IMAGE_EXTENSIONS = %w(jpg jpeg gif png) | |
| DOCUMENT_EXTENSIONS = %w(exe pdf doc docm xls) | |
| def store_dir | |
| "files/#{model.id}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/ftp' | |
| CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk" | |
| CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login" | |
| CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password" | |
| # LOGIN and LIST available files at default home directory | |
| Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp| | |
| files = ftp.list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Based on https://gist.github.com/1205828, in turn based on https://gist.github.com/1182136 | |
| class BootstrapLinkRenderer < ::WillPaginate::ActionView::LinkRenderer | |
| protected | |
| def html_container(html) | |
| tag :div, tag(:ul, html), container_attributes | |
| end | |
| def page_number(page) | |
| tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Using CoreLocation on Mac OS X with command-line | |
| // $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation | |
| // $ ./a.out | |
| // location service enabled | |
| // 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538 | |
| // 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900 | |
| // tmiz moo@tmiz.net | |
| // | |
| #import <cocoa/cocoa.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifdef _MSC_VER | |
| #include <boost/config/compiler/visualc.hpp> | |
| #endif | |
| #include <boost/property_tree/ptree.hpp> | |
| #include <boost/property_tree/json_parser.hpp> | |
| #include <boost/foreach.hpp> | |
| #include <cassert> | |
| #include <exception> | |
| #include <iostream> | |
| #include <sstream> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'fog' | |
| require 'carrierwave' | |
| require 'tempfile' | |
| Fog.mock! | |
| fog_credentials = { | |
| :provider => 'AWS', | |
| :aws_access_key_id => 'a', | |
| :aws_secret_access_key => 'b' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core? | |
| L.TileLayer.Common = L.TileLayer.extend({ | |
| initialize: function (options) { | |
| L.TileLayer.prototype.initialize.call(this, this.url, options); | |
| } | |
| }); | |
| (function () { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is the code from my 'There is No Such Thing as Metaprogramming' talk, | |
| # which premiered at the Arlington, VA Ruby Users Group on Feb 22nd. | |
| # Without the deliver and walk-through to the solution below this example | |
| # will be missing quite an important bit of content (mainly the tracking of | |
| # 'self' while developing the solution, but it still a useful read. | |
| # Here is the Toddler with no metajuju. Note that the developer, as well as | |
| # the code, is completely unuaware of the interpreter. A developer with a | |
| # background in compiled languages would be comfortable looking at this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Just wanted to clarify my points at the meetup last night. | |
| # | |
| # There were two different issues intertwined: | |
| # (1) Whether to use extend or "include as extend" | |
| # (2) When using "include as extend", what is the simplest way to achieve the goal? | |
| # | |
| # My personal opinion is that the answer to (1) is "extend", not "include as extend", but that | |
| # is just my personal opinion. My answer to (2) is a more empirical question. | |
| # Using the "extend" approach. Again, I personally prefer the simplicity of this approach, but |