Skip to content

Instantly share code, notes, and snippets.

View aishek's full-sized avatar
👨‍💻

Aleksandr Borisov aishek

👨‍💻
  • Tver', Russia
View GitHub Profile

Keybase proof

I hereby claim:

  • I am aishek on github.
  • I am aishek (https://keybase.io/aishek) on keybase.
  • I have a public key ASCG0kHVMkr4kkywJkqlkbMTUTz4E9SbOnZa3inOR6NMKAo

To claim this, I am signing this object:

@aishek
aishek / ls.rb
Created February 16, 2019 13:27
middle = ->(array) { array[array.size / 2] }
def plural(string, plural_ending)
return string if string.end_with?(plural_ending)
"#{string}#{plural_ending}"
end
files = `ls -a`.split("\n")
#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/wait.h>
int main() {
unshare(CLONE_NEWIPC | CLONE_NEWNS | CLONE_NEWNET | CLONE_NEWPID | CLONE_NEWUTS);
if(fork()) {
@aishek
aishek / special_case_if.rb
Created August 17, 2016 08:21
special_case_if.rb
def deliver_order_details_email_async(order)
# Было
#
# if order.long?
# Order::PickUpEmailWorker.perform_async(order.id)
# else
# Order::PickUpAndDropOffEmailWorker.perform_async(order.id)
# end
# Стало
@aishek
aishek / special_case.js
Created August 17, 2016 08:16
special_case.js
function sendPickUpEmailAsync(order) {
if (order.fromOffice()) return;
if (order.isLong()) {
sendPickUpEmailAsync(order)
}
else {
sendPickUpAndDropOffEmailAsync(order)
}
}
@aishek
aishek / special_case.rb
Created August 17, 2016 08:15
special_case.rb
def send_pick_up_email_async(order)
return if order.from_office?
if order.long?
Order::PickUpEmailWorker.perform_async(order.id)
else
Order::PickUpAndDropOffEmailWorker.perform_async(order.id)
end
end
@aishek
aishek / need_special_case.rb
Last active August 17, 2016 08:14
Secret case examples
def send_pick_up_email_async(order)
unless order.from_office?
if order.long?
Order::PickUpEmailWorker.perform_async(order.id)
else
Order::PickUpAndDropOffEmailWorker.perform_async(order.id)
end
end
end
@aishek
aishek / production.rb
Created February 9, 2015 15:04
Yandex.Metrika webvisor RoR 4 fix
# config/environments/production.rb
MyRails4::Application.configure do
# ...
config.action_dispatch.default_headers = {
'X-XSS-Protection' => '1; mode=block',
'X-Content-Type-Options' => 'nosniff'
}
# ...
end
@aishek
aishek / application.rb
Created February 4, 2015 12:04
trailing_slash example
# config/application.rb
# ...
module Example
class Application < Rails::Application
# ...
config.action_controller.default_url_options = { :trailing_slash => true }
config.action_mailer.default_url_options = { :trailing_slash => true }
end
@aishek
aishek / games_api.rb
Last active August 29, 2015 14:13
Grape logger
# app/controllers/api/v1/games_api.rb
class Api::V1::GamesAPI < Api::V1::BaseAPI
use ::Api::V1::Logger
# ...
end