Skip to content

Instantly share code, notes, and snippets.

View infernalmaster's full-sized avatar
😻
Working from home

Rostyslav Diachok infernalmaster

😻
Working from home
View GitHub Profile
@infernalmaster
infernalmaster / FLG FE algo.md
Last active December 5, 2023 20:37
FLG FE algo.md
require "socket"
def handle_client(io)
# START LINE:
io << "HTTP/1.1 200 OK\r\n"
# HEADERS:
io << "Content-Type: text/plain\r\n"
io << "Transfer-Encoding: chunked\r\n"
io << "\r\n"
require "socket"
def handle_client(io)
# read request
loop do
line = io.gets
puts line
break if line == "" # end of headers section
end
# we don't read request body for now
@infernalmaster
infernalmaster / .zshrc
Created April 29, 2021 15:01
zsh config
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/rosd/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@infernalmaster
infernalmaster / CO.js
Last active May 5, 2022 01:29
js/co like generator helper
function coSimple(fn) {
let gen = fn();
function next(asyncValue) {
let { done, value } = gen.next(asyncValue);
let promise = isPromise(value) ? value : Promise.resolve(value);
if (done) return promise;
def user_not_authorized
flash[:alert] = 'You are not authorized to perform this action.'
can_be_infinite_redirect = request.url == request.referer
if can_be_infinite_redirect
redirect_to root_path
else
redirect_back(fallback_location: root_path)
end
end
class ApplicationController < ActionController::Base
include Pundit
protect_from_forgery with: :exception
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def user_not_authorized

Можна пошукати приклади тут https://devhints.io/react. Але найтиповіші задачі

  1. створити компонент
import React from 'react'


export default class Hello extends React.Component {
  state = {text: 'Hello'}
@infernalmaster
infernalmaster / Instructoin.md
Created November 22, 2018 21:57
create-react-app + ESLint + prettier + VSCode
  1. Install packages
npm i -D prettier eslint-config-prettier eslint-plugin-prettier
  1. Add file .eslintrc with this content:
{