Skip to content

Instantly share code, notes, and snippets.

Piotr piotr-galas

View GitHub Profile
View import_visualise.rb
require "pry"
require "csv"
class GenerateCsvSummary
NUMBER_OF_ROWS = 10
GENERATED_FILE_PATH = "./csv_summary.csv"
def initialize(absolute_directory_path)
@absolute_directory_path = absolute_directory_path
end
View async_await_explanation.js
class A{
saveArea(callback){
const {t} = this.props;
new Api('/nurses/area').post(this.prepareData())
.then(response => {
if(response.status === 200){
response.json().then(json => {
this.setState({
popupTitle: t('area.success.title'),
View base_class.rb
require 'pry'
# TASK: Implement this class to make tests pass
class BaseClass
attr_reader :errors
VALIDATORS = %i[presence_of_validator numericality_validator].freeze
def self.validates_presence_of(name)
@presence_of_attr = name
end
View concurency_example.rb
THREADS_NUM.times.map {
Thread.new do
while !@objects.empty?
object = @objects.pop
@mutex.synchronize do
print "#{Time.now.strftime("%H:%M")} - Saving data: #{@objects.length} items left. "
print "\r"
end
if object.save
@piotr-galas
piotr-galas / capistrano deploy from zero
Last active Mar 29, 2017
It shows steps to configure deploy with capistrano on almost empty server (OVH) ubuntu
View capistrano deploy from zero
# add key to authorized keys:
1. create file `.ssh/authorized_keys` on server, then on local machine:
`cat ~/.ssh/id_rsa.pub | ssh piotr@xxx.xxx.xxx.xx -p 5555 'cat >> .ssh/authorized_keys'`
2. Check if it possible to login without password
# base capistrano config
View .gitconfig
[user]
name = Piotr
email = galaspiotrek@gmail.com
[push]
default = current
[color]
ui = auto
branch = auto
diff = auto
interactive = auto
View example_of_makro.rb
class Validator
def self.presence(value, *fields)
puts value
puts fields
end
end
class Product
def self.validates(*params)
View job_application.rb
module Filters
class Arrays
initialize(filterad_array, pattern)
@filteredArray = filteredArray
@pattern = pattern
end
def fromPrimeCount
if validateInputs?
filtered
View actioncable example
upstream action {
server unix:/srv/www/development/action-cable/tmp/sockets/puma.sock fail_timeout=0;
}
server {
server_name .actioncable.kulisz.eu;
keepalive_timeout 5;
root /srv/www/development/action-cable/public;
client_max_body_size 4G;
location / {
try_files $uri @action;
@piotr-galas
piotr-galas / preferences.sublime-settings
Created May 28, 2016
settings for sublime to dark theme with icons
View preferences.sublime-settings
{
"Seti_sidebar_font_size_14": true,
"Seti_tab_font_12": true,
"caret_extra_bottom": 3,
"caret_extra_top": 3,
"caret_extra_width": 2,
"color_scheme": "Packages/User/SublimeLinter/Oceanic Next (SL).tmTheme",
"file_exclude_patterns":
[
"npm-debug.log"
You can’t perform that action at this time.