Skip to content

Instantly share code, notes, and snippets.

@udomsak
udomsak / loki.service
Created May 6, 2021 04:14
loki systemd unit file for ubuntu 18.04
[Unit]
Description=Loki service
After=network.target
[Service]
Type=simple
User=loki
ExecStart=/usr/local/bin/loki --config.file /etc/grafana/loki/loki-local-config.yaml
[Install]
@udomsak
udomsak / debug_aws_transfer_server.log
Created September 21, 2021 17:00
trace file from aws_transfer_server
This file has been truncated, but you can view the full file.
2021-09-21T23:35:33.774+0700 [DEBUG] Adding temp file log sink: /tmp/terraform-log371252502
2021-09-21T23:35:33.774+0700 [INFO] Terraform version: 0.15.3
2021-09-21T23:35:33.774+0700 [INFO] Go runtime version: go1.16.2
2021-09-21T23:35:33.774+0700 [INFO] CLI args: []string{"/home/ubuntu/.tfenv/versions/0.15.3/terraform", "plan", "-out=tfplan"}
2021-09-21T23:35:33.774+0700 [TRACE] Stdout is a terminal of width 133
2021-09-21T23:35:33.774+0700 [TRACE] Stderr is a terminal of width 133
2021-09-21T23:35:33.774+0700 [TRACE] Stdin is a terminal
2021-09-21T23:35:33.774+0700 [DEBUG] Attempting to open CLI config file: /home/ubuntu/.terraformrc
2021-09-21T23:35:33.774+0700 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
@udomsak
udomsak / sftp_schema.json
Created September 9, 2021 17:51
aws transfer family session policy schema
{
"HomeDirectory": "string",
"HomeDirectoryMappings": [
{
"Entry": "string",
"Target": "string"
}
],
"HomeDirectoryType": "string",
"Policy": "string",
@udomsak
udomsak / postman_fc29_install.sh
Created December 24, 2018 17:00
Install postman on Fedora core 29 - Dec 2018
#!/bin/bash
wget https://dl.pstmn.io/download/latest/linux64 -O postman-linux-x64.tar.gz
sudo tar xvzf postman-linux-x64.tar.gz -C /opt
sudo ln -s /opt/Postman/Postman /usr/bin/postman
cat << EOF > ~/.local/share/applications/postman2.desktop
[Desktop Entry]
Name=Postman
GenericName=API Client
@udomsak
udomsak / cf-aws-ecr-with-iam-group-and-role.yaml
Created November 30, 2020 15:24
CloudFormation Amazon ECR with useraccount attach with IAM policy and group
# This Cloudformation will create User login only for AWS ECR with Push/Pull permission without console login permission.
# Output will produce AcessKey and SecretKey with Username.
# Group named 'GroupAccessECRImages'
AWSTemplateFormatVersion: 2010-09-09
Resources:
accessEcrUser:
Type: AWS::IAM::User
Properties:
@udomsak
udomsak / terraform.debug.log
Created September 13, 2020 14:29
TF_VAR does not pass environment variable to terraform-digitalocean-provider
2020/09/13 14:24:05 [INFO] Terraform version: 0.13.2
2020/09/13 14:24:05 [INFO] Go runtime version: go1.14.7
2020/09/13 14:24:05 [INFO] CLI args: []string{"C:\\ProgramData\\chocolatey\\lib\\terraform\\tools\\terraform.exe", "apply", "-state=_test.state", "_test_"}
2020/09/13 14:24:05 [DEBUG] Attempting to open CLI config file: C:\Users\Admin\AppData\Roaming\terraform.rc
2020/09/13 14:24:05 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/09/13 14:24:05 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2020/09/13 14:24:05 [DEBUG] ignoring non-existing provider search directory C:\Users\Admin\AppData\Roaming\terraform.d\plugins
2020/09/13 14:24:05 [DEBUG] ignoring non-existing provider search directory C:\Users\Admin\AppData\Roaming\HashiCorp\Terraform\plugins
2020/09/13 14:24:05 [INFO] CLI command args: []string{"apply", "-state=_test.state", "_test_"}
2020/09/13 14:24:05 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
@udomsak
udomsak / sample_binance.py
Created August 23, 2020 14:35
การเชื่อมต่อ กับ binance โดยใช้ WS ( WebSocket ) connect เพื่อการเชื่อมต่อแบบ Realtime
"""
Quest: https://www.facebook.com/groups/admin.py.dev/permalink/1437718479746684/
"""
from binance.client import Client
from binance.websockets import BinanceSocketManager
"""
เวลาทำงานกับ WSS ( Web Socket ให้ทำงานกับ API ตัวนี้ )
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md
@udomsak
udomsak / python_thailand.ipynb
Last active August 2, 2020 17:13
community answer | Python Thailand
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@udomsak
udomsak / bulk_remove_fork.py
Last active April 11, 2019 07:35
Bulk remove folks repositories
#!/usr/bin/env python
from github import Github
#https://github.com/settings/tokens
g = Github("4a3d3c5ba12e402015dcdcf55c312e0614xxxxx888s")
folks_repo = [ repo for repo in g.get_user().get_repos() if repo.fork == True]
for repo in folks_repo:
repo.delete()
@udomsak
udomsak / runner.js
Created December 25, 2018 14:11
fastify-validation not work.
// Require the framework and instantiate it
const fastify = require('fastify')({
logger: true
})
const post_schema = {
method: 'GET',
schema: {
body: {
type: 'object',