code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require 'rubygems'
require 'xmpp4r/client'
require 'xmpp4r/roster'
require 'xmpp4r/version'
Jabber::debug = true
class Annei
def connect
begin
jid = Jabber::JID::new('example@example.org/Bot')
password = ''
@connection = Jabber::Client::new(jid,true)
@connection.on_exception { conn... | Ruby |
#!/usr/bin/env ruby
# Save your fork, there's cake!"
require 'find'
require 'open-uri'
require 'socket'
require 'fileutils'
require 'io/wait'
require 'pp'
if RUBY_PLATFORM =~ /(mingw|mswin)(32|64)$/
begin
require 'rubygems' rescue nil
require 'win32/process'
rescue LoadError
puts 'cake requires win32/p... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | 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 |
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 |
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 |
#!/usr/bin/ruby
# jsmin.rb 2007-07-20
# Author: Uladzislau Latynski
# This work is a translation from C to Ruby of jsmin.c published by
# Douglas Crockford. Permission is hereby granted to use the Ruby
# version under the same conditions as the jsmin.c on which it is
# based.
#
# /* jsmin.c
# 2003-04-21
#
# Copyrig... | Ruby |
#!/usr/bin/ruby
# jsmin.rb 2007-07-20
# Author: Uladzislau Latynski
# This work is a translation from C to Ruby of jsmin.c published by
# Douglas Crockford. Permission is hereby granted to use the Ruby
# version under the same conditions as the jsmin.c on which it is
# based.
#
# /* jsmin.c
# 2003-04-21
#
# Copyrig... | Ruby |
# Copyright 2009 Waag Society <http://www.waag.org>
# This file is part of Annotrax.
#
# Annotrax is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or (at your option) any late... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
# Compass configurations
sass_path = File.dirname(__FILE__)
css_path = File.join(sass_path, "..", "css")
# Require any additional compass plugins here.
images_dir = File.join(sass_path, "..", "img")
output_style = :expanded
environment = :production | Ruby |
# $ext_path: This should be the path of where the ExtJS SDK is installed
# Generally this will be in a lib/extjs folder in your applications root
# <root>/lib/extjs
$ext_path = "../../"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a resource... | Ruby |
# include the utils rb file which has extra functionality for the ext theme
dir = File.dirname(__FILE__)
require File.join(dir, 'lib', 'utils.rb')
# register ext4 as a compass framework
Compass::Frameworks.register 'ext4', dir | Ruby |
# $ext_path: This should be the path of the Ext JS SDK relative to this file
$ext_path = "../../extjs"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a resources/sass folder
# <root>/resources/sass
sass_path = File.dirname(__FILE__)
# css_pat... | Ruby |
# Compass configurations
sass_path = File.dirname(__FILE__)
css_path = File.join(sass_path, "..", "css")
# Require any additional compass plugins here.
images_dir = File.join(sass_path, "..", "img")
output_style = :expanded
environment = :production | Ruby |
module ExtJS4
module SassExtensions
module Functions
module Utils
def parsebox(list, n)
assert_type n, :Number
if !n.int?
raise ArgumentError.new("List index #{n} must be an integer")
elsif n.to_i < 1
raise ArgumentError.new("List index #{n} must... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | 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 |
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 |
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 |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string
t.column :email, :string
t.column :crypted_password, :string, :limit => 40
t.column :salt, :str... | Ruby |
class AddColumnLastPublishedAtToFeed < ActiveRecord::Migration
def self.up
add_column :feeds, :last_published_at, :datetime
end
def self.down
remove_column :feeds, :last_published_at
end
end
| Ruby |
class AddColumndFeedsTagRegexp < ActiveRecord::Migration
def self.up
add_column :feeds, :tag_regexp, :string
end
def self.down
remove_column :feeds, :tag_regexp
end
end
| Ruby |
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.integer :post_id
t.datetime :date
end
end
def self.down
drop_table :events
end
end
| Ruby |
class CreateFulltextRows < ActiveRecord::Migration
def self.up
create_table :fulltext_rows, :options => 'ENGINE=MyISAM' do |t|
t.column :fulltextable_type, :string, :null => false, :limit => 50
t.column :fulltextable_id, :integer, :null => false
t.column :value, :text, :null... | Ruby |
class CreateGeotagsPosts < ActiveRecord::Migration
def self.up
create_table :geotags_posts, :id => false do |t|
t.integer :post_id
t.integer :geotag_id
end
end
def self.down
drop_table :geotags_posts
end
end
| Ruby |
class CreateGeotags < ActiveRecord::Migration
def self.up
create_table :geotags do |t|
t.string :name, :null => false
t.decimal :longitude, :precision => 10, :scale => 6, :null => false
t.decimal :latitude, :precision => 10, :scale => 6, :null => false
t.timestamps
end
add_ind... | Ruby |
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.column :feed_id, :integer
t.column :url, :string
t.column :guid, :string
t.column :title, :string
t.column :description, :text
t.column :body, :text
t.column :published_at, :datetime
... | Ruby |
class CreateFeeds < ActiveRecord::Migration
def self.up
create_table :feeds do |t|
t.column :url, :string, :null => false
t.column :invalid, :boolean, :default => false, :null => false
t.column :title, :string
t.column :link, :string, :limit => 500
t.column :created_at, :datetime
... | Ruby |
class AddTagSupport < ActiveRecord::Migration
def self.up
#Table for your Tags
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
#id of tagged object
t.column :taggable_id, :integer
#type of object tagged
... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
#!c:/ruby/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired... | Ruby |
#!c:/ruby/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
#... | Ruby |
#!c:/ruby/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired... | Ruby |
#!c:/ruby/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired... | Ruby |
#!c:/ruby/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
#... | Ruby |
#!c:/ruby/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/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/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| 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/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| 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/console'
| Ruby |
#!/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/request'
| 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/performance/request'
| 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
def tag_cloud(tags, classes)
max, min = 0, 0
tags.each { |t|
count = t.taggings.count
max = count if count > max
min = count if count < min
}
divisor = ((max - min) / classes.size) + 1
... | Ruby |
module FeedsHelper
end
| Ruby |
module TimelineHelper
end
| Ruby |
module SettingsHelper
end
| Ruby |
module AccountHelper
end | Ruby |
module AdminHelper
end
| Ruby |
module PostsHelper
end
| Ruby |
module TagsHelper
end
| Ruby |
module MapHelper
end
| Ruby |
class Geotag < ActiveRecord::Base
has_and_belongs_to_many :posts
def self.find_or_create(name)
tag = self.find_by_name(name)
if tag.nil?
results = Geocoding::get(name)
if results.status == Geocoding::GEO_SUCCESS
tag = Geotag.new :name => name, :longitude => results[0].longitude,... | Ruby |
class Event < ActiveRecord::Base
belongs_to :post
validates_uniqueness_of :date, :scope => :post_id
end
| Ruby |
class Post < ActiveRecord::Base
acts_as_taggable
has_many :events
has_and_belongs_to_many :geotags
acts_as_fulltextable [:title, :description, :body]
def has_events?
events.count > 0
end
def duration?
events.count > 1
end
def process
#find tags
tags = body.scan(/\A[а-яА-я\s,]*/)[... | Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
# Virtual attribute for the unencrypted password
attr_accessor :password
validates_presence_of :login, :email
validates_presence_of :password, :if => :password_required?
validates_presence_of :password_confirmation, :if ... | Ruby |
# == Schema Information
# Schema version: 4
#
# Table name: feeds
#
# id :integer(11) not null, primary key
# url :string(255) default(""), not null
# invalid :boolean(1) not null
# title :string(255)
# link :string(255)
# created_at :datetime
... | Ruby |
class PostsController < ApplicationController
before_filter :tag_clouds, :only => [:index, :show, :tag, :search]
def index
unless params[:q].blank?
@posts = Post.find_fulltext(params[:q])
else
@posts = Post.find(:all, :page =>{:size => 10, :current => params[:page]}, :order=>... | Ruby |
class AccountController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
layout "admin"
# If you want "remember me" functionality, add this before_filter to Application Controller
before_filter :login_from_cookie
# say something... | Ruby |
class MapController < ApplicationController
def index
@tags = Tag.tags(:limit => 100, :order => "name desc")
@map = GMap.new("map_div")
@map.control_init(:large_map => true,:map_type => true)
markers = Post.get_markers
@map.center_zoom_init(markers[0].point, 3)
unless params[:post].... | 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
helper :all # include all helpers, all the time
self.allow_forgery_protection = false
include Authenticated... | Ruby |
class TagsController < ApplicationController
def reload
feeds = Feed.find(:all)
feeds.each do |feed|
feed.posts.each do |post|
tags = post.body.scan(/\A[а-яА-я\s,]*/)
post.tag_with(tags[0]) unless tags.nil?
end
end
render :partial => "tags", :object => Ta... | Ruby |
class TimelineController < ApplicationController
def index
@tags = Tag.tags(:limit => 100, :order => "name desc")
end
end
| Ruby |
class SettingsController < ApplicationController
before_filter :login_required
layout "admin"
def index
@feeds = Feed.find(:all)
@tags = Tag.find(:all)
end
end
| Ruby |
class AdminController < ApplicationController
def index
end
end
| Ruby |
class FeedsController < ApplicationController
before_filter :login_required
layout "admin", :only => [:index, :new]
#in_place_edit_for :feed, :tag_regexp
def index
@feeds = Feed.find(:all)
end
def set_tag_regexp
@feed = Feed.find(params[:id])
@feed.tag_regexp = params[:tag_regexp]
... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# i... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
ActionController::Routing::Routes.draw do |map|
#map.resources :feeds
# 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 :con... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
# Be sure to restart your server when you modify this file
require 'jcode'
$KCODE = "utf8"
# 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 ... | 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 |
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_user with the user model if they're logged in.
def logged_in?
current_user != :false
end
# Accesses the current user from the session.
def current_user
@current_user ||= ... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user] = user ? users(user).id : nil
end
def content_type(type)
@request.env['Content-Type'] = type
end
def accept(accept)
@request.env["HTTP_ACCEPT"] = accept
en... | Ruby |
require 'hpricot'
require 'open-uri'
class ContentParser
def self.parse(url, path)
doc = Hpricot(open(url))
(doc/"#{path}").inner_html
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.