Skip to content

Instantly share code, notes, and snippets.

View bestwebua's full-sized avatar
:octocat:

Vladislav Trotsenko bestwebua

:octocat:
View GitHub Profile
@le0pard
le0pard / dns.rb
Created October 1, 2020 11:21
Simple Ruby DNS server
# frozen_string_literal: true
require 'socket'
require 'bindata'
class DnsHeader < BinData::Record
endian :big
uint16 :transaction_id
bit1 :flag_QR
@davydovanton
davydovanton / text.md
Last active August 11, 2023 13:33
Рефакторинг сервис объекта с монадами и AR

https://t.me/pepegramming

Сегодня попался рельсовый код, в котором используются монады, сервисы и прочее. Решил сделать обзор с объяснением того, что в коде не нравится и что можно исправить.

Данный разбор основан только на личном опыте и избегает попытку написать самый идеальный код на свете. К сожалению пошарить ссылку на код не могу, потому что автор попросил опубликовать анонимно.

Исходные данные

Главная операция, которая вызывается из контроллера выглядит следующим образом:

@median-man
median-man / mongodb-mac-uninstall.md
Last active December 8, 2023 16:06
Uninstall MongoDB on Mac

How to Completely Uninstall MongoDB Community on macOS Catalina

From this post on the IntelliPaat forum.

This guide assumes that MongoDB Community was installed on macOS Catalina using brew install mongodb-community@4.2. Refer to MongoDB Manual: Install on MacOS for installation instructions.

Commands to Uninstall

@tgaff
tgaff / upgrade26.md
Last active January 14, 2021 06:40
ruby 2.3 to 2.6 upgrade

local

brew upgrade ruby-install
ruby-install ruby 2.6.5

install bundler 2.1.4 (may not be necessary)

Depending on ruby version manager (rvm/chruby/rbenv) you may need to change directories or select ruby 2.6.5 then

@rubencaro
rubencaro / setup_go.md
Last active April 28, 2024 21:52
Golang installation guide

Golang installation guide

Since Golang version 1.11 this process is finally (almost) as easy as it should (!!). You can see full docs here. For older guides see here.

These are my notes, not a generic solution. They are not meant to work anywhere outside my machines. Update version numbers to whatever are the current ones while you do this.

Installing everything needed the first time

Install asdf and its golang plugin, then install golang

@Aupajo
Aupajo / 01.1.lifecycle.rb
Last active August 25, 2023 19:26
Sockets in Ruby
require 'socket'
# 1. Create
# AF_INET means IPv4 (xxx.xxx.xxx.xxx)
# SOCK_STREAM means communicating with a stream (TCP)
#
# Can be simplified to symbols :INET and :STREAM, respectively
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
@loisaidasam
loisaidasam / README.md
Last active October 19, 2023 16:07
Sort git tags by semver

If you're like me and you use semver for versioning your tags, you probably hate when you do this:

$ git tag -l
0.1.0
0.10.0
0.2.0
0.3.0
0.3.1
0.4.0

0.5.0

@albertico
albertico / sequel-tinytds-mssql-example.md
Last active October 18, 2022 16:04
A sample script for connecting to MS SQL Server database using Sequel ORM with the TinyTDS adapter.

Ruby Sequel TinyTDS MS SQL Example

A sample script for connecting to MS SQL Server database using Sequel ORM with the TinyTDS (FreeTDS) adapter.

#!/usr/bin/env ruby

require 'sequel'
require 'tiny_tds'
@rxaviers
rxaviers / gist:7360908
Last active May 10, 2024 23:34
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@llxff
llxff / active_admin.rb
Created August 15, 2013 07:29
Using devise + activeadmin with one User model and separate sign_in entry points
config.authentication_method = :authenticate_admin_user!
config.current_user_method = :current_admin_user
config.logout_link_path = :destroy_user_session_path