Skip to content

Instantly share code, notes, and snippets.

View dmitry's full-sized avatar
🇪🇪
Water, earth and air.

Dmitry Polushkin dmitry

🇪🇪
Water, earth and air.
View GitHub Profile
@ffoxin
ffoxin / sqtm
Last active August 29, 2015 13:55
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <thread>
#include <vector>
using namespace std;
inline size_t calc(const size_t n, const size_t i, const size_t j)
{
@yuki24
yuki24 / application.rb
Last active August 29, 2015 14:01
Error handler that generates error pages dynamically in Rails
# config/application.rb
config.exceptions_app = ->(env) { ErrorsController.action(:show).call(env) }
@dmitry
dmitry / why_test.md
Last active August 29, 2015 14:05
Why should I write tests?

Why test?

  • Design API;
  • Make sure code is working as it should;
  • Regression check.

Look how it's easy - all about time:

  • plan (before);
  • implement (current);
@YaroSpace
YaroSpace / ComPort Architecture draft.rb
Created September 17, 2014 15:07
ComPort Architecture draft
Architecture description
-
Aggregator
Orchestrates the overall process from fetching to updating the db,
scheduling and managing aggregator jobs and their stages for different modules
does:
fetch :all | latest - accepts a block with strategy to determine latest
jobs :all | :current - AggreagationJob - status, stop, pause, resume
@hugs
hugs / LICENSE
Created February 15, 2010 01:45
The Node.js "Hello World" web server ported to CoffeeScript
I, Jason Huggins, the author of the work "CoffeeScript Web Server" (2010), irrevocably renounce
all current and future legal rights to the work in any medium whatsoever.
I stand behind the merit of the work, but disclaim all liability for it under law.
I encourage you, the audience, to share, copy, distribute, perform, remix, mash up, interpret,
excerpt, translate, and otherwise enjoy and use the work as you will.
I request that you acknowledge my authorship.
class BaseTask
def self.perform(*args)
ActiveRecord::Base.verify_active_connections!
end
end
class SomeTask < BaseTask
def self.perform(*args)
super
# do some stuff
#encoding: utf-8
require 'mechanize'
class MechanizeEncodingHook
def call(params)
return if params[:response].nil? || params[:response_body].nil?
response = params[:response]
content_type = response['Content-Type']
@nragaz
nragaz / rails.history.js
Created January 16, 2011 23:43
Add callbacks to remote links in Rails to manage browser history using pageState and replaceState
function historySupport() {
return !!(window.history && window.history.pushState !== undefined);
}
function pushPageState(state, title, href) {
if (historySupport()) {
history.pushState(state, title, href);
}
}
From 67eb80e72d8d4782334aabf3b120adf6fdca5cda Mon Sep 17 00:00:00 2001
From: Rodrigo Rosenfeld Rosas <rr_rosas@yahoo.com.br>
Date: Thu, 25 Feb 2010 00:29:43 -0300
Subject: [PATCH] Include support for :full_message option to validations.
---
activemodel/lib/active_model/errors.rb | 54 +++++++++++++------
.../lib/active_model/validations/acceptance.rb | 2 +-
.../lib/active_model/validations/confirmation.rb | 2 +-
.../lib/active_model/validations/exclusion.rb | 2 +-
@ryanb
ryanb / rails_3_1_update.txt
Created July 23, 2011 21:31
Possible output from a Rails 3.1 upgrade wizard
$ rake rails:update
Generating app/assets directory and content. (same as 3.1 app generator)
Do you want to move all public/stylesheets into app/assets/stylesheets? (recommended) [y]
Moving public/stylesheets into app/assets/stylesheets...
Existing application.css, merging content to the end of app/assets/stylesheets/application.css.