Le Wagon Beirut; Dec 17, 2014; Abdo Achkar
We'll follow a "What, How, DIY, Fix" (WHDF) methodology throughout the workshop:
- We'll show the feature we'll be building
- How to build it
- You then do it yourself
| # select_from_hash location_size | |
| def select_from_hash(object, name, args, options={}) | |
| selected = [] | |
| include_blank = false | |
| if (!options[:selected].nil?) | |
| selected = options[:selected] | |
| end | |
| module IRB | |
| class Irb | |
| MAX_LEN = 10000 | |
| def output_value | |
| if (@context.inspect_last_value.length > MAX_LEN) | |
| printf @context.return_format, "#{@context.inspect_last_value[0..MAX_LEN]} <- Truncated" | |
| else | |
| printf @context.return_format, @context.inspect_last_value | |
| end | 
| <%= link_to_function "Add Number" do |page| | |
| partial = escape_javascript( render PhoneNumber.new, { :phone_types => PhoneNumbersHelper::phone_types, :name => "location[numbers][]" } ) | |
| page << "$('#phone_numbers .rightside .phonenumbers').append(\"#{partial}\")" | |
| end %> | 
| class Geolocation < ActiveRecord::Base | |
| belongs_to :geotaggable, :polymorphic => true | |
| end | |
| class Location < ActiveRecord::Base | |
| has_many :geolocations, :as => :geotaggable, :dependent => :destroy | |
| end | |
| irb(main):045:0> Location.first.geolocations | |
| ←[1m←[36mLocation Load (1.0ms)←[0m ←[1mSELECT `locations`.* FROM `locations` | 
| require 'socket' # Get sockets from stdlib | |
| filename = "file.txt" | |
| port = 80 | |
| server = TCPServer.open(port) #open socket for listening | |
| loop { # Servers run forever | |
| client = server.accept # Wait for a client to connect | |
| file = File.new(filename, "r") | 
| user::rwx | |
| group::rwx | |
| other::r-- | |
| default:user::rwx | |
| default:group::rwx | |
| default:group:root:rwx | |
| default:mask::rwx | |
| default:other::r-- | 
| set nocompatible | |
| filetype off | |
| " set runtime path to include vundle and initialize | |
| set rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| " Let Vundle manage Vundle | 
| let mapleader="\<Space>" | |
| set number | |
| " easymotion works with <leader><leader>s | |
| " lines below allow yanking to be shared with system clipboard | |
| set clipboard^=unnamed | |
| set clipboard^=unnamedplus | |
| set wrapscan | 
| set nocompatible | |
| filetype off | |
| " set runtime path to include vundle and initialize | |
| set rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| " Let Vundle manage Vundle |