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
// https://gist.github.com/xNok/74934a0c1c8500bfe84c8de6e92386cd | |
var PSD = require('psd'); | |
var fs = require('fs'); | |
// command usage validation | |
if (process.argv.length <= 2) { | |
console.log("Usage: " + __filename + " path/to/directory/ path/to/output_dir/"); | |
process.exit(-1); | |
} | |
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
var fs = require('fs'); | |
// command usage validation | |
if (process.argv.length <= 3) { | |
console.log("Usage: " + __filename + " path/to/directory path/to/output"); | |
process.exit(-1); | |
} | |
var path = process.argv[2]; | |
var output = process.argv[3]; |
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
from diagrams import Diagram, Cluster, Edge | |
from diagrams.custom import Custom | |
from diagrams.onprem.compute import Server | |
from diagrams.onprem.monitoring import Grafana, Prometheus | |
from diagrams.onprem.container import Docker | |
from diagrams.onprem.database import Mongodb | |
from diagrams.onprem.iac import Ansible | |
from diagrams.onprem.ci import GithubActions | |
with Diagram(name="Startup infra for small self hosted project", show=False): |
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
@startuml | |
actor USER as U | |
participant APP as A | |
participant SLACK as S | |
== App Home == | |
autonumber | |
U -> S: Opens App Home Open | |
S -> A ++ #DarkSalmon: `app_home_opened` event triggered |
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
import _ "embed" | |
//go:embed hello.txt | |
var s strings | |
//go:embed hello.txt | |
var b []bytes |
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
import ( | |
"embed" | |
) | |
//go:embed greetingViews/* | |
var greetingAssets embed.FS |
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 GreetingMessage(user string) []slack.Block { | |
// [TODO]: parse the template `greetingViews/greeting.json` | |
view := slack.Msg{} | |
// [TODO]: unmarshal the template into slack.Msg{} | |
return view.Blocks.BlockSet | |
} |
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 renderTemplate(fs fs.FS, file string | |
, args interface{}) bytes.Buffer { | |
var tpl bytes.Buffer | |
// read the block-kit definition as a go template | |
t, err := template.ParseFS(fs, file) | |
if err != nil { | |
panic(err) | |
} | |
// render the template using provided datas | |
err = t.Execute(&tpl, args) |
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 GreetingMessage(user string) []slack.Block { | |
// we need a stuct to hold template arguments | |
type args struct { | |
User string | |
} | |
tpl := renderTemplate(greetingAssets, "greetingViews/greeting.json", args{User: user}) | |
// we convert the view into a message struct | |
view := slack.Msg{} | |
str, _ := ioutil.ReadAll(&tpl) | |
json.Unmarshal(str, &view) |
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 ConnectToSlackViaSocketmode() (*socketmode.Client, error) { | |
appToken := os.Getenv("SLACK_APP_TOKEN") | |
if appToken == "" { | |
return nil, errors.New("SLACK_APP_TOKEN must be set") | |
} | |
if !strings.HasPrefix(appToken, "xapp-") { | |
return nil, errors.New("SLACK_APP_TOKEN must have the prefix \"xapp-\".") | |
} |
OlderNewer