code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module UsersHelper end
Ruby
module ProjectsHelper end
Ruby
module DashboardHelper end
Ruby
class User < ActiveRecord::Base validates_presence_of :username validates_presence_of :full_name validates_presence_of :email validates_uniqueness_of :username validates_as_email :email validates_confirmation_of :password end
Ruby
class Project < ActiveRecord::Base NAME_ERROR = 'You must specify a valid project name.' KEY_ERROR = 'You must specify a unique project key, at least 2 characters long, containing only uppercase letters.' validates_presence_of :name, :message => NAME_ERROR validates_presence_of :key, :message => KEY_ERR...
Ruby
class ProjectsController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @proj...
Ruby
class DashboardController < ApplicationController end
Ruby
class UsersController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @user_pa...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_xira_sessi...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION ...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
class Repository extend ElMixin CODE_SAMPLES = %q< # Show options for the repository - Show options: Repository.menu > def self.svn_command command, dir=nil dir ||= View.dir #dir ||= "tr" switch_to_buffer generate_new_buffer("*svn command") elvar.default_directory = Bookmarks.expand(di...
Ruby
require 'rubygems' gem 'net-ssh' require 'net/ssh' require 'net/sftp' require 'timeout' class Remote extend ElMixin @@connections = {} @@default_dirs ||= [] def self.menu @@default_dirs.each do |d| puts ".dir '#{d}'" end puts ".dir 'user@foo.com:22/tmp'" end # default_dirs attr def s...
Ruby
class Files extend ElMixin # Lets user open a file def self.open if elvar.current_prefix_arg find_file Keys.input(:prompt => "Open file: ") else find_file read_file_name("Open: ") end end # def self.save # If prefix, save as if elvar.current_prefix_arg write_file read_f...
Ruby
require 'line' class CodeTree extend ElMixin CODE_SAMPLES = " # Menus for all CodeTree classes The menus serve as User Interfaces for the classes. - show menus: CodeTree.menu " # Mapped to C-. def self.launch options={} orig = Location.new Line.to_left line = Line.without_indent ...
Ruby
class Line extend ElMixin CODE_SAMPLES = %q< # Moving - up: Line.previous - down: Line.next # Getting text - line text: p Line.value - indent: p Line.indent - without indent: p Line.without_indent - label: p Line.label - without label: p Line.without_label # Getting Po...
Ruby
class Rails extend ElMixin CODE_SAMPLES = %q< # Show options to help create new rails app - Show options: Rails.menu > def self.menu name=nil, port=nil unless name # Print menu puts "- name, port: foo, 3000" else # Print options puts " - .create - .start -...
Ruby
require 'block' require 'stringio' class Code extend ElMixin CODE_SAMPLES = %q< # Eval code - get output and stdout: p Code.eval("puts 'printed'; 1 + 2") > def self.location_from_id id path = ObjectSpace._id2ref(id).to_s path =~ /@(.+):([0-9]+)/ file, line = $1, $2 [file, line] end ...
Ruby
require 'net/http' require 'uri' require 'timeout' require 'keys' class Redmine extend ElMixin @@url ||= 'http://foo.com:80/wiki/1' def self.url= to; @@url = to; end def self.url; @@url; end def self.menu puts " - .pages - .start - local: http://localhost:3401/wiki/gateway -...
Ruby
class Hide extend ElMixin @@visible = {} # include ElMixin # (hide-find-overlays) # self.reset def self.hide_unless search, options={} self.hide_unless_block(options) do |l, bol, eol| l =~ search end end def self.visible @@visible end def self.already_hidden @@already_hidden ...
Ruby
module AutoMenu CODE_SAMPLES = %q< # Let the Foo CodeTree class define multi-level menus with one method class Foo extend AutoMenu def self.auto_menu item=nil "- .reminders - .backup - .backup_code() ".gsub(/^ /, '') end - This will now retur...
Ruby
require "location" require "view" class App # extend KeyMappableMixin ## TODO - delete this include ElMixin extend ElMixin def self.open path Location.go path end def self.line line_number_at_pos end def self.enter_directory insert read_directory_name("Directory to insert: ", "/") end ...
Ruby
class Shell extend ElMixin CODE_SAMPLES = %q[ # Run OS commands - in shell (asynchronously): Shell.run("ls", :dir => "/tmp") - Synchronously: Shell.run("ls", :dir => "/etc", :sync => true) ] # Run the command in a shell def self.run command, options={} #dir=nil, sync=nil, buffer_name=nil ...
Ruby
require 'styles' require 'line' require 'effects' require 'view' require 'keys' require 'clipboard' class Notes extend ElMixin def self.menu puts ".help_wiki_format" end def self.block regex="^| " left, after_header, right = View.block_positions regex buffer_substring(after_header, right) end ...
Ruby
# Helps you switch between files, in a way very similar to how Ctrl-tab # switches between windows in most operating systems. Call #keys # to map it to Ctrl-tab in emacs. class ControlTab extend ElMixin @@edited = nil # @@switch_index = 0 # Primary method. Is mapped to C-tab and does the switching. def se...
Ruby
require 'view' # Saves and restores locations. A location can include multiple of # these: a file, a line number, a column number class Location extend ElMixin include ElMixin #@@hash = {} # Save file and location def initialize *args # Just use file if it's passed if args[0] && args[0].class == S...
Ruby
# Todo # - switch_to_buffer generate_new_buffer(buffer_name) # - generate-new-buffer-name # - Function to switch to buffer if open already # switch-to-buffer-other-window # switch-to-buffer-other-window-maybe # Represents a division of a window (in emacs terms, it's a window (which is within a frame)) class View in...
Ruby
require 'line' class TextUtil def self.unindent txt # Delete initial blank line if there txt.sub!(/^\n/, '') # Untab indent txt.gsub!(/^\s+/) { |t| t.gsub("\t", ' ') } # If 1st line has no indent and 2nd line has indent (at least 3 spaces) if txt !~ /\A / and txt =~ /\A.+\n( +)/ ...
Ruby
# Remember something you're searching for, and jump to the next occurrences. CODE_SAMPLES = %q< - Deprecated: > class SearchTerm extend ElMixin @@last_dash_search = "" def self.keys define_key :isearch_mode_map, kbd("C--") do # During isearch, remember current search term isearch_done is...
Ruby
require 'keys' # Provides different ways of moving cursor. class Move extend ElMixin # Go to last line having indent def self.to_indent indent = Keys.prefix # If no prefix, go down to same indent as this one if Keys.prefix_u || Line.matches(/^ *(end|\]|\}|\))$/) return self.to_same_indent(:up)...
Ruby
class Docs end
Ruby
require 'view' class Merb # extend AutoMenu def self.menu name=nil, port=nil unless name # Print menu puts " - name, port: ., 4000 - .links/ - .snippets " else # Print options puts " - .create - .start - .url '/' - .shells/ ...
Ruby
require 'keys' class PauseMeansSpace extend ElMixin def self.go while(inserted = insert_until_pause) next if inserted == 127 if inserted == "." delete_backward_char 2; insert ". " next end insert " " end delete_backward_char 1 message "Typing finished" ...
Ruby
require 'pause_means_space' # Convenient way to define keyboard shortcuts class Keys #extend ElMixin @@key_queue =[] # For defining menus (must be done in reverse) CODE_SAMPLES = %q< # Map C-c C-a Keys.CA { View.insert "foo" } # Map M-x (in shell mode) Keys._X(:shell_mode_map) { View.insert "...
Ruby
# Starting and stopping macros class Macros # include ElMixin extend ElMixin def self.record # If ending a macro if elvar.defining_kbd_macro end_kbd_macro nil # If starting a macro else start_kbd_macro nil end end def self.run # If defining a macro, just end it and run it ...
Ruby
class Elvar def method_missing(func, *args, &block) print "<blocked>" end end module ElMixin def elvar Elvar.new end def method_missing(func, *args, &block) print "<blocked>" end end
Ruby
require 'notes' require 'text_util' require 'app' require 'bookmarks' require 'clipboard' require 'code' require 'color' require 'control_tab' require 'deletes' require 'diff_log' require 'files' require 'history' require 'keys' require 'macros' require 'move' require 'search' require 'tree_ls' require 'repository' req...
Ruby
require 'hide' # Will store a diff each time a file is saved. class DiffLog extend ElMixin @@log = File.expand_path("~/.emacs.d/difflog.notes") @@temp_path = elvar.temporary_file_directory + "latest-diff.txt" # Open file having difflog def self.open # If open, just switch to it and revert if View.b...
Ruby
require 'rubygems' gem 'net-ssh' require 'net/ssh' # Wraps around a local or remote irb or merb (and probably rails) # console, passing commands to it and returning their stdout output. class RubyConsole @@output = "" def self.output; @@output; end @session = @channel = nil CODE_SAMPLES = %q< # Send s...
Ruby
class Mysql def self.menu puts " - foo - .create_db - .drop_db " end def self.create_db name Shell.run "mysqladmin -u root create #{name}", :buffer => "create #{name}" end def self.drop_db name Shell.run "mysqladmin -u root drop #{name}", :buffer => "drop #{name}" e...
Ruby
class History extend ElMixin def self.prefix_times prefix = Keys.prefix prefix ||= 20 prefix = 20 if prefix == :u prefix end def self.open_current options={} if options[:prompt_for_bookmark] bm = Keys.input(:timed => true, :prompt => "Enter bookmark to show outline for: ") path...
Ruby
class Environment extend ElMixin def self.linux? elvar.system_type.to_s[/linux/] end end
Ruby
class Block extend ElMixin def self.value res = [] with(:save_excursion) do found = re_search_backward "^ *$", nil, 1 if found end_of_line forward_char end res << point re_search_forward "^ *$", nil, 1 beginning_of_line res << point end end end...
Ruby
require "hide" class Search extend ElMixin def self.insert_at_spot self.clear match = self.match #hidesearch_show_all_invisible Hide.show Location.go :_0 #bookmark_jump "_" insert match end def self.insert_tree_at_spot self.clear # Grab symbol txt = TreeLs.snippet() ...
Ruby
require 'auto_menu' class Help CODE_SAMPLES = %q< # Show docs - Code samples: Docs.display > def self.menu puts " - .keys/ - .docs - .classes/ " end def self.keys type=nil, prefix=nil, command=nil unless type # No type, so display list puts " - all/ ...
Ruby
require 'line' require 'effects' require 'ruby_console' class LineLauncher extend ElMixin @@just_show = false @@launchers = [] @@launchers_regexes = {} def self.launchers; @@launchers; end @@paren_launches = {} def self.add_paren match, &block @@paren_launches[match] = block end def self.add ...
Ruby
class Ruby def self.menu puts " - .list_classes - .re_index_fast_ri " end def self.list_classes clazz=nil, method=nil unless clazz # Show list of classes ObjectSpace.each_object(Class) do |c| puts c end return end unless method # Show list of met...
Ruby
require 'styles' require 'line' require 'view' require 'net/http' require 'uri' require 'cursor' # Draws a tree from a dir structure and lets you incrementally search in the tree. # Usage (user): # - Type C-x C-t # - A tree will be drawn in a new buffer # - Representing the directory structure in the curre...
Ruby
class Buffers def self.menu buffer=nil #return $el.ml buffer if buffer == nil # If no buffer, show list $el.buffer_list.map { |b| $el.buffer_name(b) }.to_a.each do |b| #name = $el.buffer_name(b) puts "- #{b}" end return end # Switch to buffer View.to_after_bar if V...
Ruby
class Styles extend ElMixin CODE_SAMPLES = %q[ # Define Styles.define :red, :bg => "d77" # Define more complex font Styles.define :ls_dir, :fg => "99e", :face => "verdana", :size => 90, :bold => true # Apply Styles.apply "apply", :red ] def self.define name, o...
Ruby
require 'auto_menu' class DataMapper extend AutoMenu def self.auto_menu puts " - .docs_links/ - index: http://datamapper.org/docs/ - finding: http://datamapper.org/docs/find.html - saving: http://datamapper.org/docs/create_and_destroy.html - api: http://datamapper.rubyfor...
Ruby
require 'location' require 'keys' class Bookmarks extend ElMixin CODE_SAMPLES = %q< # Get path for bookmark p Bookmarks["$t"] # Bookmark name is 't' # Expand bookmark shortcut in a path p Bookmarks["$tm/hi.txt"] > def self.save arg=nil # If arg is a symbol, use it as the prefix pref...
Ruby
class Links def self.open_first url = View.txt[/http:\/\/.+/] $el.browse_url url end end
Ruby
require 'strscan' require 'hide' require 'keys' # Currently not used class Xiki extend ElMixin @@default_server = "localhost:11111" # @@default_server = "xiki.org" # @@default_server = "http://#{@@default_server_root}" @@xiki_dir = File.expand_path("~/.xiki") @@original_dir = "#{@@xiki_dir}/orig" @@hook_en...
Ruby
require 'keys' require 'tree_ls' # Provides copy and paste functionality class Clipboard extend ElMixin # Stores things user copies @@hash = {} def self.copy loc=nil # Use string if user types it quickly loc ||= Keys.input(:one_char => true, :prompt => "Enter one char (to store this as): ") || "0" ...
Ruby
require 'effects' require 'styles' # Colors lines, and shows only colored lines class Color extend ElMixin CODE_SAMPLES = %q< # Make current line be a color - red: Color.colorize :r - blue: Color.colorize :b - yellow: Color.colorize :y > @@colors = { "r" => :color_rb_red, "o" => :color_rb...
Ruby
class Cursor @@remember = {} CODE_SAMPLES = %q[ # Colors - orange: Cursor.color "#ff9900" - Cursor.red - Cursor.green - Cursor.blue - Cursor.black # Shapes - Cursor.bar - Cursor.underscore - Cursor.hollow - Cursor.box # Colors and Shapes - Cursor.red_bar -...
Ruby
class Computer def self.menu puts "- .ip/" end def self.ip puts `ifconfig`.grep(/\binet\b/) end end
Ruby
class Irc extend AutoMenu def self.auto_menu puts " - .logon - room (o): /j merb - identify (o): /m nickserv IDENTIFY #{self.pw} " end def self.logon View.handle_bar $el.el4r_lisp_eval "(erc :server \"irc.freenode.net\" :nick \"#{@@username}\")" end def self.username= to...
Ruby
require 'styles' # Makes visual things happen class Effects extend ElMixin CODE_SAMPLES = %q[ # Blink - whole file: Effects.blink :what => :all ] # Sample usages: def self.blink options={} what = options[:what] what ||= :line case what when :all left, right = View.top, View.bo...
Ruby
class String def unindent TextUtil.unindent(to_s) end end
Ruby
require 'net/http' class Svn extend ElMixin def self.menu action=nil, *path if action == "list" orig = View.window View.to_after_bar out = shell_command_to_string("svn list") View.to_window orig puts out.gsub(/^/, '- ') return end puts "- list" end def self.co...
Ruby
class Schedule def self.menu puts "$td" txt = nil $el.with(:save_window_excursion) do View.open("$td") txt = View.txt end puts txt.grep(/^\| e /).join("").gsub(/^/, ' ') end end
Ruby
class Menu def self.add_menu name lisp = %Q< (define-key global-map [menu-bar #{name.downcase}] (cons "#{name}" (make-sparse-keymap "#{name}"))) > #puts lisp $el.el4r_lisp_eval lisp menu = $el.elvar.menu_bar_final_items.to_a $el.elvar.menu_bar_final_items = menu.push(name.downc...
Ruby
require 'net/http' require 'timeout' class Twitter extend ElMixin CODE_SAMPLES = %q< # C-. on this - Twitter.menu > def self.post_or_list if Keys.prefix_u # If U prefix, just list shell_command("twitter timeline") else # Otherwise, post self.post end end def self.list o...
Ruby
class Deletes extend ElMixin def self.delete_whitespace # If at end of line, delete 1 char forward if point == Line.right and ! Line.blank? delete_char 1 forward_char end # If nothing on line, delete blank lines if buffer_substring(point_at_bol, point_at_eol)[/^[\t ]*$/] delet...
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
Ruby
ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all # Add more helper methods to be used by all tests here... end
Ruby
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.5' # Use sqlite3 as the database for Active Record #gem 'sqlite3' gem 'mysql2' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= ...
Ruby