design – How can I implement an invite system between users in an app?

I’m currently making a web app using flutter and firebase. To make this short and sweet, I want users in my app to be able to form groups. The group leader will pick base “settings” for the group and the users will add their own settings. Example:
Example

So in the example above, the group leader has formed a group called “Ice cream group” and has chosen its base settings with every user in the group having its own settings. To form this group, the group leader would need to have the usernames of the users they want to invite and have it sent to the users. Within the invite are the group settings. The users will have the opportunity to add their settings and accept the invite. So in the end everyone in the group will be using the settings of the group and their own.

So sequentially this would happen.

  1. Group Leader creates group settings
  2. Group Leader makes its own settings.
  3. Group Leader has the ids of users that they want to invite.
  4. Group Leader sends the invites.
  5. Users receive the invite with the base settings. They can accept or reject the invite. Before they accept, they would have to add their own settings.
  6. Once every user that the group leader invites accepts the invitation, then the group is formed.

For this project I’m using the flutter framework and firebase(nosql) for the back end. Since firestore uses nosql my guess to the solution would be a document that would track the status of the invites. And depending on the status the group would be formed.

Currently my structure for the user looks something like this:
User Document

I was thinking about adding an invite field to the user and then adding a invite document that would hold the settings of the group, the status of the invite, and the user settings…

I have some ideas on what I think should done but I wanted to come here first to see if anyone had any suggestion before I try and tackle it. If anyone has any pseudo code, information, or can direct me to a place where I should ask this question, I’d appreciate it. Thanks!

windows – How to aid (do the testing for) a developer who doesn’t own a touchpad to implement Precision bindings?

First of all, I consider myself to be a power user, but wouldn’t dare to call myself a software designer.

I opened a feature request to add support for Windows’ Precision Touchpad binding in the hotkey section of MPC-BE. They already have a huge hotkey support, including support for assigning actions to click and gestures of all mouse buttons.

The dev’s response is that they don’t own any device with a touchpad, thus they can’t develop for it. Now, I would be very much willing to do all the necessary testing and provide detailed info on what every gesture do and so on.

So here’s my question: how I, as someone who doesn’t develop, but can reasonably understand code etc, can do all testing steps needed and provide the necessary “calls” the software should make in order to use Precision Touchpads? Are there any manuals or tutorials on developing for these which would help bypass the present issue? May you point me to them?

postgresql – How to implement what “psql > d table1” command does, manually in C?

If you want to find out what the psql meta commands do, start psql with the -E or --echo-hidden parameter:

psql --echo-hidden
postgres=# d table1
********* QUERY **********
SELECT c.oid,
  n.nspname,
  c.relname
FROM pg_catalog.pg_class c
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname OPERATOR(pg_catalog.~) '^(table1)$' COLLATE pg_catalog.default
  AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 2, 3;
**************************

********* QUERY **********
SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, false AS relhasoids, c.relispartition, '', c.reltablespace, CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, c.relpersistence, c.relreplident, am.amname
FROM pg_catalog.pg_class c
 LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)
LEFT JOIN pg_catalog.pg_am am ON (c.relam = am.oid)
WHERE c.oid = '22298017';
**************************

********* QUERY **********
SELECT a.attname,
  pg_catalog.format_type(a.atttypid, a.atttypmod),
  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid, true) for 128)
   FROM pg_catalog.pg_attrdef d
   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),
  a.attnotnull,
  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t
   WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation,
  a.attidentity,
  a.attgenerated
FROM pg_catalog.pg_attribute a
WHERE a.attrelid = '22298017' AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum;
**************************

********* QUERY **********
SELECT pol.polname, pol.polpermissive,
  CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,
  pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),
  pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),
  CASE pol.polcmd
    WHEN 'r' THEN 'SELECT'
    WHEN 'a' THEN 'INSERT'
    WHEN 'w' THEN 'UPDATE'
    WHEN 'd' THEN 'DELETE'
    END AS cmd
FROM pg_catalog.pg_policy pol
WHERE pol.polrelid = '22298017' ORDER BY 1;
**************************

********* QUERY **********
SELECT oid, stxrelid::pg_catalog.regclass, stxnamespace::pg_catalog.regnamespace AS nsp, stxname,
  (SELECT pg_catalog.string_agg(pg_catalog.quote_ident(attname),', ')
   FROM pg_catalog.unnest(stxkeys) s(attnum)
   JOIN pg_catalog.pg_attribute a ON (stxrelid = a.attrelid AND
        a.attnum = s.attnum AND NOT attisdropped)) AS columns,
  'd' = any(stxkind) AS ndist_enabled,
  'f' = any(stxkind) AS deps_enabled,
  'm' = any(stxkind) AS mcv_enabled
FROM pg_catalog.pg_statistic_ext stat WHERE stxrelid = '22298017'
ORDER BY 1;
**************************

