Skip to content

Instantly share code, notes, and snippets.

@CarsonSlovoka
CarsonSlovoka / awaitMessages.go
Created June 21, 2022 05:48
discord bot test
package main
import (
"container/list"
"flag"
"fmt"
"github.com/bwmarrin/discordgo"
"os"
"os/signal"
"strings"
@CarsonSlovoka
CarsonSlovoka / flag_example.go
Created September 10, 2022 09:37
A tutorial for flag
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"strconv"
"strings"
@CarsonSlovoka
CarsonSlovoka / popupmenu_test.go
Created November 15, 2022 03:15
create popup menu
package main
import (
"github.com/CarsonSlovoka/go-pkg/v2/w32"
"log"
"syscall"
"unsafe"
)
func ExampleUser32DLL_CreatePopupMenu() {
@CarsonSlovoka
CarsonSlovoka / js_extends_multiple.html
Created November 29, 2022 08:40
ES6 Class Multiple inheritance
<script>
class Meta {
static id = 0 // 流水號
static GetID() {
return ++Meta.id
}
constructor() {
console.log("meta created.")
@CarsonSlovoka
CarsonSlovoka / import.ts
Last active January 23, 2023 18:47
Example: import javascript from gist
export async function ImportModule(url: string) {
const res = await fetch(url)
const newBlob = new Blob([(await res.text())],{type: 'text/javascript'})
return (await import(URL.createObjectURL(newBlob)))
}
@CarsonSlovoka
CarsonSlovoka / xml.MarshalIndent.js
Created February 2, 2023 03:12
Pretty printing XML with javascript
function prettifyXml(sourceXml)
{
const xmlDoc = new DOMParser().parseFromString(sourceXml, 'application/xml');
const xsltDoc = new DOMParser().parseFromString([
// describes how we want to modify the XML - indent everything
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',
' <xsl:strip-space elements="*"/>',
' <xsl:template match="para[content-style][not(text())]">', // change to just text() to strip space in text nodes
' <xsl:value-of select="normalize-space(.)"/>',
' </xsl:template>',
@CarsonSlovoka
CarsonSlovoka / ansIoReader.go
Created February 9, 2023 07:05
回答discordgo用
package main
import (
"bufio"
"log"
"os"
"time"
)
type User struct {
@CarsonSlovoka
CarsonSlovoka / powershell.xml
Last active July 11, 2023 04:20
jetbrains.filetypes.powershell
<filetype binary="false" default_extension="ps1" description="powershell" name="powershell">
<highlighting>
<options>
<option name="LINE_COMMENT" value="#" />
<option name="COMMENT_START" value="&lt;#" />
<option name="COMMENT_END" value="#&gt;" />
<option name="HEX_PREFIX" value="" />
<option name="NUM_POSTFIXES" value="" />
<option name="HAS_BRACES" value="true" />
<option name="HAS_BRACKETS" value="true" />
@CarsonSlovoka
CarsonSlovoka / README.md
Last active July 14, 2023 07:52
slidev.components.vtt
@CarsonSlovoka
CarsonSlovoka / drawImage.go
Created July 21, 2023 09:02
新增畫布,並將圖片畫到該畫布上
package main
import (
"image"
"image/color"
"image/draw"
"image/png"
"os"
)