Skip to content

Instantly share code, notes, and snippets.

View denysxftr's full-sized avatar

Denys Serhiienko denysxftr

View GitHub Profile
@denysxftr
denysxftr / talk_notes.md
Last active July 1, 2023 11:50
Links and mentioned things from PyconPL 2023 Talk Building reliable Python microservices: lessons learned from production downtimes
from flask import Flask, abort, request
import json
import subprocess
import hashlib
import os
app = Flask(__name__)
@app.route("/submit", methods=["POST"])
def submit():
sudo su
add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
mkdir /usr/local/share/spark
curl http://d3kbcqa49mib13.cloudfront.net/spark-2.1.0-bin-hadoop2.7.tgz | tar xvz -C /usr/local/share/spark
cd /usr/local/share/spark/spark-2.1.0-bin-hadoop2.7/
./bin/run-example SparkPi 10 # output should contain Pi
# add this to your .bashrc
export SPARK_HOME=/usr/local/share/spark/spark-2.1.0-bin-hadoop2.7
@denysxftr
denysxftr / .bashrc
Last active February 5, 2017 21:42
PS1='\[\e[0;31m\][PRODUCTION]\[\e[0m\][\u@\[\e[0;92m\]\h\[\e[0m\]:\[\e[0;96m\]\w\[\e[0m\]] $ ' # production
PS1='\[\e[0;36m\][STAGING]\[\e[0m\][\u@\[\e[0;92m\]\h\[\e[0m\]:\[\e[0;96m\]\w\[\e[0m\]] $ ' # staging
PS1='\[\e[0;31m\][PRODUCTION]\[\e[0m\][\u@\[\e[0;92m\]\h\[\e[0m\]:\[\e[0;96m\]\w\[\e[0m\]]\[\e[1;31m\][ROOT]\[\e[0m\] # ' # production root
PS1='\[\e[0;36m\][STAGING]\[\e[0m\][\u@\[\e[0;92m\]\h\[\e[0m\]:\[\e[0;96m\]\w\[\e[0m\]]\[\e[1;31m\][ROOT]\[\e[0m\] # ' # staging root
require 'rack'
require 'json'
class ApiApp
def initialize
@views = {}
end
def call(env)
req = Rack::Request.new(env)
class SomeService
# http status of operation
attr_reader :status
# result of service work for example: { errors: { email: ['should not be empty'] }, user: { id: 32, email: nil, ... } }
attr_reader :result
def self.call(params)
new(params).perform!
end
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"draw_white_space": "all",
"font_size": 14,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
folder_path = ENV['FOLDER']
from = Regexp.new(ENV['FROM'])
to = ENV['TO']
Dir.glob(folder_path + "*").sort.each do |f|
filename = File.basename(f, File.extname(f))
new_filename = filename.gsub(from, to)
File.rename(f, folder_path + new_filename + File.extname(f))
end
@denysxftr
denysxftr / v-jquery-change.js
Created May 12, 2015 13:44
custom vue js directive for jquery events
Vue.directive('jquery-change', {
twoWay: true,
bind: function() {
var self = this;
$(self.el).on('change', function() {
self.set(this.value);
});
},
update: function(data) {
if(data) {
@denysxftr
denysxftr / lab15.pl
Created April 5, 2015 15:09
Find the most frequent element from list.
%% PACK SECTION
pack([X|Unpacked], Packed) :- pack(Unpacked, [[X]], Packed).
pack([H|T], [[H|Acc]|Rest], Packed) :- pack(T, [[H,H|Acc]|Rest], Packed).
pack([X|T], [[Y|Acc]|Rest], Packed) :-
X \= Y,
pack(T, [[X],[Y|Acc]|Rest], Packed).
pack([], RPacked, Packed) :- reverse(RPacked, Packed).
% UTILS SECTION