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.
| # This script just get the latest tracks of your friends on Last.fm and recommends those more popular. | |
| # It's all based on a conversation between @mort, @rochgs, @littlemove and me (mainly by @mort) | |
| # INSTRUCTIONS | |
| # 1. Install lastfm gem: https://github.com/youpy/ruby-lastfm/ | |
| # gem install lastfm | |
| # 2. Get a Last.fm API Key on http://www.lastfm.es/api | |
| require 'lastfm' |
| # ======================================================= | |
| # Importing and searching RSS with ElasticSearch and Tire | |
| # ======================================================= | |
| # | |
| # This script downloads, parses and indexes Stackoverflow RSS feed with ElasticSearch | |
| # via the [Tire](https://github.com/karmi/tire) Rubygem. | |
| # | |
| # Requirements | |
| # ------------ | |
| # |
| # Activate in a modular Sinatra app: | |
| # | |
| # register Sinatra::Memcacher | |
| # set :memcacher_enabled, true | |
| # set :memcacher_expiry, 86400 | |
| # Cache an action: | |
| # | |
| # get '/' do | |
| # cache "index" do |
| #!/bin/bash | |
| # cpustatus | |
| # | |
| # Prints the current state of the CPU like temperature, voltage and speed. | |
| # The temperature is reported in degrees Celsius (C) while | |
| # the CPU speed is calculated in megahertz (MHz). | |
| function convert_to_MHz { | |
| let value=$1/1000 | |
| echo "$value" |
| #! /bin/bash | |
| sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF | |
| DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]') | |
| CODENAME=$(lsb_release -cs) | |
| echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main" | sudo tee /etc/apt/sources.list.d/mesosphere.list | |
| sudo apt-get -y update --fix-missing | |
| sudo apt-get -y install mesosphere |
| require 'continuation' | |
| # | |
| # Messing around with mimicking Scheme in Ruby by implementing the Yin/Yang puzzle with Kernel#callcc and a fake 'let' macro | |
| # | |
| # See also: | |
| # http://blog.gonzih.me/blog/2013/11/26/yin-yang-callcc-puzzle-in-ruby/, | |
| # http://stackoverflow.com/questions/16843853/how-to-implement-let-in-scheme | |
| # | |
| # In Scheme (the original) |
| #/usr/bin/env bash | |
| # MIT © Sindre Sorhus - sindresorhus.com | |
| # git hook to run a command after `git pull` if a specified file was changed | |
| # Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. | |
| changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
| check_run() { | |
| echo "$changed_files" | grep --quiet "$1" && eval "$2" |