Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / restore.sh
Created March 31, 2023 08:38
Restore Files from Glacier on Amazon S3 Storage using Bash Script
#!/bin/bash
# Set your AWS region and S3 bucket name
REGION=eu-central-1
BUCKET=bucket-name
# List all objects in the bucket and change the storage class to Standard
aws s3api list-objects --region "$REGION" --bucket "$BUCKET" --query "Contents[?StorageClass=='GLACIER'].[Key]" --output text | while read -r line; do
# Skip directories
if [[ "$line" == */ ]]; then
@slav123
slav123 / unlock.sh
Created September 1, 2022 11:35
SeLinux write
#SELinux is blocking the read/write operations
chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/ (if you want to allow full web root)
chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/uploads/ (Or just uploads folder)
@slav123
slav123 / signed.go
Last active August 29, 2022 07:43
AWS Signed request in GO
package main
import (
"compress/gzip"
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
@slav123
slav123 / timeout.go
Created July 31, 2022 09:14
example of using timeout in go with context package
package main
import (
"context"
"fmt"
"time"
)
var globalResult []int
@slav123
slav123 / post.go
Created July 5, 2022 13:46
Send multipart/form-data form with GO
type field struct {
Key string `json:"key"`
Value string `json:"value"`
}
func Post(url string, fields []field) error {
var b bytes.Buffer
w := multipart.NewWriter(&b)
@slav123
slav123 / post.go
Created June 30, 2022 06:34
golang post query with host header oberri
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
@slav123
slav123 / main.go
Created June 23, 2022 14:16
PUT presigned url example in Go
// main.go
package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
@slav123
slav123 / trigger.sql
Created November 3, 2021 09:31
trigger mysql to update items
DELIMITER $$
CREATE TRIGGER on_items_update
AFTER INSERT
ON order_items FOR EACH ROW
BEGIN
UPDATE orders SET total_photos=total_photos+1 WHERE id=new.order_id;
END$$
DELIMITER ;
@slav123
slav123 / post.js
Created September 27, 2021 07:50
post fetch query
postData('notes/update_note_date', {
id: element.parentElement.getAttribute("data-id"),
lead_id: element.parentElement.getAttribute('data-lead'),
note_type: element.parentElement.getAttribute('data-type'),
field: element.parentElement.getAttribute('data-field'),
value: element.value
}).then(data => {
console.log(data); // JSON data parsed by `data.json()` call
});
@slav123
slav123 / index.html
Last active September 24, 2021 09:57
inline date picker with HTML5
<!DOCTYPE html>
<html>
<head>
<title>Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<div class="editable date" data-id="6">2021-09-23</div>
<div class="editable date" data-id="1">2011-08-11</div>