This file contains hidden or 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
| #!/usr/bin/env ruby | |
| module Algo | |
| # Gets the Greatest Common Divisior of integers a and b | |
| def self.gcd(a, b) | |
| if b == 0 | |
| a.abs | |
| else | |
| gcd(b, a % b) | |
| end |
This file contains hidden or 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
| struct list_item { | |
| list_item *next; // указатель на следующий элемент списка | |
| list_item *rand; // указатель на произвольный элемент списка | |
| }; | |
| list_item *first; // указатель на первый элемент списка | |
| list_item copy(){ | |
| int length = 0; | |
This file contains hidden or 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 'kit/base' | |
| # require 'kit/travian' | |
| class Dozorni | |
| extend Bot::Base | |
| # extend Bot::Travian | |
| def self.bot name, &b | |
| ::AllBots.bots[name] = b | |
| end |
This file contains hidden or 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
| commit 6b9484bd51ce108dcab1158062a0183348aa16d4 | |
| Author: Phil Pirj <[email protected]> | |
| Date: Wed Feb 10 23:17:46 2010 +0300 | |
| adding /logs | |
| diff --git a/container.rb b/container.rb | |
| index 6bec45a..5d80b29 100644 | |
| --- a/container.rb | |
| +++ b/container.rb |
This file contains hidden or 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 'util' | |
| require 'luarocks.require' -- http://www.luarocks.org/ | |
| local http = require 'socket.http' -- http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/ | |
| local bot_container = 'http://dozorni.heroku.com/whatnow' | |
| local body, status = http.request(bot_container, '') | |
| local json = require('json') -- http://luaforge.net/projects/luajson/ | |
| local dec = json.decode(body) |
This file contains hidden or 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
| local function handler(sock_in) | |
| local line = sock_in:receive('*l') | |
| -- where to? | |
| local url = string.match(line, 'http://([%a%d\.-]+):*%d*/') | |
| local port = string.match(line, 'http://[%a%d\.-]+:(%d+)/') | |
| local sock_out = socket.connect(url, port or 80) | |
| repeat | |
| if line then sock_out:send(line..'\r\n') end |
This file contains hidden or 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
| 6 | |
| whale: big black water animal | |
| penguin: black white ice beak | |
| piano: keyboard black white wire | |
| jackboot: leather heel black | |
| train: rail wheel black | |
| rose: red green thorn | |
| 4 | |
| whale penguin piano jackboot train | |
| penguin piano |
This file contains hidden or 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
| def class_for_name name | |
| namespaces = name.split '::' | |
| base = Kernel | |
| namespaces.each do |namespace| base = base.const_get(namespace) end | |
| base | |
| end |
This file contains hidden or 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
| user app; | |
| worker_processes 2; | |
| error_log /home/app/logs/nginx.error.log info; | |
| events { | |
| worker_connections 1024; | |
| } | |
This file contains hidden or 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
| # include this in app file | |
| # this is for Role Based Access Controle, can be much shorter | |
| class Ability | |
| include CanCan::Ability | |
| def initialize account | |
| @abilities ||= {} | |
| allow [:any, :manager, :manufacturer, :admin] do |
OlderNewer