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.
# Examples: | |
# client = FGraph.new("USERNAME") | |
# | |
# if you need see response details use: | |
# client.request # returns a Net::HTTPFound instance, with this you can see the status, headers# Examples: | |
# client = FGraph.new("USERNAME") | |
# | |
# client.data # returns the parsed response body | |
# if you need an alias to get the api data response, use: |
# Generate a module which imports a given subset of module methods | |
# into the including module or class. | |
def Methods(source_module, *method_names) | |
all_methods = source_module.instance_methods + | |
source_module.private_instance_methods | |
unwanted_methods = all_methods - method_names | |
import_module = source_module.clone | |
import_module.module_eval do | |
define_singleton_method(:to_s) do | |
"ImportedMethods(#{source_module}: #{method_names.join(', ')})" |
(function() { | |
var script, | |
scripts = document.getElementsByTagName('script')[0]; | |
function load(url) { | |
script = document.createElement('script'); | |
script.async = true; | |
script.src = url; | |
scripts.parentNode.insertBefore(script, scripts); |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
I had some headaches yesterday while trying to upgrade to VMWare Fusion with Vagrant.
The steps that work are:
#!/usr/bin/ruby | |
# Create display override file to force Mac OS X to use RGB mode for Display | |
# see http://embdev.net/topic/284710 | |
require 'base64' | |
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay` | |
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten | |
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten |
sysctl -w fs.file-max=12000500 | |
sysctl -w fs.nr_open=20000500 | |
ulimit -n 4000000 | |
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000' | |
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384' | |
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384' | |
sysctl -w net.core.rmem_max=16384 | |
sysctl -w net.core.wmem_max=16384 | |
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb | |
sudo dpkg -i erlang-solutions_1.0_all.deb |
echo 'require "objspace"; ObjectSpace.trace_object_allocations_start; Kernel.send(:define_method, :sup) do |obj| ; puts "#{ ObjectSpace.allocation_sourcefile(obj) }:#{ ObjectSpace.allocation_sourceline(obj) }"; end' > tmp/tmp-gemfile | |
cat Gemfile >> tmp/tmp-gemfile | |
cat tmp/tmp-gemfile > Gemfile | |
# $ bundle exec irb | |
# irb(main):001:0> require 'rails' | |
# => true | |
# irb(main):002:0> sup(Rails) | |
# /Users/richardschneeman/.gem/ruby/2.4.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:3 |
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :development
Then you'll want to rebuild your Docker container to install the gems