Skip to content

Instantly share code, notes, and snippets.

View quolpr's full-sized avatar
🚀
rock

Sergey quolpr

🚀
rock
View GitHub Profile
#container {
margin: 48px auto;
width: 960px;
section {
clear: both;
}
header {
margin-bottom: 46px;
@quolpr
quolpr / laba.cpp
Last active August 29, 2015 14:14
laba
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
bool file_valid(char *filename) {
_strlwr_s(filename, 100);
char* const unsupported[] = {
class MyClass
def initialize(&block)
instance_eval(&block)
end
def say(message)
@message = message
self
end
class Likeable
validate :check_voteable
def check_voteable
has_assoc = model_type.constantize.reflect_on_all_associations(:belongs_to)
unless has_assoc.select{|name| name=='likeable'}
errors.add(:model_type, "This model is not voteable")
end
end
class ActiveRecord::Base
class << do
def self.voteable!
@voteable = true
end
def self.voteable?
@voteable || false
end
end
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
@quolpr
quolpr / opertions.rb
Created July 16, 2017 11:15
Trnasactions
class CreatePost
def call
in_transaction do
Post.create!(params[:post]).tap do |post|
params[:comments].each do |comment_params|
post.comments << CreateComment.(comment_params)
end
end
end
end
defmodule SafeTcp do
@moduledoc"""
This process tries to maintain connection with the TCP server. If error is
occured or connection is closed - it will be trying to establish the new one every
@reconnect_freequency milliseconds
"""
use GenServer
@initial_state %{socket: nil, connection_error: nil, host: nil, port: nil}
@quolpr
quolpr / Readme.md
Created June 28, 2024 07:48
Cspell integration to nvim
  1. Clone https://github.com/streetsidesoftware/vscode-spell-checker locally and compile it with npm i && npm run build-production
  2. Create file lua/cspell-lsp/init.lua. Don't forget to change path at cmd.
local util = require 'lspconfig.util'

-- Function to decode a URI to a file path
local function decode_uri(uri)
  return string.gsub(uri, 'file://', '')
end