Set up VirtualBox with an Ubuntu virtual machine:
- Sugested: RAM:2048MB, Storage:20GB
Create and mount a /dev
folder from your Mac (Host) to the Ubuntu VM (Guest).
- Set it to Auto-mount and Make Permanent. You can find instructions here.
# Open terminal and type. | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="small-spacer-tile";}';killall Dock |
awk '/word1/&&/word2/&&/word3/&&/word4/' file |
Set up VirtualBox with an Ubuntu virtual machine:
Create and mount a /dev
folder from your Mac (Host) to the Ubuntu VM (Guest).
# tested ruby 1.8 | |
class Spinner | |
include Enumerable | |
def each | |
loop do | |
yield '|' | |
yield '/' | |
yield '-' | |
yield '\\' |
grep 'query' testing.log -B 5 -A 5 | less |
class MyLog | |
def self.debug(message=nil) | |
@my_log ||= Logger.new("#{Rails.root}/log/my.log") | |
@my_log.debug(message) unless message.nil? | |
end | |
end |
Here's a useful one - If you ever need to check the methods of a ruby class/module (e.g. Math or User) you can call public_methods
to get the class methods and public_instance_methods
to get the instance ones.
The problem with this is that you'll also get entries for everything that it inherits from too, all the way up to Object methods like is_a?
and send
To get around that, because they return arrays, you can subtract the result from calling it on the base class, e.g. Math.public_methods - Module.public_methods
, or User.instance_methods - ActiveRecord::Base.instance_methods
require 'benchmark' | |
n = (10**6) | |
Benchmark.bm(7) do |x| | |
x.report("1:") do | |
1.upto(n) do | |
#code | |
end |
GET: | |
with JSON: | |
curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://hostname/resource | |
as XML: | |
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET http://hostname/resource | |
curl -H "Accept: application/xml" "http://localhost:3040/api/org.xml" | |
curl -H "Accept: application/xml" -H "API_KEY: fgjfgjhfj68rvuIXy5XAlpRELmHKmOZNJeot62I3rePsnFAl15Wghjgs" "http://localhost:3040/api/org" |
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH=/Users/marcoaraujo/.oh-my-zsh | |
# Set name of the theme to load. Optionally, if you set this to "random" | |
# it'll load a random theme each time that oh-my-zsh is loaded. | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
# ZSH_THEME="robbyrussell" |