Skip to content

Instantly share code, notes, and snippets.

View ra9dev's full-sized avatar

Sherkhan ra9dev

  • Dubai
View GitHub Profile
@ra9dev
ra9dev / log_api_call.go
Created April 22, 2020 15:59
LogColors
package helpers
import (
"fmt"
"net/http"
"time"
"github.com/sirupsen/logrus"
)
class ProfilePage extends React.Component {
prepareMessage = (user) => {
return 'Followed ' + user;
}
showMessage = (user) => {
const message = this.prepareMessage(user);
alert(message);
};
class Page extends React.Component {
getPageName = () => {
return this.props.name;
}
render() {
return <h1>Welcome on page: {this.getPageName()}!</h1>;
}
}
// The page argument refers to any instance of the Page class, including the inherited one.
// That is, we could equally pass an instance of the ProfilePage class if it inherits from Page,
// since we will use their common method getPageName, and due to this we satisfy the principle of polymorphism.
function logPageVisit(page, userName) {
 console.log(`${userName} has visited ${page.getPageName()}`);
}
function ProfilePage(props) {
const prepareMessage = (user) => {
return 'Followed ' + user;
}
const showMessage = () => {
const message = prepareMessage(props.user);
alert(message);
};
// ... imports
import { prepareMessage } from './prepareMessage'
function ProfilePage(props) {
const showMessage = () => {
const message = prepareMessage(props.user);
alert(message);
};
const handleClick = () => {
import (
"encoding/json"
"errors"
"fmt"
"net/http"
chi "github.com/go-chi/chi/v5"
"github.com/go-chi/render"
validation "github.com/go-ozzo/ozzo-validation/v4"
import "go.uber.org/dig"
func Dependencies() []any {
return []any{InjectionConfig, InjectionPostgres}
}
func InjectionConfig() (config.Config, error) {
return config.NewConfig()
}
package kafka
import (
"context"
"encoding/json"
"fmt"
"github.com/segmentio/kafka-go"
"io"
)
@ra9dev
ra9dev / math.go
Created October 12, 2022 15:32
Generig Golang Math
package math
import (
"math"
"golang.org/x/exp/constraints"
)
type Numeric interface {
constraints.Integer | constraints.Float