grep: retain colors when piping

By default grep -color is not producing color symbols if it detects that the output is not a terminal.

grep -color=auto is doing the same, that is not producing color symbols if it detects that the output is not a terminal.

The solution is to use “grep -color=always“ in the place that need it.

Do not put it in an alias of grep as it would break some code somewhere else. Color symbols are strings like “ESC[35m” and they will be inserted in the text.

Portapack firmware with Search App and updated Freqman files (based on latest next )

  • I’ve build an up to date firmware with the last updates from next and the last version from search app and freqman enhancements.
  • The Search app is in the ‘receive’ menu
  • The documentation is here : https://github.com/GullCode/portapack-mayhem/wiki/Search
  • -Freqman now do understand freq files with that format:
    f=468000000 f=468000000,d=Single Freq f=468000000,m=AM,d=Single Freq AM f=468000000,m=NFM,d=Single Freq NFM f=468000000,m=WFM,d=Single Freq WFM f=468000000,m=AM,b=DSB,d=Single Freq AM DSB f=468000000,m=AM,b=USB,d=Single Freq AM USB f=468000000,m=AM,b=LSB,d=Single Freq AM LSB a=87000000,b=110000000 a=87000000,b=110000000,m=AM,s=100KHz,d=AM radio search a=87000000,b=110000000,m=AM,b=DSB,s=250KHz,d=AM radio search LSB a=87000000,b=110000000,m=WFM,b=16k,s=50KHz,d=WFM radio search s=50KHz r=430150000,t=430550000 r=430150000,t=430550000,d=HAM radio r=430150000,t=430550000,m=AM,b=DSB,d=HAM radio
  • The freqman GUI have note been improved and may show partial results on new formatted lines
  • Description of the fields:
    f=freq for one frequency or a=start_frequency,b=end_frequency for a range
    m=modulation
    b=bandwidth
    s=step
    d=description
  • All fields except ‘f=freq’ or ‘a=freqA,b=freqB’ are mandatory. If nothing specified actual value is used.
  • As a reminder :
    -Most of the time if the Search app is not working as you expected it’s coming from a SDCARD problem.
    -You need a SDCARD for the Search app to save settings between runs and between settings menu / main gui, and you need a SEARCH folder at the root of it.
    -Don’t forget to check that by default the ‘input: load’ fields in ‘search app -> params -> more ‘ are all checked.
    -You HAVE to click save in ordre to save the settings.

GitLab: WARNING: gl-sast-report.json: no matching files

When enabling SAST in a gitlab project you can have that kind of error at the tests part:

The yaml provided is not containing the needed part:

artifacts:
   name: sast
   paths:
     - gl-sast-report.json
   reports:
     sast: gl-sast-report.json
   when: always

Source:

https://forum.gitlab.com/t/uploading-artifacts-warning-gl-sast-report-json-no-matching-files-error-no-files-to-upload/60887/5

https://gitlab.com/gitlab-org/gitlab/-/issues/345696#note_737150614

Compare two json in shell

I did it using the JQ command line tool from https://stedolan.github.io/jq/

Exemple: list all json files from current directory and print the difference with updated jsons from updated/ directory

for user in  `ls updated-users`
do
    # print file name
    echo $user
    # simple 
    diff <(jq -S . users/$user) <(jq -S . updated-users/$user)
    # or full on one side and the diff on the other side
    # diff -y --left-column <(jq -S . users/$user) <(jq -S . updated-users/$user)
    # or full on one side and the diff on the other side, colored
    # diff -y --left-column --color  <(jq -S . users/$user) <(jq -S . updated-users/$user)
done

#shell #diff #json #script

Khelda II [KrampusHack 2021] Game Jam

I made a Zelda II alike world with a big map on top view and some dungeons in side view. Permanent world, only the monsters are reset between dungeons / starts.

The limit was way overdue before I could do all I wanted so I’m linking both version here, the entry for the compo and the updated / finalised one.

Compo rules: https://tins.amarillion.org/krampu21/rules/

Tins log : https://tins.amarillion.org/krampu21/log/entrant/4277

git repo: https://framagit.org/GullRaDriel/krampushack2021-kheldaii

Click here for full pack with datas, sources and binaries

Screens:

Gameplay demo : 

Khelda II gameplay demo

=============================================

How to play:

  • You are Kwink. You have to save princess Khelda which is kept prisonner by an Ogre
  • You directly start on the main map. Move around and kill some simple monsters to gain a bit of XP/Life before trying yourself at the dungeons.
  • Each dungeons is guarded by a lot of mobs. Killing them is up to you. Leveling up before being traped in a dungeon is recommended
  • Find all the 3 key fragments before going onto the last dungeon. Deliver princess Khelda by defeating the last mob

Keys:

  • Esc: quit
  • Arrow keys: move, go up/down or jump/crouch
  • CTRL/LeftMouseButton: attack
  • F1 -> F4t: change weapon (Wood stick, sword, magic bow, magic wand)
  • Key PAD PLUS: shield potion
  • Key PAD ENTER: health potion

Items to be collected:

  • shield (passive, always equiped once found)
  • sword of Khelda
  • magic ice wand
  • infinite arrow bow
  • health potion
  • shield potion

Obtain: the kiss of the princess one the Ogre is dead !

Tips:

  • Leveling up a bit on easy monsters before trying yourself to a dungeon
  • Wandering around and use the map find the sword, the magic wand, the arrow, the shield
  • Loot a bit of potions before entering the last dungeon

==============================================

Options:

  • configurable log level, example: ./KheldaII.exe -V DEBUG
  • cheat: editable player_state.json after first execution

==============================================

How to build: need gcc on linux and gcc + msys / cygwin on windows

mkdir -p KheldaII
mkdir -p KheldaII/LIB
mkdir -p KheldaII/Src/
cd KheldaII/LIB
git clone https://framagit.org/GullRaDriel/nilorea-library.git .
cd ../Src/
git clone https://framagit.org/GullRaDriel/krampushack2021-kheldaii.git
cd https://framagit.org/GullRaDriel/krampushack2021-kheldaii.git
make

GIT and BitBucket

Cloning a git repository from BitBucket can fail producing that kind of logs:

Clonage dans '.'...
remote: Counting objects: 7008, done.
remote: Compressing objects: 100% (5921/5921), done.
error: échec RPC ; curl 56 GnuTLS recv error (-110): La connexion TLS n’a pas été terminée correctement.
fetch-pack: unexpected disconnect while reading sideband packet
fatal: fin de fichier prématurée
fatal: Ă©chec de index-pack

Working solution was to force IPv4 with -4 option, like in the following example:

git clone -4 https://giturl.com/repo.git .

Adding proxy to MSYS2

If you ever need to use a proxy when updating / installing packages in msys2 you’ll have to set the following environnement variables, and put them i.e in your .bash_profile :

# .bash_profile example
# Note: username and password have to be url encoded in case they contain special chars
export http_proxy=http://USERNAME:PASSWORD@proxy:port
# or like this if not user/password required
# export http_proxy=http://proxy:port
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
# if you need a proxy ignore list
export no_proxy="localhost,127.0.0.1,localaddr,.yourlocaldomain.ext,.local"

MSYS2 ALLEGRO5 Setup

I’ve set up my last allegro 5 install + compilers in less than 15 minutes.

1) download and install msys2 ( https://www.msys2.org/ )

Now launch the msys2 terminal and copy pasta the followings:

#UPDATE MSYS2
pacman -Syu
#INSTALL GCC 32 & 64BITS
pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git subversion mercurial mingw-w64-i686-cmake mingw-w64-x86_64-cmake
#INSTALL ALLEGRO5 32 & 64BITS
pacman -Sy mingw32/mingw-w64-i686-allegro mingw64/mingw-w64-x86_64-allegro 
#INSTALL ALLEGRO5 64BITS DEPENDENCIES
pacman -Sy mingw-w64-i686-dumb mingw-w64-i686-flac mingw-w64-i686-opusfile mingw-w64-i686-freetype mingw-w64-i686-libjpeg-turbo mingw-w64-i686-libpng mingw-w64-i686-libvorbis mingw-w64-i686-libwebp mingw-w64-i686-openal mingw-w64-i686-physfs
#INSTALL ALLEGRO5 32BITS DEPENDENCIES
pacman -Sy mingw-w64-x86_64-dumb mingw-w64-x86_64-flac mingw-w64-x86_64-opusfile mingw-w64-x86_64-freetype mingw-w64-x86_64-libjpeg-turbo mingw-w64-x86_64-libpng mingw-w64-x86_64-libvorbis mingw-w64-x86_64-libwebp mingw-w64-x86_64-openal mingw-w64-x86_64-physfs

CYGWIN: list all process arguments

A few days ago I had to list the arguments for specific process.
While finding it using “ps -aef | grep ‘processname'” and getting the information is trivial under linux, it is not the case using cygwin, which is only reporting process name and pid when calling “ps”.

A lot of solutions involve installing cygwin packet, like pstree.

Another solution is to search the /proc/pid/cmdline files, like here:

grep -a /proc/*/cmdline | xargs -0
/proc/1990/cmdline:/bin/sh /usr/bin/startxwin
/proc/2016/cmdline:xinit /etc/X11/xinit/startxwinrc — /usr/bin/XWin :0 -multiwindow -auth /home/user/.serverauth.1990
/proc/2017/cmdline:/usr/bin/XWin :0 -multiwindow -auth /home/user/.serverauth.1990
/proc/2023/cmdline:/usr/bin/xwin-xdg-menu
/proc/2035/cmdline:dbus-launch –sh-syntax –exit-with-session
/proc/2036/cmdline:/usr/bin/dbus-daemon –fork –print-pid 5 –print-address 7 –session
/proc/2046/cmdline:/usr/libexec/gam_server
/proc/2512/cmdline:mintty
/proc/2513/cmdline:bash
/proc/3441/cmdline:grep –color -a /proc/1990/cmdline /proc/2016/cmdline /proc/2017/cmdline /proc/2023/cmdline /proc/2035/cmdline /proc/2036/cmdline /proc/2046/cmdline /proc/2512/cmdline /proc/2513/cmdline /proc/3441/cmdline /proc/self/cmdline
/proc/self/cmdline:grep –color -a /proc/1990/cmdline /proc/2016/cmdline /proc/2017/cmdline /proc/2023/cmdline /proc/2035/cmdline /proc/2036/cmdline /proc/2046/cmdline /proc/2512/cmdline /proc/2513/cmdline /proc/3441/cmdline /proc/self/cmdline

To restrain it to a particular process i.e XWin, excluding grep command:

grep -a “XWin” /proc/*/cmdline |xargs -0 |grep -v grep
/proc/2016/cmdline:xinit /etc/X11/xinit/startxwinrc — /usr/bin/XWin :0 -multiwindow -auth /home/user/.serverauth.1990
/proc/2017/cmdline:/usr/bin/XWin :0 -multiwindow -auth /home/user/.serverauth.1990