This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kivanio Barbosa | |
# Class to remove or install gems | |
class Phoda | |
attr_accessor :command | |
attr_accessor :file | |
attr_accessor :sudo | |
def initialize(command,file,sudo=false) | |
raise "Need some existent File." unless File.exist?(file) | |
@file = file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a code example for the Ruby HTTP library Typhoeus | |
# here's an example for twitter search | |
# Including Typhoeus adds http methods like get, put, post, and delete. | |
# What's more interesting though is the stuff to build up what I call | |
# remote_methods. | |
class Twitter | |
include Typhoeus | |
remote_defaults :on_success => lambda {|response| JSON.parse(response.body)}, | |
:on_failure => lambda {|response| puts "error code: #{response.code}"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shoes.setup do | |
gem 'activeresource' | |
end | |
require 'activeresource' | |
class Person < ActiveResource::Base | |
self.site = 'http://0.0.0.0:3000' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ARF | |
attr :coords | |
def initialize map, follow, size, app | |
@map, @follow, @size, @app, @coords = (map.is_a?(Array) ? map : [map]), follow, size, app, [follow.left,follow.top] | |
@vx, @vy = 0,0 # velocity | |
animate_loop | |
end | |
def [](x,y) | |
@coords[0] += x | |
@coords[1] += y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'pathname' | |
get %r{^(?!/files)(.+$)} do |path| | |
dir = './public/files' + path | |
pass unless File.exists?(dir) | |
@links = Dir[ dir + '*' ].map do |file| | |
url = file.gsub %r{^\./public}, '' | |
file_link( File.directory?( file ) ? url.gsub( %r{^/files}, '' ) + '/' : url ) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App < Sinatra::Base | |
before do | |
headers "Content-Type" => "text/html; charset=utf-8" | |
end | |
get '/?' do | |
"Hello World from App" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |