Skip to content

Instantly share code, notes, and snippets.

@dmitriy-sqrt
dmitriy-sqrt / ejabberd.cfg
Last active December 28, 2015 20:59
Ejabberd config (place in /etc/ejabberd/ejabberd.cfg)
%%%
%%% Debian ejabberd configuration file
%%% This config must be in UTF-8 encoding
%%%
%%% The parameters used in this configuration file are explained in more detail
%%% in the ejabberd Installation and Operation Guide.
%%% Please consult the Guide in case of doubts, it is available at
%%% /usr/share/doc/ejabberd/guide.html
%%% This configuration file contains Erlang terms.
@dmitriy-sqrt
dmitriy-sqrt / gist:7688990
Last active December 29, 2015 15:09
Tournament mix model
def logA( x, a )
return (Math.log(x)/Math.log(a))
end
def print_row(teams) #просто выводит команды на какомто этапе
teams.each_slice(2) do |team1, team2|
print team1.to_s + '-' + team2.to_s + " "
end
puts
@dmitriy-sqrt
dmitriy-sqrt / gist:7699115
Last active December 29, 2015 16:39
Perfect team mixing
#################################Тестирование#################################
def print_row(teams) #просто выводит команды на какомто этапе
teams.each_slice(2) do |team1, team2|
print team1.to_s + '-' + team2.to_s + " "
end
puts
end
def random_play(team1,team2)
require 'amqp'
require 'em-websocket'
class Websockets
def self.publisher(message = "Hello world!"+Time.now.to_s, routing_key = "amqp.test") #routing_key will contain current_user.id
#connect to rabbitmq service, open channel, create queue
AMQP.start("amqp://localhost") do |connection| # connection is open and ready to be used
channel = AMQP::Channel.new(connection)
require 'amqp'
require 'em-websocket'
class Websockets
def self.publisher(message = "Hello world!"+Time.now.to_s, routing_key = "amqp.test") #routing_key will contain current_user.id
#connect to rabbitmq service, open channel, create queue
AMQP.start("amqp://localhost") do |connection| # connection is open and ready to be used
channel = AMQP::Channel.new(connection)
class UpdateTeamRatingsFromTeamScores < ActiveRecord::Migration
def up
rating = Rating.by_alias('starladder')
Team.all.each do |team|
prev_tscore = team.team_scores.first
current_team_rating = nil
team.team_scores.each_with_index do |tscore, index|
require 'nokogiri'
file = File.open("/home/neox/Desktop/test")
doc = Nokogiri::HTML(file)
rows = doc.css('tbody tr')
rows.each do |row|
name = row.at_xpath('td[2]/a/text()').to_s.strip
<?php
$birth_date = htmlentities($_GET['birth_date']);
if (preg_match("/([0-9]{2})\.([0-9]{2})\.([0-9]{4})/", $birth_date) === 0)
$error = 'Неправильный формат даты.';
#$birth_date = '21.04.1991';
$date = [];
list($date['day'], $date['month'], $date['year']) = explode('.', $birth_date);
class OneOnOne::ConversationManager
attr_reader :session, :limit, :offset, :timestamp
LIMIT = 5
def initialize(session, options = {})
@session = session
@limit = options[:limit].present? ? options[:limit].to_i : LIMIT
@offset = options[:offset].present? ? options[:offset].to_i : 0
@timestamp = options[:timestamp].present? ? Time.at(options[:timestamp].to_i) : nil
/*Message*/
{
"body": "bw",
"created_at": "2016-07-12T08:28:58Z",
"id": 60,
"user": {
"id": 1,
"avatar_url": null,
"full_name": "Darwin Lueilwitz"
},