********* QUERY **********
SELECT pubname
FROM pg_catalog.pg_publication p
JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid
WHERE pr.prrelid = '22298017'
UNION ALL
SELECT pubname
FROM pg_catalog.pg_publication p
WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('22298017')
ORDER BY 1;
**************************

********* QUERY **********
SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhparent AND i.inhrelid = '22298017' AND c.relkind != 'p' ORDER BY inhseqno;
**************************

********* QUERY **********
SELECT c.oid::pg_catalog.regclass,       pg_catalog.pg_get_expr(c.relpartbound, c.oid),       c.relkind FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '22298017' ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',          c.oid::pg_catalog.regclass::pg_catalog.text;
**************************

You can extract those queries and run them from within your C/C++ code.

coding style – Is this enum/trait a good way to implement polymorphic design in Rust?

this is my first post on here, and I’m wondering about a good rust implementation with traits on enum types. I want to know if using an enum w/ a trait as a generator of different code is viable like the one below? Also a couple of things I’m curious about is if there is an overhead with the match statement? Would implementing separate structs be faster?

struct GeneralCell {
    repr: char,
    position: Position,
    cell_type: Cell,
}

trait InitializeCells {
    fn new(&self, position: Position) -> GeneralCell;
}

pub enum Cell {
    Hall,
    Filled,
    Empty,
}

impl InitializeCells for Cell {
    fn new(&self, position: Position) -> GeneralCell {
        match self {
            Cell::Hall => GeneralCell {
                repr: 'H',
                position,
                cell_type: Cell::Hall,
            },
            Cell::Empty => GeneralCell {
                repr: 'E',
                position,
                cell_type: Cell::Empty,
            },
            Cell::Filled => GeneralCell {
                repr: 'F',
                position,
                cell_type: Cell::Filled,
            },
        }
    }
}

networking – Creating a virtual network adapter on Windows to implement VPN

I would like to implement a custom VPN client on Windows 10 and therefore I am looking for examples how to create a virtual network adapter where I can grab all IP packets for a dedicated subnet.

I was also taking a look at OpenVPN and SoftEther but it looks like that the source code is no longer supported with Visual Studio 2019.

godot – How should I implement stair climbing?

enter image description hereIm using raycast to detect if a block is to my side. I can use raycast to see if i need to climb stairs but the transition is bad. I immediately reach the top of the stairs when trying to go on them.

extends KinematicBody2D

signal collected

const ACCELERATION = 200
const GRAVITY = 10
var JUMP = -400
var SPACE_JUMP = JUMP * 1.25
var LEDGE_JUMP = JUMP * .75

var state = "idle"
var prev_state = "idle"
var velocity = Vector2.ZERO
var acceleration = Vector2(200,0)
var deceleration = Vector2(500,0)
var terminal_velocity = Vector2(200,0)
onready var collisionShape2D = $CollisionShape2D
var gravity = Vector2(0,10)
var jump = -400
var timer = 0
var facing = 1
var threshold = .5

var floor_normal = Vector2(0,-1)

func _ready():
    collisionShape2D.shape.radius = 28
    #collisionShape2D.shape.extents = Vector2(31.9,31.9)

func _physics_process(delta):
    timer += delta
    var ax = Input.get_joy_axis(0,0)
    var ay = Input.get_joy_axis(0,1)
    var space_rid = get_world_2d().space
    var space_state = Physics2DServer.space_get_direct_state(space_rid)
    var ray_down = space_state.intersect_ray(global_position, global_position + Vector2(0,32),(self))
    var ray_side1 = space_state.intersect_ray(global_position, global_position + Vector2(facing*32,-16),(self))
    var ray_side2 = space_state.intersect_ray(global_position, global_position + Vector2(facing*32,0),(self))
    var ray_up = space_state.intersect_ray(global_position + Vector2(facing*32,-32), global_position + Vector2(facing*32,-64))
    
    if ay > .25 and state == "ledge_grab":
        state = "jump"
        gravity.y = GRAVITY
    elif ay > .25 and state == "idle":
        state = "ball"
        collisionShape2D.shape.radius = 14
    elif ay < -.25 and state == "ball" and not ray_up.has("collider"):
        state = "idle"
        collisionShape2D.shape.radius = 28
    if is_on_floor():
        if state == "jump": state = "idle"
        acceleration.x = ACCELERATION
    if abs(ax) < .1: 
        ax = 0 
        if state == "moving":
            state = "idle"
    else: 
        if state == "idle":
            state = "moving"
    if ax < -threshold:
        facing = -1
        velocity.x -= acceleration.x * delta
    elif ax > threshold:
        facing = 1
        velocity.x += acceleration.x * delta
    else:
        velocity.x += -sign(velocity.x) * deceleration.x * delta
        
    if abs(velocity.x) < 1: velocity.x = 0
    velocity.x = clamp(velocity.x,-terminal_velocity.x,terminal_velocity.x)
    velocity += gravity
    
    if not ray_up.has("collider") and ray_side1.has("collider") and state != "ledge_grab" and state != "jump":
        state = "ledge_grab"
        position.y = ray_side1.metadata.y * 32 + 32
        gravity = Vector2.ZERO
        velocity = Vector2.ZERO
        position.x -= facing
    if not ray_up.has("collider") and ray_side2.has("collider") and ray_down.has("collider"):
        
        #What should i do here?
        position.y -= 32
        position.x += facing * 24
    if state == "idle" or state == "moving" or state == "jump" or state == "ball":
        velocity = move_and_slide(velocity,floor_normal)
        
    var collision = move_and_collide(velocity * delta,true,true,true)
    if collision:
        if collision.collider.name == "StaticBody2D":
            jump = SPACE_JUMP
            collision.collider.free()
    print(state)
            
    
    
