xtapa

joined 2 years ago
[–] xtapa@discuss.tchncs.de 1 points 2 months ago (2 children)

Well, thats a lot to concern, and some points, I can probably not check in the nearer future (like the router beeing my own and not my ISPs. I am bound to the Router by contract. But I will keep that in mind. This made my "look into" list a lot longer :D

[–] xtapa@discuss.tchncs.de 2 points 2 months ago

Ah, thanks for the clarification!

[–] xtapa@discuss.tchncs.de 4 points 2 months ago (3 children)

I've got my hands on an older Zotac nano that, according to the specs, has idle consumption of 6W. I think thats as good as it gets for a decent budget.

[–] xtapa@discuss.tchncs.de 1 points 2 months ago (2 children)

So uploads go via nc and samba distributes stuff back to the personal devices? Or what does samba actually do in this case?

[–] xtapa@discuss.tchncs.de 9 points 4 months ago

Papers please should be playable with one hand only and is great at burning time

[–] xtapa@discuss.tchncs.de 4 points 4 months ago (2 children)

Can you use it on colored clothes? Borax acts as bleach so I'm a bit skeptical.

[–] xtapa@discuss.tchncs.de 4 points 4 months ago

Looks great, thanks!

[–] xtapa@discuss.tchncs.de 21 points 4 months ago (4 children)

I think this level of derailing in a post about trains is irresponsible.

[–] xtapa@discuss.tchncs.de 19 points 4 months ago (2 children)

Tut mir leid, Japan-Fanboys und -Girls.

Tabi (jap. 足袋) sind eine Art von knöchelhohen japanischen Socken mit abgeteiltem großem Zeh.

Sie werden üblicherweise zu Zōri oder Geta (beides Sandalen) getragen.

Quelle: Wikipedia

Tabi (Socken) 足袋 Traditionelle Socken bestehen meist aus weißem, festem Baumwollstoff mit abgeteiltem großen Zeh.

Zôri 草履 (Sandalen) Zôri-Sandalen gehören zum Kimono

Quelle: Deutsch-Japanische Gesellschaft München

Es SIND Socken in Sandalen.

[–] xtapa@discuss.tchncs.de 2 points 4 months ago

Hersteller sprechen von Temposchwelle.

[–] xtapa@discuss.tchncs.de 2 points 5 months ago* (last edited 5 months ago)

I personally try to avoid deeply nested if/else. Or else in general, because I think it makes code more readable. Especially when one of the branches is just an exit condition.

if exitCondition {
    return false
}
// long ass code execution

is way more readable than

if !exitCondition {
    // long ass code execution
} else {
   return false
}

In a loop, you can just return the value instead of passing it to a "retVal" variable.

With those in mind, you could refactor HasPermissions to

func (r *RBAC) HasPermission(assignedRoles []string, requiredPermission string, visited map[string]bool) bool {
	for _, assigned := range assignedRoles {
		if visited[assigned] {
			continue
		}
		role, ok := r.Roles[assigned]
		if !ok {
			//role does not exist, so skip it
			continue
		}
		for _, permission := range role.Permissions {
			if permission.String() == requiredPermission {
				//Permission has been found! Set permitted to true and bust out of the loop
				return true
			}
		}
		//check inherited roles
		if permitted := r.HasPermission(role.Inherits, requiredPermission, visited); permitted {
			return true
		}
	}
	return false
}

The same could be applied to LoadJSONFile and I think that really would approve the readability and maintainability of your code.

edit: This refactor is not tested

view more: ‹ prev next ›