Skip to content

Instantly share code, notes, and snippets.

View sagnol's full-sized avatar

Sagnol sagnol

  • Seoul, Korea
  • 21:23 (UTC +09:00)
View GitHub Profile
@sagnol
sagnol / go-style-generators.md
Created February 23, 2023 04:12 — forked from vxgmichel/go-style-generators.md
Go-style generators in asyncio

Go-style generators in asyncio

I've recently been looking into the go concurrency model to see how it compares to asyncio.

An interesting concept caught my attention: go generators.

Generators in Go

@sagnol
sagnol / README.md
Created October 25, 2022 08:12 — forked from anchan828/README.md
This is an improvement to allow @nestjs/[email protected] to handle CustomRepository. I won't explain it specifically, but it will help in some way. https://github.com/nestjs/typeorm/pull/1233

You need to provide some classes and decorators yourself to maintain the same style as [email protected].

1. EntityRepository -> CustomRepository

@EntityRepository(UserEntity)
export class UserRepository extends Repository<UserEntity> {}

@sagnol
sagnol / rust-xp-03-redis.rs
Created September 20, 2022 01:18 — forked from jeremychone/rust-xp-03-redis.rs
Rust Redis with Async/Await (single threaded concurrency) | RustLang by example
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use std::{error::Error, time::Duration};
use tokio::time::sleep;
use redis::{
from_redis_value,
streams::{StreamRangeReply, StreamReadOptions, StreamReadReply},
AsyncCommands, Client,
};
@sagnol
sagnol / pause.scala
Created May 9, 2022 02:06 — forked from mpilquist/pause.scala
Pausing & resuming an FS2 stream
// Like interruptWhen / interrupt but allows resumption of the source stream.
def pauseWhen[F[_]: Async, A](controlSignal: Signal[F, Boolean]): Pipe[F, A, A] =
pause(controlSignal.discrete)
def pause[F[_]: Async, A](control: Stream[F, Boolean]): Pipe[F, A, A] = {
def unpaused(
controlFuture: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[Boolean], Handle[F, Boolean])]],
srcFuture: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[A], Handle[F, A])]]
): Pull[F, A, Nothing] = {
@sagnol
sagnol / ssm_parameter.go
Created July 15, 2020 01:41 — forked from miguelmota/ssm_parameter.go
AWS SSM Go SDK parameter store example
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ssm"
)
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@sagnol
sagnol / update-golang.md
Created May 8, 2020 02:35 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@sagnol
sagnol / gist:cc3e8c2b95f41f4755109374dcc2a036
Created March 30, 2020 05:32 — forked from michail-nikolaev/gist:3840973
JPA - Tree structure with automatic order and tested operations for it
@Entity
public class TreeCategory extends IdentifiableEntity {
....
@ManyToOne(optional = true)
@JoinColumn(name = "parent_id", referencedColumnName = "id")
public TreeCategory getParent() {
return parent;
}
@sagnol
sagnol / protect.conf
Created March 18, 2020 04:54 — forked from VirtuBox/protect.conf
Nginx Configuration to block SQL Injection and similar attacks
location ~* "(eval\()" { deny all; }
location ~* "(127\.0\.0\.1)" { deny all; }
location ~* "([a-z0-9]{2000})" { deny all; }
location ~* "(javascript\:)(.*)(\;)" { deny all; }
location ~* "(base64_encode)(.*)(\()" { deny all; }
location ~* "(GLOBALS|REQUEST)(=|\[|%)" { deny all; }
location ~* "(<|%3C).*script.*(>|%3)" { deny all; }
location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" { deny all; }
location ~* "(boot\.ini|etc/passwd|self/environ)" { deny all; }
location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" { deny all; }