Skip to content

Instantly share code, notes, and snippets.

View ArseniySavin's full-sized avatar
😏

savars ArseniySavin

😏
View GitHub Profile
@ArseniySavin
ArseniySavin / OracleDynamicParameters.cs
Created August 6, 2016 02:58 — forked from vijayganeshpk/OracleDynamicParameters.cs
OracleDynamicParameters class for Dapper
using Dapper;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
public class OracleDynamicParameters : Dapper.SqlMapper.IDynamicParameters {
private static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>( );
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
}
}
@ArseniySavin
ArseniySavin / publicating-go-application-on-github.md
Last active February 21, 2021 04:45 — forked from lesovsky/publicating-go-application-on-github.md
Publicating Golang application on GitHub.

Link

Publicating Golang application on GitHub.

  • Makefile
  • Dockerfile
  • Github Actions
  • Goreleaser

Makefile

@ArseniySavin
ArseniySavin / dumptransport.go
Created October 30, 2021 11:01 — forked from jboursiquot/dumptransport.go
Dump transport will dump Go HTTP request/response for debugging
package dumptransport
import (
"fmt"
"net/http"
"net/http/httputil"
)
type DumpTransport struct {
r http.RoundTripper
@ArseniySavin
ArseniySavin / revprox.go
Created October 30, 2021 11:09 — forked from JalfResi/revprox.go
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@ArseniySavin
ArseniySavin / insert.go
Created May 23, 2022 12:51 — forked from miguelmota/insert.go
Golang SQL insert row and get returning ID example
func InsertOrder(order *Order) (int, error) {
var id int
tx, err := db.Begin()
if err != nil {
return id, err
}
{
@ArseniySavin
ArseniySavin / crc32.sql
Created October 13, 2022 09:48 — forked from cuber/crc32.sql
crc32 for postgresql
CREATE OR REPLACE FUNCTION CRC32(VARCHAR) RETURNS BIGINT AS
$BODY$
DECLARE
src alias FOR $1;
crc BIGINT not null default x'ffffffff'::BIGINT;
len INTEGER not null default 0;
i INTEGER not null DEFAULT 1;
table BIGINT[] not null DEFAULT ARRAY[
x'00000000'::BIGINT, x'77073096'::BIGINT, x'EE0E612C'::BIGINT, x'990951BA'::BIGINT,
x'076DC419'::BIGINT, x'706AF48F'::BIGINT, x'E963A535'::BIGINT, x'9E6495A3'::BIGINT,
@ArseniySavin
ArseniySavin / docker-api-port.md
Created June 20, 2024 07:07 — forked from styblope/docker-api-port.md
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
    
@ArseniySavin
ArseniySavin / reflection.go
Created August 16, 2024 17:07 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@ArseniySavin
ArseniySavin / how-to-postgres-listener.md
Created July 9, 2025 16:27 — forked from albscui/how-to-postgres-listener.md
Postgres trigger and listener mechanism (Go)

How to listen to events in Postgres (with a bit of Go)

Postgres has built-in mechanism for notifying clients (listeners) of events such as INSERT, UPDATE, and DELETE on tables.

Note that for this to work, a listener must have a dedicated direct connection to Postgres. Connection poolers like pgbouncer would not work.

First, lets go over some key Postgres components:

  • triggers - automatically executes some function when an event on a table occurs
  • channels - a communication mechanism identified by a string in postgres