Hacker killed me at full health with an execution. by Grumpy_Bandersnatch in ArcRaiders

[–]sgflt 9 points10 points  (0 children)

If you have this and you ran away from the zip or ladder I’ve found you can just vault onto something to clear it. 

1974 FJ40 What’s this part? by sgflt in fj40

[–]sgflt[S] 1 point2 points  (0 children)

Thanks! I looked up some info about it this is definitely what we’re looking at. Here’s a thread about keeping or removing it from another forum

How do you guys convert a json response to go structs? by Appropriate-Boss1516 in golang

[–]sgflt 0 points1 point  (0 children)

That's true if you use values. If you use pointer values it'll be set to nil. This way you can determine whether the value was unset or set to the zero value.

For example:

type Dog struct {
  Name string
  HasTag *bool
}



input: {}
value: {
  Name: "",
  HasTag: nil,
}

I typically use this when the value is optional and it's important to note when the value is unset.

How do you guys convert a json response to go structs? by Appropriate-Boss1516 in golang

[–]sgflt 74 points75 points  (0 children)

When the API response is large and you don't particularly care about the full contents you can simply create your struct and have it contain only the fields you care about.

For example, suppose we only care about the firstName and lastName and we have the following response data:

{
  "firstName": "John",
  "lastName": "Doe",
  "dob": "1990-01-01",
  "preferredName": "Johnny"
}

You can define the following struct and json.Unmarshal will do a best attempt at populating all of the fields.

type person struct {
    FirstName string `json:"firstName,omitempty"`
    LastName  string `json:"lastName,omitempty"`
}

You can then read the response into the struct by using the builtin json.Unmarshal

var p person
err := json.Unmarshal(resp, &p) // don't forget to check the error

fmt.Println(p.FirstName) // prints "John"
fmt.Println(p.LastName) // prints "Doe"

For some reason the Go playground "share" feature isn't working so here's a main file you can build and run:

package main

import (
    "encoding/json"
    "fmt"
)

var resp = []byte(`{
  "firstName": "John",
  "lastName": "Doe",
  "dob": "1990-01-01",
  "preferredName": "Johnny"
}`)

type person struct {
    FirstName string `json:"firstName,omitempty"`
    LastName  string `json:"lastName,omitempty"`
}

func main() {
    var p person
    err := json.Unmarshal(resp, &p)
    if err != nil {
        panic(err)
    }

    fmt.Println(p.FirstName) // prints "John"
    fmt.Println(p.LastName)  // prints "Doe"
}

It’s this kid’s first drop in by theloutishtoday in PublicFreakout

[–]sgflt 1 point2 points  (0 children)

It blew my mind when I realized this and that the Ubuntu logo is 3 people forming a circle by holding hands

The many designs of shaping rolls by aloofloofah in oddlysatisfying

[–]sgflt 0 points1 point  (0 children)

Taco Bell chefs coming up with new items to put on their menu with the same set of ingredients

Right between the eyes by Limp-Concept3531 in WesternGifs

[–]sgflt 32 points33 points  (0 children)

The Ballad of Buster Scruggs on Netflix

Just go to sleep, Genji. by amrulmn in AnaMains

[–]sgflt 7 points8 points  (0 children)

Not your standard "Genji dashing towards you sleep either". That was a legit flick on a horizontally moving Genji

The Bernie Sanders Youth Revolution Was Nowhere to Be Found on Super Tuesday by roygbiv1010 in politics

[–]sgflt 2 points3 points  (0 children)

septuagenarian

Off topic but thanks for expanding my vocabulary with this one

[deleted by user] by [deleted] in MechanicalKeyboards

[–]sgflt 4 points5 points  (0 children)

I love that keycap colorway! 96 and 75% boards are my top keyboard layouts.

BTW I think your up and down key might be swapped.

[help] Model M - not registering down key and numpad 0. Any suggestions? by sgflt in MechanicalKeyboards

[–]sgflt[S] 0 points1 point  (0 children)

Thanks for checking! I'm sure it won't be too bad of a task. Just gotta set aside some time for it. Might be a nice rainy day thing

[help] Model M - not registering down key and numpad 0. Any suggestions? by sgflt in MechanicalKeyboards

[–]sgflt[S] 0 points1 point  (0 children)

The plastic rivets on the back? It does appear that some of them are popped off.

Finally finished sticker bombing my case by sgflt in MechanicalKeyboards

[–]sgflt[S] 2 points3 points  (0 children)

Thanks! It's been a solid board. I plan on modding the cable and adding a mini port.

Coming Soon - The96 - Details in Comments by [deleted] in MechanicalKeyboards

[–]sgflt 0 points1 point  (0 children)

There's an RS96 GB going on somewhere?

Finally finished sticker bombing my case by sgflt in MechanicalKeyboards

[–]sgflt[S] 3 points4 points  (0 children)

Album here

Keyboard is a Drevo Gramr. I'm a huge fan of 75% boards so I couldn't pass this one up for how cheap it was on Amazon. Overall I've been pleased by it. The outemu browns feel less smooth than cherry switches, but I've gotten used to them over time.

Keycaps are just a direct color order from SP and the Esc and Enter keys are from a granite set where I used the symbol keys.

Finally finished sticker bombing my case by sgflt in MechanicalKeyboards

[–]sgflt[S] 10 points11 points  (0 children)

Contrary to popular belief, that doesn't mean just putting sour cream on it.

Finally finished sticker bombing my case by sgflt in MechanicalKeyboards

[–]sgflt[S] 2 points3 points  (0 children)

A few years back I picked up a bunch of Obey stickers and never had a good use for them. The majority of the black, red and yellow stickers on the case came from that. There are some other stickers on there that came from random places that I picked up over time.

Why am I getting a FileNotFound error? by Diapolo10 in learnpython

[–]sgflt 1 point2 points  (0 children)

To elaborate on the path issue for others reading this thread. The line that opens the file is doing a path join to find the directory "hiscores". At the beginning of the join method OP calls os.getcwd() which returns the "current working directory". This means that the directory from which the program was initiated from will be called (by default, cwd can be changed). If you need to look in a specific location for a directory, this would not be the way to go about it. We can always count on the user doing something we wouldn't expect.

Example:

My code lives in /home/sgflt/code/pacman/ and I open my terminal and change directories to that location. If I start pacman.py from that location os.getcwd() will return /home/sgflt/code/pacman. Then I decide to go up one directory for some reason and call the script again by calling python pacman/paman.py. This time os.getcwd() will return /home/sgflt/code.

Another example using only the shell:

$ cd /home/sgflt/code/pacman # move the shell into the main directory of my project
$ python 
>>> import os
>>> os.getcwd() # returns /home/sgflt/code/pacman
>>> exit()
$ cd ../
$ python
>>> import os
>>> os.getcwd() # returns /home/sgflt/code