Command Line
pry -r ./config/app_init_file.rb
- load your app into a pry session (look at the file loaded by config.ru)pry -r ./config/environment.rb
- load your rails into a pry session
Debugger
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
#!/usr/bin/env ruby | |
# Batch encodes videos from a list of editing points | |
# Author: Werner Robitza <werner.robitza@univie.ac.at> | |
FFMPEG = "ffmpeg" # => path to the FFmpeg executable | |
COPY = false # => if set to true, just does a bitstream copy | |
# => if set to false, encoding options below are used | |
OVERWRITE = "-n" # => set to "-n" if you just want to keep files that exist |
#!/usr/bin/env ruby | |
=begin | |
install Sinatra: gem install sinatra | |
install Shotgun: gem install shotgun (this auto-reloads sinatra on every http request - which means every time you make a change in your code you don't have to stop then start sinatra) | |
To just run your code using Sinatra: ruby name-of-file.rb | |
To run your code using Shotgun (which is just Sinatra but with ability to auto-reload when changes are made to files): shotgun name-of-file.rb | |
The following examples are run using Shotgun and the URL is: http://127.0.0.1:9393/ |
# Update, upgrade and install development tools: | |
apt-get update | |
apt-get -y upgrade | |
apt-get -y install build-essential git-core curl libssl-dev \ | |
libreadline6 libreadline6-dev \ | |
zlib1g zlib1g-dev \ | |
libmysqlclient-dev \ | |
libcurl4-openssl-dev \ | |
libxslt-dev libxml2-dev |
/* | |
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp | |
server, but for some reason omit a client connecting to it. I added an | |
example at the bottom. | |
Save the following server in example.js: | |
*/ | |
var net = require('net'); |
Command Line
pry -r ./config/app_init_file.rb
- load your app into a pry session (look at the file loaded by config.ru)pry -r ./config/environment.rb
- load your rails into a pry sessionDebugger
# Basic example | |
siege -t60s -c20 -d10 'http://robertomurray.co.uk/' | |
# Basic auth; | |
auth=$(echo -n 'username:password' | openssl base64) | |
siege -t60s -c20 -d10 --header="Authorization:Basic $auth" 'https://staging.a-hostname.co.uk/' |
Sinatra Flash is an awesome gem that allows you to pop up little messages alerting your users of important things, via some simple code in your server.rb
file. This is very useful for things like displaying error messages if the user has filled out a form wrong, or displaying "success" messages if the user did something successfully like sign in, sign out, or submit a form.
This also gives you a great chance to implement Foundation's beautiful alerts. Here's how to set it up!
gem install sinatra-flash
in your terminal.require 'sinatra/flash'
Install Atom on your computer (https://atom.io)
Launch Atom, go in Preferences, then chose Install, search for "remote-atom", and install it
On the distant machine:
cd ~
wget https://raw.githubusercontent.com/aurora/rmate/master/rmate
chmod +x rmate
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/ | |
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch | |
// async function | |
async function fetchAsync () { | |
// await response of fetch call | |
let response = await fetch('https://api.github.com'); | |
// only proceed once promise is resolved | |
let data = await response.json(); | |
// only proceed once second promise is resolved |