Archives par mot-clé : code

Flutter – Scrollable dialog with Getx

To have a scrollable dialog with Getx, you have multiple possibilities.

1. With Get.dialog

Get.dialog(
  Container(
    width: double.maxFinite,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          Text("Description 1",
              style:
                  TextStyle(fontWeight: FontWeight.bold)),
          SizedBox(height: 8),
          Flexible(
            child: SingleChildScrollView(
              child: Text('Very, very large title',
                  textScaleFactor: 15),
            ),
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: Text("OK"),
          )
        ]),
  ),
);

2. With Get.defaultDialog

Get.defaultDialog(
  content: Flexible(
    child: SingleChildScrollView(
      child: Text('Very, very large title',
                  textScaleFactor: 15),
    ),
  ),
);

3. By combining Get.dialog and AlertDialog

Get.dialog(AlertDialog(
  content: Container(
    width: double.maxFinite,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          Text("Description 1",
              style:
                  TextStyle(fontWeight: FontWeight.bold)),
          SizedBox(height: 8),
          Flexible(
            child: SingleChildScrollView(
              child: Text('Very, very large title',
                  textScaleFactor: 15),
            ),
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: Text("OK"),
          )
        ]),
  ),
));

Monter en miroir un volume synology

But

Monter un volume, par exemple le /volume1 du synology, dans un répertoire de partage /volume1/volume1 afin de tout sauvegarder y compris les répertoires cachés ou cryptés.

Procédure

  • créez un répertoire partagé nommé volume1
  • connectez-vous en ssh
  • ajoutez un fichier S99MountBind.sh dans /usr/syno/etc.defaults/rc.d
  • le contenu du fichier:


#!/bin/sh

start()
{
/bin/mount -o bind /volume1 /volume1/volume1
}

stop()
{
/bin/umount /volume1/volume1
}

case "$1" in
start) start ;;
stop) stop ;;
*) ;;
esac

  • chmod 755 S99MountBind.sh
  • S99MountBind.sh start

voilà! Ca devrait même marcher au démarrage du nas…

Go get and Fork – script helper workaround

Why

If you write some Golang code, from my point of view, one of biggest pitfall of this language is dependency management.

At the beginning, get library directly from git repository seems a good idea, but between package rules, versions, your pull requests, it becomes a mess quickly.

Some sources on this problem:
Article: Forking Golang repositories on GitHub and managing the import path

StackOverflow : Using forked package import in Go

My workaround

Then, why not automate this procedure ?
In your .bashrc add:

function gofork() {
  if [ $# -ne 2 ] || [ -z "$1" ] || [ -z "$2" ]; then
    echo 'Usage: gofork yourFork originalModule'
    echo 'Example: golang github.com/YourName/go-contrib github.com/heirko/go-contrib'
    return
  fi
   echo "Go get fork $1 and replace $2 in GOPATH: $GOPATH"
   go get $1
   go get $2
   currentDir=$PWD
   cd $GOPATH/src/$1
   remote1=$(git config --get remote.origin.url)
   cd $GOPATH/src/$2
   remote2=$(git config --get remote.origin.url)
   cd $currentDir
   rm -rf $GOPATH/src/$2
   mv $GOPATH/src/$1 $GOPATH/src/$2
   cd $GOPATH/src/$2
   git remote add their $remote2
   echo Now in $GOPATH/src/$2 origin remote is $remote1
   echo And in $GOPATH/src/$2 their remote is $remote2
   cd $currentDir
}

export -f gofork

This command do

  • a ‘go get’ on source and fork repositories
  • extract remote urls
  • replace source code by fork
  • add source remote to your fork repository in case you want pull from source

You can call this script from command line or directly from a script like this:

gofork github.com/heralight/baloo gopkg.in/h2non/baloo.v2