Home

That Which Must Not Be Read >

  • TOM and his Computer bring brilliance into existence

    8 months ago

    It was an evening of solitude. The sky absolutely black, the cats all tuckered out, and not a responsibility needing to be tended to. I scrolled through BandsInTown and noticed Trentemøller was having a concert at the Wonder Ballroom (Portland). Fondly recalling his mentally stimulating music, I purchased a ticket.

    At the venue, I saw a little gray computer monitor on a table on stage. Was that an Apple computer from way back when? Audience members slowly moseyed their way in, and proceeded to equip themselves with liquid courage. Was Trentemøller going to have an opener? There wasn't a mention of one on the ticket purchase page.

    TOM came out and braced us with his presence at the table with the little computer monitor facing the audience. The monitor flickered on, and began to display sweet pixelated animations!

    What came after the lights went darker I was so not expecting. What came next was amplified by the fact that I have particularly acute hearing.

    The first minute or so of his set went a bit like this: A hard candy-textured merry-go-round succession of synthy music notes punched the floor beneath my feet, offering the listener an opportunity to probe the intellect. So probe the intellect I did -- and TOM's music made it so fucking easy. It's as if his music made my thoughts progress and become clarified. One key thought was, "What the hell is going on, how in the hell is this music so fucking good?"

    And then the candy sequence ceased. It ceased for a moment, but a gentle synth blanket continued on, and decrescendoed to echoing silence. UM, WHAT!!! EXCUSE ME, UNIVERSE, WHAT WAS THAT?!! Color me fucking fascinated, but TOM and his Computer are truly, TRULY brilliant. I've seen many shows in this lifetime, and his set comes at #2 for me, right below Danny Elfman's Nightmare Before Christmas concert.

    I ordered his 'Future Ruins' vinyl today and am so excited for its arrival. I can't wait to see another show of his.

    Should I fly to Brooklyn for the last leg of their tour?

  • Delete a known element from a slice

    almost 5 years ago
    a := []int{0,1,2,3,4,5}
    i := 1
    a = append(a[:i], a[i+1:]...)
    

    Out:
    [0 2 3 4 5 6]

  • I love this

    almost 5 years ago

    https://djhworld.github.io/post/2018/01/27/running-go-aws-lambda-functions-locally/

  • Type assertion vs. type conversion in Go

    almost 5 years ago

    Type assertion

    Source

    For an expression x of interface type and a type T, the primary expression

    x.(T)

    asserts that x is not nil and that the value stored in x is of type T. The notation x.(T) is called a type assertion.

    If the type assertion holds, the value of the expression is the value stored in x and its type is T. If the type assertion is false, a run-time panic occurs. In other words, even though the dynamic type of x is known only at run time, the type of x.(T) is known to be T in a correct program.

    var x interface{} = 7          // x has dynamic type int and value 7
    i := x.(int)                   // i has type int and value 7
    

    Type conversion

    A type conversion converts one (non-interface) type to another, e.g. a var x uint8 to and int64 like var id int64 = int64(x).

    Conversions are expressions of the form T(x) where T is a type and x is an expression that can be converted to type T.

  • Online socializing - let's try something else

    about 5 years ago

    I've been inactive from Facebook for over a year because I found a lot of the communications to be unproductive. They didn't foster any positive growth. I grew weary of the idea that being online meant my attention is available to any and all who saw that I was online. So I quit.

    The opportunity cost of having more mental real estate to pursue action on things I found more meaningful was social isolation. You realize who you want to keep in contact with and become more intentional about reaching out to select friends and family - and those relationships strengthen.

    My home on the internet is tilde.town, of which I am a volunteer admin, so I started to occupy the #tildetown IRC channel quite a lot in lieu of both social media and in-person social interaction. We chat and play games and run D&D adventures and water our ASCII plants.

    I got on Mastodon a little bit ago and attempted to see if I had any interest or potential in engaging in a Twitter-like platform. Answer is no.

    Then I discovered Scuttlebutt. It is a decentralized social network technology where all of the data is encrypted, owned by the users, and not private companies. I installed Patchwork, a super sleek, lightning fast native app to use Scuttlebutt. tilde.town's m455, resir014 and I experimented connecting to the diefrein.club pub server so that our data, written in local .ssb diary logs, could sync to each other's feeds.

    The experience functions much like meatspace interactions would; there is no "login" mechanism permitting or denying you from interaction. If you and a friend are on the same network and are following each other, your posts will sync up to each other's clients, and you two can then share / converse about the synced updates -- about how cool the visit to the winery was, or how hilarious you thought the ice cream flavor tasted. Also much like real life, you can't delete your posts. This form of "online" socializing is closely replicating the real thing, and avoiding the infamous tweet and delete. There are no advertisements. No content catered to you based on your historical perusing. No giving off the impression that everything is perfect and that anyone is better than anyone. It feels, well, real, which is something online socializing has been sorely lacking.

  • apex-go to aws-lambda-go

    about 5 years ago

    Say you have an AWS Lambda function that expects some manual JSON input from a CloudWatch rule scheduled event trigger, and you really, really, really want to use the tasty new Golang native runtime in a Lambda.

    Take the following Go code example using apex-go Node.js' shim to allow Go functions to run pre-January 15, 2018 (see README.md):

    package main
    
    import (
        "encoding/json"
        "strings"
    
        "github.com/apex/go-apex"
    )
    
    type message struct {
        CatName string `json:"cat_name"`
    }
    
    func main() {
        apex.HandleFunc(func(event json.RawMessage, ctx *apex.Context) (interface{}, error) {
            var m message
    
            if err := json.Unmarshal(event, &m); err != nil {
                return nil, err
            }
    
            m.Value = strings.ToUpper(m.Value)
    
            return m, nil
        })
    }
    

    Sparkly:

    package main
    
    import (
        "encoding/json"
        "strings"
    
        "github.com/aws/aws-lambda-go/lambda"
    )
    
    type message struct {
        CatName string `json:"cat_name"`
    }
    
    func main() {
        lambda.Start(handler)
    }
    
    func handler(event json.RawMessage) (interface{}, error) {
        var m message
    
        if err := json.Unmarshal(event, &m); err != nil {
            return nil, err
        }
    
        m.Value = strings.ToUpper(m.Value)
    
        return m, nil
    }
    

    A CloudWatchEvent is the outer structure of an event sent via CloudWatch Events:

    type CloudWatchEvent struct {
        Version    string          `json:"version"`
        ID         string          `json:"id"`
        DetailType string          `json:"detail-type"`
        Source     string          `json:"source"`
        AccountID  string          `json:"account"`
        Time       time.Time       `json:"time"`
        Region     string          `json:"region"`
        Resources  []string        `json:"resources"`
        Detail     json.RawMessage `json:"detail"`
    }
    

    The Detail struct field of type json.RawMessage is what will contain the JSON constant content:

    {
      "cat_name": "Yoshimi"
    }
    
  • Go: Slice initialization and JSON marshalling

    over 5 years ago
    package main
    
    import (
        "encoding/json"
        "fmt"
    )
    
    type Puzzle struct {
        Pieces []string
    }
    
    func main() {
        // var pieces []string is non-initialized
    
        pieces := make([]string, 0)
    
        if pieces == nil {
            fmt.Println("The pieces slice is empty/non-initialized/nil and will print null when marshaled as a struct variable into JSON.")
        } else {
            fmt.Println("The pieces slice is initialized/not-nil, and will print an empty set/array when marshaled as a struct variable into JSON.")
        }
    
        puzzleJSON, _ := json.Marshal(Puzzle{
            pieces,
        })
    
        fmt.Printf("\n%s\n", puzzleJSON)
    }
    

    Playground

  • FYI

    over 5 years ago

    The "download source" requirement of the Affero General Public License is based on the idea of a quine.

  • Log Levels

    over 5 years ago

    Trace - Only when I would be "tracing" the code and trying to find one part of a function specifically.

    Debug - Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).

    Info - Generally useful information to log (service start/stop, configuration assumptions, etc). Info I want to always have available but usually don't care about under normal circumstances. This is my out-of-the-box config level.

    Warn - Anything that can potentially cause application oddities, but for which I am automatically recovering. (Such as switching from a primary to backup server, retrying an operation, missing secondary data, etc.)

    Error - Any error which is fatal to the operation, but not the service or application (can't open a required file, missing data, etc.). These errors will force user (administrator, or direct user) intervention. These are usually reserved (in my apps) for incorrect connection strings, missing services, etc.

    Fatal - Any error that is forcing a shutdown of the service or application to prevent data loss (or further data loss). I reserve these only for the most heinous errors and situations where there is guaranteed to have been data corruption or loss.

  • Set Up Golang: OS X

    about 6 years ago

    Bring it in:

    $ brew update
    $ brew install golang

    Alternatively, Go (gigglez) get it at https://golang.org/dl/.

    Paths of #GreatImportance AKA Workspace:

    Pick a directory location for your sweet Go workspace -
    $HOME/go good enough for where you house your Go stuff? Cool.

    Add env vars to your shell config (~/.zshrc, ~/.bashrc etc):

    export GOPATH=$HOME/go
    export PATH=$PATH:$GOPATH/bin

    Go directory tree:

    $GOPATH/src: Source code
    $GOPATH/pkg: Package objects
    $GOPATH/bin: Home of the compiled binaries

    $ mkdir -p $GOPATH $GOPATH/src $GOPATH/pkg $GOPATH/bin

    Test drive (watch out)

    $ touch $GOPATH/src/main.go

    Add:

    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("WUSSUP WORLD")
    }
    

    Take a 5 minute break after that strenuous task.

    Come back refreshed and run $ go run wussup.go in your $GOPATH/src/ directory.

Next

Copyright © 2022 l0010o0001l / Tara Planas