In GAP, how to to construct all non-split extensions? It is well explained how to construct split extensions (semidirect products) in the GAP manual; however, for the non-split extensions, I couldn't find any method or a source of code implemented to generate non-split extensions of a finite group. GAP has GModuleByMats and Extensions, I think I am failing to understand this part to find all extensions of a group. I would be glad if someone could explain how to do that over some examples.
 A: I shall assume that you know the basic theory of extensions, and why it is mostly sufficient to consider cases in which the normal subgroup is elementary abelian -- this being the case I'll describe.
So let's assume that $G$ is a finite group (in my example $S_6$) and $N$ an elementary abelian group of order $p^k$ (in my example $3^6$).
We start by finding the ways in which $G$ can act linearly on $N$. If we further restrict to cases where $N$ is minimal, these arise from irreducible representations. Lets classify these:
gap> reps:=IrreducibleRepresentations(G,GF(3));;
gap> List(reps,x->DimensionOfMatrixGroup(Range(x)));
[ 1, 1, 4, 4, 6, 9, 9 ]

The degree of the 5th dimension is 6, lets take this and get matrices for the group generators:
gap> mats:=List(GeneratorsOfGroup(G),x->Image(reps[5],x));
[ < immutable compressed matrix 6x6 over GF(3) >,
  < immutable compressed matrix 6x6 over GF(3) > ]

Construct a module from the matrices:
gap> mo:=GModuleByMats(mats,GF(3));
rec( IsOverFiniteField := true, dimension := 6, field := GF(3),
  generators := [ < immutable compressed matrix 6x6 over GF(3) >,
      < immutable compressed matrix 6x6 over GF(3) > ], isMTXModule := true )

Now we can use the operation TwoCohomologyGeneric. (There also is TwoCohomology and Extensions, but these only work for solvable groups.) It returns a complicated record, whose entry cohomology contains representatives for the second cohomology group.
gap> co:=TwoCohomologyGeneric(G,mo);;co.cohomology;
[ < immutable compressed vector length 126 over GF(3) > ]

So here the 2-cohomology has dimension 1 over $\mathbb{F}_3$, so we get three nonequivalent extensions. These can be constructed (as finitely presented) using the command FpGroupCocycle which gets the cohomology record and the cocycle as arguments:
gap> e1:=FpGroupCocycle(co,0*co.cohomology[1],true);; # split extensions
gap> e2:=FpGroupCocycle(co,co.cohomology[1],true);;
gap> e3:=FpGroupCocycle(co,-co.cohomology[1],true);;

The extra argument true triggers the computation of a decent faithful permutation representation. Working in this one is much better:
gap> p1:=Image(IsomorphismPermGroup(e1),e1);
<permutation group with 11 generators>
gap> p2:=Image(IsomorphismPermGroup(e2),e2);
<permutation group with 11 generators>
gap> p3:=Image(IsomorphismPermGroup(e3),e3);
<permutation group with 11 generators>

We thus have classified all extensions with an irreducible module of order $3^6$. It turns out in this example that the groups p2 and p3 are isomorphic, so there are two nonisomorphic extensions.
