A proof of concept of having Sinatra like routes inside your controllers.
Since the router is gone, feel free to remove config/routes.rb.
Then add the file below to lib/action_controller/inline_routes.rb
inside your app.
| /* | |
| Функция для одновременной подсветки ссылок с одинаковым href, | |
| на вход принимает: | |
| 1) selector — джеквери-селектор ссылок, чтобы | |
| была возможность включить дублирующую подсветку в определённом фрагменте; | |
| 2) hoverClass — какой класс добавить по ховеру и псевдо-ховеру. | |
| Инициализация для всего документа: | |
| doubleHover('a', 'hover'); |
| apps = { | |
| 'localhost.first' => ->(env) { [200, {'Content-Type' => 'text/plain'}, ['App 1']] }, | |
| 'localhost.second' => ->(env) { [200, {'Content-Type' => 'text/plain'}, ['App 2']] } | |
| } | |
| run ->(env) do | |
| request = Rack::Request.new(env) | |
| if app = apps[request.host] | |
| app.call(env) |
| # Simple approach to sending email from the Rails console | |
| # Implementation idea courtesy of Steve Klabnik | |
| # http://blog.steveklabnik.com/posts/2012-09-09-random-ruby-tricks--class-new | |
| # Create the mailer class with a block and assign to a variable | |
| mailer = Class.new(ActionMailer::Base) do | |
| def example_message | |
| mail(to: "test@test.com", from: "test@test.com", subject: "Example Message") do |format| | |
| format.text { render text: "Example message body" } | |
| end |
| # A sample Gemfile | |
| source "https://rubygems.org" | |
| gem 'mechanize' |
Howdy howdy, NSHipsters!
If you alloc init an NSCalendar, you'll notice that New Year's Eve falls on a Monday this year, a.k.a. "the day NSHipster is published every week". What fun!
So in celebration of the upcoming year++, I thought it'd be fun to compile a list of some of your favorite tips and tricks of the trade. Submit your favorite piece of Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!
Here are a few examples of the kind of things I'd like to see:
| #define EMKStringableEnum(ENUM_NAME, ENUM_VALUES...) \ | |
| \ | |
| typedef enum { \ | |
| ENUM_VALUES \ | |
| } ENUM_NAME; \ | |
| \ | |
| \ | |
| \ | |
| static NSString * ENUM_NAME##ToString(int enumValue) { \ | |
| static NSString *enumDescription = @"" #ENUM_VALUES; \ |
| #! /usr/bin/env bash | |
| # Target and build configuration. | |
| TARGET=arm-none-eabi | |
| PREFIX=/opt/arm-none-eabi-4.7.1 | |
| # Sources to build from. | |
| BINUTILS=binutils-2.23.1 | |
| GCC=gcc-4.7.1 | |
| NEWLIB=newlib-1.20.0 |
| #define USE_ROBIN_HOOD_HASH 1 | |
| #define USE_SEPARATE_HASH_ARRAY 1 | |
| template<class Key, class Value> | |
| class hash_table | |
| { | |
| static const int INITIAL_SIZE = 256; | |
| static const int LOAD_FACTOR_PERCENT = 90; | |
| struct elem |