This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *ClientImpl) PostLargeFile(reader io.ReadCloser, formParams map[string]string) (io.ReadCloser, error) { | |
r, w := io.Pipe() | |
writer := multipart.NewWriter(w) | |
defer r.Close() | |
go func() { | |
defer w.Close() | |
defer reader.Close() | |
for key, val := range formParams { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table mat-table [dataSource]="tableData" style="width: 100%"> | |
<ng-container [matColumnDef]="col" *ngFor="let col of tableData[0] | keys"> | |
<th mat-header-cell *matHeaderCellDef> {{ col }} </th>s | |
<td mat-cell *matCellDef="let element"> {{ element[col] }} </td> | |
</ng-container> | |
<tr mat-header-row *matHeaderRowDef="tableData[0] | keys"></tr> | |
<tr mat-row *matRowDef="let row; columns: tableData[0] | keys;"></tr> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mq | |
import ( | |
"context" | |
"time" | |
"github.com/pkg/errors" | |
"github.com/streadway/amqp" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
job "api-gw" { | |
datacenters = ["dc1"] | |
type = "service" | |
# Update policy | |
update { | |
max_parallel = 1 | |
min_healthy_time = "10s" | |
healthy_deadline = "3m" | |
progress_deadline = "10m" | |
auto_revert = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BRANCH=$(git branch --show-current) | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
for i in {1..5} ; do | |
printf "Phase %s\n" "$i" | |
if ! curl -s "localhost:8000/debug/pprof/heap" > mem-"$BRANCH"-"$COMMIT_HASH"-"$(date "+%Y-%m-%d-%H-%M-%S")".pprof | |
then | |
echo "failed to get mem profile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config: | |
environments: | |
local: | |
target: "http://localhost:8000" | |
phases: | |
- duration: 10 | |
arrivalRate: 1 | |
arrivalCount: 200 | |
maxVusers: 50 | |
name: "Warm up" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH get AS ( | |
SELECT id FROM table_name WHERE name=$1 | |
), new AS ( | |
INSERT INTO table_name (name) VALUES ($1) ON CONFLICT (name) DO NOTHING RETURNING id | |
) | |
SELECT id FROM get | |
UNION ALL | |
SELECT id FROM new; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH ranked_records AS ( | |
SELECT row_number() OVER (PARTITION BY user_id, user_id ORDER BY created_at DESC) AS rn, | |
id, some_other_column, created_at | |
FROM user_status WHERE user_id IN (?) | |
) | |
SELECT | |
id, some_other_column, created_at | |
FROM ranked_records | |
WHERE rn=1 | |
ORDER BY user_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
first AS ( | |
DELETE FROM table1 WHERE condition1 | |
RETURNING * | |
), | |
second AS ( | |
DELETE FROM table2 WHERE condition2 | |
RETURNING * | |
), | |
-- add more analogous delete statements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SizedPool is a channel-based pool of slices objects. | |
// It retains an arbitrary number of slices of objects and ensures their initial capacity. | |
type SizedPool[T any] struct { | |
pool chan []T | |
cap int | |
} | |
func NewSizedPool[T any](size int, cap int) *SizedPool[T] { | |
return &SizedPool[T]{ | |
pool: make(chan []T, size), |
OlderNewer