programming.dev

9,496 readers
328 users here now

Welcome Programmers!

programming.dev is a collection of programming communities and other topics relevant to software engineers, hackers, roboticists, hardware and software enthusiasts, and more.

The site is primarily english with some communities in other languages. We are connected to many other sites using the activitypub protocol that you can view posts from in the "all" tab while the "local" tab shows posts on our site.


🔗 Site with links to all relevant programming.dev sites

🟩 Not a fan of the default UI? We have alternate frontends we host that you can view the same content from

ℹ️ We have a wiki site that communities can host documents on


⚖️ All users are expected to follow our Code of Conduct and the other various documents on our legal site

❤️ The site is run by a team of volunteers. If youre interested in donating to help fund things such as server costs you can do so here

💬 We have a microblog site aimed towards programmers available at https://bytes.programming.dev

🛠️ We have a forgejo instance for hosting git repositories relating to our site and the fediverse. If you have a project that relates and follows our Code of Conduct feel free to host it there and if you have ideas for things to improve our sites feel free to create issues in the relevant repositories. To go along with the instance we also have a site for sharing small code snippets that might be too small for their own repository.

🌲 We have a discord server and a matrix space for chatting with other members of the community. These are bridged to each other (so you can interact with people using matrix from discord and vice versa.

Fediseer


founded 2 years ago
ADMINS

Broken communities have been fixed, report any issues to ategon

1
 
 

2
3
10
submitted 16 hours ago* (last edited 16 hours ago) by [email protected] to c/linux4noobs
 
 

I've installed Samba on my Debian 12 home server but can't get it to start. I ran:

sudo systemctl start smbd
sudo systemctl status smbd

Here is the output:

   Duration: 7h 25min 18.079s
  Condition: start condition failed at Fri 2025-02-14 17:13:11 EST; 14min ago
       Docs: man:smbd(8)
             man:samba(7)
             man:smb.conf(5)
    Process: 598599 ExecCondition=/usr/share/samba/is-configured smb (code=exited, status=1/FAILURE)
        CPU: 1ms
Feb 14 17:13:11 harvee systemd[1]: Starting smbd.service - Samba SMB Daemon...
Feb 14 17:13:11 harvee systemd[1]: smbd.service: Skipped due to 'exec-condition'.
Feb 14 17:13:11 harvee systemd[1]: Condition check resulted in smbd.service - Samba SMB Daemon being skipped.

The install also doesn't seem to have created a samba configuration directory in /etc or a log in /var/log

I'm stumped. Googling turns up a lot of people accidentally checking the status of 'samba' instead of 'smbd', but I'm not finding much on this issue. What am I doing wrong?

4
5
6
7
 
 
8
9
 
 

cross-posted from: https://lemmy.ml/post/26048405

Because, we have here something called "Swiss Qr Bill" (standardized e-bill with Qr code) and some shops send you the bill via email. Would be nice, if i could just tap the qr-image and open with app.

10
11
12
 
 
13
 
 

Thank you for git - a lovely version control system https://git-scm.com

#ilovefsday #ilovefs @git @fsfe @torvalds

14
15
 
 

Learning by doing is hard to beat when it comes to building software.

I am starting a home lab to have a safe environment to try things out. Any ideas on what I could run that is completely useless but fun to set up?

@learn_programming
@homelabs

16
 
 

Workers at RDU1 and other facilities told CNBC that Amazon is increasingly using digital tools to deter employees from unionizing. That includes messaging through the company’s app and workstation computers. There’s also automated software and handheld package scanners used to track employee performance inside the warehouse, so the company knows when staffers are working or doing something else.

“You cannot get away from the anti-union propaganda or being surveilled, because when you walk into work they have cameras all over the building,” said Medelius-Marsano, who is an organizer with CAUSE. “You can’t get into work without scanning a badge or logging into a machine. That’s how they track you.”

17
 
 

Back in November, we broke the news that Meta — owner of Facebook, Instagram, and WhatsApp, with billions of users accounting for 10% of all fixed and 22% of all mobile traffic — was close to announcing work on a major new, $10 billion+ subsea cable project to connect up the globe. The aim was to give Meta more control over how it runs its own services.

18
19
9
submitted 17 hours ago* (last edited 3 hours ago) by [email protected] to c/haskell
 
 

I consider myself to be learning haskell. I am proficient enough to solve Advent of Code and do some small projects using it. I love doing it but I always feel like there's more to it. Apparently there is: this blog post from Reasonably Polymorphic caught me, I was probably exactly the intended audience.

What's in the blog post?

They visualize the Builder Pattern, where an Object is created through repeated mutation, which, when transferred to Haskell, should be replaced by creating objects through Monoids and the corresponding Semigroup function <>.

I parse a programming language using parsec and I did exactly what was proposed to enhance my structure creation.

Before, my code was this

Old Code

data StructStatement = Variable VariableName VariableType
        | Function Function.Function

data Struct = Struct 
        { name :: String
        , variables :: [(VariableName, VariableType)]
        , functions :: [Function]
        }
        deriving (Show)

addVariable :: Struct -> VariableName -> VariableType -> Struct
addVariable (Struct sn vs fs) n t = Struct sn ((n, t): vs) fs

addFunction :: Struct -> Function -> Struct
addFunction (Struct sn vs fs) f = Struct sn vs (f:fs)

accumulateStruct :: Struct -> StructStatement -> Struct
accumulateStruct s (Variable n t) = addVariable s n t
accumulateStruct s (Function f)   = addFunction s f

Then using a fold over Struct _ [] [] (which is basically mempty I just realized) would get me the complete struct. It is kind of ugly:

foldl accumulateStruct (Struct structIdentifier [] []) <$!> braces (many structMember)

Now my code is this

New Code

data Struct = Struct
        { name :: String
        , body :: StructBody
        }
        deriving (Show)

data StructBody = StructBody
        { variables :: [(VariableName, VariableType)]
        , functions :: [Function]
        }
        deriving stock (Generic, Show)
        deriving (Semigroup, Monoid) via Generically StructBody

Which shorter and easier to use, the entire construction only looks like this now:

mconcat <$!> UbcLanguage.braces (many structMember)

I love the new construction method using Semigroup and Monoid. However, I don't understand them in depth anymore. I have written my own instance of Semigroup and Monoid, and I assume these deriving clauses do something similar.

Handwritten Semigroup instance

instance Semigroup StructBody where
  (<>) s1 s2 = StructBody
        { variables = variables s1 <> variables s2
        , functions = functions s1 <> functions s2
        }

Monoid instance is trivial then, just default all the values to mempty.

I also have a dump of the generated class instances using -ddump-deriv -dsuppress-all:

Generated instances

instance Semigroup StructBody where
  (<>) :: StructBody -> StructBody -> StructBody
  sconcat :: NonEmpty StructBody -> StructBody
  stimes ::
    forall (b_a87f :: *). Integral b_a87f =>
                          b_a87f -> StructBody -> StructBody
  (<>)
    = coerce
        @(Generically StructBody
          -> Generically StructBody -> Generically StructBody)
        @(StructBody -> StructBody -> StructBody)
        ((<>) @(Generically StructBody))
  sconcat
    = coerce
        @(NonEmpty (Generically StructBody) -> Generically StructBody)
        @(NonEmpty StructBody -> StructBody)
        (sconcat @(Generically StructBody))
  stimes
    = coerce
        @(b_a87f -> Generically StructBody -> Generically StructBody)
        @(b_a87f -> StructBody -> StructBody)
        (stimes @(Generically StructBody))

instance Monoid StructBody where
  mempty :: StructBody
  mappend :: StructBody -> StructBody -> StructBody
  mconcat :: [StructBody] -> StructBody
  mempty
    = coerce
        @(Generically StructBody) @StructBody
        (mempty @(Generically StructBody))
  mappend
    = coerce
        @(Generically StructBody
          -> Generically StructBody -> Generically StructBody)
        @(StructBody -> StructBody -> StructBody)
        (mappend @(Generically StructBody))
  mconcat
    = coerce
        @([Generically StructBody] -> Generically StructBody)
        @([StructBody] -> StructBody) (mconcat @(Generically StructBody))

In the documentation it says that there is an instance (Generic a, Monoid (Rep a ())) => Monoid (Generically a) which is defined exactly like the generated instance ghc dumped (source) which uses the Monoid of (Rep a ()) which isn't defined anywhere.

Where does the monoid come from? This is the generated type Rep

Generated

Derived type family instances:
  type Rep StructBody = D1
                          ('MetaData "StructBody" "Ubc.Parse.Syntax.Struct" "main" 'False)
                          (C1
                             ('MetaCons "StructBody" 'PrefixI 'True)
                             (S1
                                ('MetaSel
                                   ('Just "variables")
                                   'NoSourceUnpackedness
                                   'NoSourceStrictness
                                   'DecidedLazy)
                                (Rec0 [(VariableName, VariableType)])
                              :*: S1
                                    ('MetaSel
                                       ('Just "functions")
                                       'NoSourceUnpackedness
                                       'NoSourceStrictness
                                       'DecidedLazy)
                                    (Rec0 [Function])))

but I cannot find a Monoid instance. Do you know where I could learn about this?

Thank you for your time and attention

Edit: fixed a problem with a deriving clause, added a missing code block

20
21
22
 
 

cross-posted from: https://ponder.cat/post/1631485

Open source software projects are frequently enmeshed with the interests of corporations. We should update mental models of who works on open source accordingly, and build or modify power structures to be more resilient to corporate capture.

23
24
 
 
25
 
 
view more: next ›