func jump():
    if is_on_floor() and state != "ball":
        velocity.y = jump
        acceleration.x += -jump
        state = "jump"
    if state == "ledge_grab":
        gravity.y = GRAVITY
        velocity.y = LEDGE_JUMP
        acceleration.x += -jump
        state = "jump"
func _unhandled_input(event):
    if event is InputEventJoypadButton:
        if event.pressed and event.button_index == 0:
            jump()

usability – Why do nearly all the social media platforms have nearly the same layout for “user’s post” and how can I implement similar layout in my design?

So I am making an art sharing app ( image sharing ) and have noticed that nearly all the existing social media platforms have similar layout for user’s post.

e.g.

  1. Facebook

enter image description here

  1. Instagram

enter image description here

  1. Twitter

enter image description here

Now as it is quite clear from the above pictures that they follow a similar layout which goes something like this :

  1. Profile photo and user name, with follow button if user isn’t following that user.
  2. The caption, description, tweet etc.
  3. Images ( if any ) ( in case of instagram, point 2 and 3 are interchanged ).
  4. Then comes the interaction button.

My question is why all of them have Poster’s name and profile photo ( optional ) above the content of the post and not below it ? What is wrong with having the poster’s name and pic below the main content ? And also, in most of the cases, description is above the image ( if any ) ? Is it because our eyes start reading from top to bottom ?

If so, how can I improve the layout of my app which is just the opposite and quite frankly looks not that good.

Layout of my app :

enter image description here

Red area is for the image ( which is the main content of my app ), I want at least 70% of the users screen to show the image, also I don’t want to overlay any buttons or text on the image cause it can hide important details of the picture. What can I do make it look more good and at the same time easy to use ?

agile – should I design a simplified version of a use case and implement it, or should I stick to the exact use case while designing?

I know that user stories and use cases are written by a customer not the development team alone. And I know that on each iteration the development team picks a number of requested use cases and delivers them by the end of the sprint.

The question is: Should the requirements analysis and design phase on each iteration be aimed to target the exact given use case at the first place?

Let’s say that we, as the development team, are given a use case to develop like this:

” Jimmy, as the bank owner, should be able to see the charts showing how much profits has changed on each day during the last week.”

As a developer I feel more comfortable to first design and impalement a feature which helps the user to see information in textual form:

Jimmy, as the bank owner , should be able to see some texts showing how much profit has changed on each day during the last week

after I reach at the point where everything works, start to redesign and change the code so that charts are shown instead of textual info.

If it’s okay to first start by focusing on a simplified version of the actual requirement and then move toward the actual requirement gradually, what are those simplified intermediate outcomes called? should they be listed as backlogs?

Thanks in advance.

python – How to implement FizzBuzz with functions

I am new to coding and so I was trying out some common problems. After watching Tom Scott’s video on FizzBuzz, I tried implementing both techniques (if-else and adding strings) in python. Now I wanted to improve it further and I thought that instead of repeating some lines, I could define a function. However, that is running into some problems…

This was my code when adding strings:

i = 1
while i <= 100:
    text = ''
    if i % 3 == 0:
        text = text + 'Fizz'
    if i % 5 == 0:
        text = text + 'Buzz'
    if text == '':
        text = i
    print(text)
    i += 1

As you can see, I was repeating a line so I wanted to define a function:

i = 1
def Modulo_Check(x, y):
    if i % x == 0:
        text = text + y
while i <= 100:
    text = ''
    Modulo_Check(3, 'Fizz')
    Modulo_Check(5, 'Buzz')
    if text == '':
        text = i
    print(text)
    i += 1

I am getting an error:

UnboundLocalError: local variable text referenced before assignment

I think this is because the function is outside the while, while the text variable is inside. I tried fixing it by defining the function below the while function, but obviously that didn’t work. I also tried defining it inside the while function:

i = 1

while i <= 100:
    text = ''
    def Modulo_Check(x, y):
        if i % x == 0:
            text = text + y
    Modulo_Check(3, 'Fizz')
    Modulo_Check(5, 'Buzz')
    if text == '':
        text = i
    print(text)
    i += 1

However, I am still stumped. It still shows the same error message even though the variable text has been defined already. How should I proceed? I am using Python 3.8.2 if that matters.