Skip to content

Instantly share code, notes, and snippets.

View r6m's full-sized avatar
🏠
Working from home

Reza r6m

🏠
Working from home
  • localhost
View GitHub Profile
@r6m
r6m / rke2-commands.md
Created June 29, 2024 07:08 — forked from superseb/rke2-commands.md
RKE2 commands

RKE2 commands

  • Updated on May 29 to accommodate etcd container not having /bin/sh available anymore.

Install

curl -sL https://get.rke2.io | sh
systemctl daemon-reload
systemctl start rke2-server
@r6m
r6m / google-oauth.controller.ts
Created September 16, 2023 20:53 — forked from thisismydesign/google-oauth.controller.ts
OAuth2 in NestJS for social login (Google, Facebook, Twitter, etc) /1
import { Controller, Get, Req, Res, UseGuards } from '@nestjs/common';
import { Request, Response } from 'express';
import { GoogleOauthGuard } from './google-oauth.guard';
@Controller('auth/google')
export class GoogleOauthController {
constructor(private jwtAuthService: JwtAuthService) {}
@Get()
@UseGuards(GoogleOauthGuard)
@r6m
r6m / golang_minimize_allocations.md
Created February 15, 2023 08:59 — forked from CAFxX/golang_minimize_allocations.md
Minimize allocations in Go

📂 Minimize allocations in Go

Protobuf

Working with protobuf in Go puts significant load on the memory subsystem, as protobuf-generated structures often contain a significant amount of pointers.

One way to minimize the number of allocations is to allocate all the fields at the same time, and then use internal pointers to wire them up.

Practice Consul, Nomad in Production Part 1- Setup Cluster

This cluster will be set up for 3 servers, each server will run (Nomad server/client + Consul server/client)

Server Information

workload-info

Plans

@r6m
r6m / throttled_transport.go
Created August 28, 2022 09:49 — forked from zdebra/throttled_transport.go
NewThrottledTransport wraps transportWrap with a rate limitter, improvement of https://gist.github.com/MelchiSalins/27c11566184116ec1629a0726e0f9af5 since it allows use of *http.Client
package main
import (
"net/http"
"time"
"golang.org/x/time/rate"
)
// ThrottledTransport Rate Limited HTTP Client

Integrating Slate into a Rails app

Want to use the excellent rich text editor Slate in a Rails app? Beware – since you'll be integrating React with your Rails app, it'll turn out pretty complicated and you'll have to do things (e.g. start server, managing dependencies, etc.) a bit differently than before. Let's start.

1. Install react_on_rails

react_on_rails is pretty much the best option for integrating React into Rails. Install it like so:

  1. Add this to your gemfile:
@r6m
r6m / auth.go
Created December 14, 2021 20:22 — forked from ogazitt/auth.go
Auth0 PKCE flow for a CLI built in golang
package auth
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
@r6m
r6m / main.go
Created September 16, 2021 09:25 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@r6m
r6m / frontmatter.js
Created June 27, 2021 04:13 — forked from sudkumar/frontmatter.js
MDX Remark plugin to handle frontmatter
// helps us in parsing the frontmatter from text content
const matter = require('gray-matter')
// helps us safely stringigy the frontmatter as a json object
const stringifyObject = require('stringify-object')
// helps us in getting the reading time for a given text
const readingTime = require('reading-time')
// please make sure you have installed these dependencies
// before proceeding further, or remove the require statements
// that you don't use
@r6m
r6m / restricted_usernames.py
Created January 19, 2021 14:47 — forked from theskumar/restricted_usernames.py
Restricted usernames
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
'''
List of reserved usernames (pre-defined list of special banned and reserved keywords in names,
such as "root", "www", "admin"). Useful when creating public systems, where users can choose
a login name or a sub-domain name.
__References:__
1. http://www.bannedwordlist.com/
2. http://blog.postbit.com/reserved-username-list.html