Posts

Svelte offers remarkable flexibility for creating dynamic components. In this tutorial, we’ll explore how to instantiate components on the fly and pass properties to them in an elegant and efficient manner.

A business web application is a specialized software solution designed to help companies manage their operations effectively. Unlike generic apps such as e-commerce platforms (like Shopify) or booking management tools (like Doctolib), a business web app typically processes client-provided information, applies business-specific logic, and returns a result that helps achieve the companies goals.

I have a keyboard/mouse/screen switch to connect 2 PCs: one running Linux and one running Windows.

When I connect all the ports, it works, but every time I switch to the Windows laptop, the screen reconfigures, my windows are moved, and it annoys me. The switch behaves as if I had physically unplugged/replugged the screen, and Windows feels compelled to adjust the entire layout!

I often need to code some way to have multiple pages rendered in the same location : think about a configuration panel with several sub panels. The natural way to code this is using tabs.

Tags input

I want to code a simple tags input component in Svelte like the animation above.

  • An input text where I can type words.
  • As soon as I type a comma or Enter, the input turns into a “tag”.
  • The tag appears next to the input text with a small cross to delete it.

I can retrieve the list of tags in an easy-to-use data structure: for example, an array of string.

During a discussion on a Discord channel, a message puzzled me: Go is not an object-oriented language.

I knew Go didn’t have an inheritance mechanism. But, was that enough to disqualify it as an object language ?

We can customize Firefox interface to hide the tabs bar :

  1. First, we have to tell Firefox that we want to customize its interface.

Sqlite Pure Go 2022.11.06

Would it be possible to embed a database to avoid managing a MySQL or Postgres instance?

Even better, can this database be queried in SQL? I don’t want to learn another way to query data.

In my previous post, I used Nebula to setup a secured network between 2 virtual machines.

This time, I’ll try to make a MySQL client and server communicate through a Nebula tunnel. And to make it a little bit more difficult, I’ll use podman to run the client and the server in containers.

Is it possible to use the public network, namely Internet, to make 2 machines communicate securely ? And if possible something easier to install and configure than OpenVpn ?

Udev Webcam 2022.04.01

You can change the device link so your webcam will be always accessible at the same location /dev/video99. You can also persist some settings via the v4l-ctl command.

This days, with 4K monitors, the linux console is unreadable : the font is too small. So how can we scale the font size in the console after boot ?

Local git 2019.12.02

Define a repo somewhere in your file system with a bare init

mkdir -p /somewhere/repo/test_project
cd /somewhere/repo/test_project
git init --bare

Now create a local folder for your work with init only

You can change the mysql prompt client so you know where you are.
Very usefull when you manage a lot of mysql databases and you forget which one :-)

If you use a tiled window manager like me, Suckless DWM for example, and have Firefox as your browser, you may be interested by not showing the tabs.

How to flash any iso (think about your favorite distro) on an USB key without graphical IHM ?

sudo dd if=/path/to/image.iso of=/dev/sda status=progress
  • “/path/to/image.iso” is the path to the ISO file
  • /dev/sda is your USB key device (see below to get yours) : note that it is the whole device, not a partition (e.g. /dev/sda and not /dev/sda1)
  • status=progress show flashing progression

How to know wich device to use ?

How to configure a Debian based Linux distribution to share a folder with anyone on the network, with read and write access ?

ImageMagick logo

As ‘man convert’ states :

The convert program is a member of the ImageMagick suite of tools. Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

MySQL

I tried to resync a slave MySQL after it disconnected from the master. But the binary log was already deleted on master, so the only solution was to restore from the last backup. To avoid lock tables on the master and remember the binary log name and position to put them on the slave configuration, there is a tip to take care of all that : the “- master-data” option in mysqldump.

To import a local CSV file into MySQL, use the syntax below :

LOAD DATA LOW_PRIORITY LOCAL INFILE '/path/tofile.csv'
INTO TABLE database.table
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES
(`field1`,`field2`,...)

To export a mysql results in CSV format, use the syntax below :

SELECT field1, field2, ...
FROM table
WHERE condition
INTO OUTFILE '/tmp/toto.csv'
FIELDS TERMINATED BY ';'
ENCLOSED BY '"'
LINES TERMINATED BY '\n' ;

By default, in Cheyenne, the header size limit for a post request is 102'400.
If you want to ajust this limit you can define the post-mem-limit parameter in the global context or in a specific webapp.
For example, to double the initial limit in the httpd.cfg, :

Get rid of graphic boot on Linux with a few modifications in grub configuration :

# edit your grub config
sudo vi /etc/default/grub

# remove splash, quiet, ... from GRUB_CMDLINE_LINUX_DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT="text"

# save the file and update grub
sudo update-grub

Just in case you absolutely have to insert a date in MySQL that does’nt exist, eg 2014-02-30, you can run MySQL server in a special mode that authorizes such dates :

A few days ago, I started to have a very disturbing “Not permitted” message when trying to mount a usb disk from Thunar . The only way I found was to pmount the disk : not as intuitive as just clicking the disk on Thunar.

  1. In Windows, create a certificate via Start > All Programs > Microsoft Office > Microsoft Office Tools > Digital Certificate for VBA Projects
  2. In Microsoft Outlook, open the VB editor and copy/paste the code below
  3. Replace your@email.here and save
  4. Click on Tools > Digital Signature
  5. Click on [Choose] and select your certificate
  6. Click OK, then save and close the VB editor
  7. Create the Outlook rule with [run a script] as action and select your macro
  8. That’s all folks !
Private Const TO_EMAIL As String = "your@email.here"
Sub ForwardAllEmail(theMail As MailItem)
	On Error GoTo EndSub
	Dim mailObj As Outlook.MailItem
	Dim item As Outlook.MailItem
	Set mailObj = Application.Session.GetItemFromID(theMail.EntryID)
	Set item = mailObj.Forward
	item.Recipients.Add (TO_EMAIL)
	item.Send
	Set item = Nothing      ' Set variables to null to prevent memory leaks
	Set mailObj = Nothing
	Exit Sub
EndSub:
  MsgBox "Error: " & Err.Description
End Sub

For example, to substitute foo with bar

for f in `grep -lR foo`; do
  echo -n ">> $f";
  sed 's/foo/bar/g' $f > $f.2;
  mv $f.2 $f;
  echo " done.";
done
  • for loops on all files containing the text “foo”, grep -l only show the file name with corresponding text inside.
  • sed replace foo with bar in all file
  • mv save the modification (delete if you don’t want to overwrite the original files, the modified files is named with .2 at the end)

The fastest and more efficient way to batch multiple files encoding conversion :

vim +"argdo se fileencoding=utf-8 | w | bnext" +"q" ` find . -type f -name "*.rsp"

+“argdo” : execute the following vim commands for each file (filencode, save and next buffer)

Side note : Microsoft has dropped support for IE8 last april 2014 :-(

There are still some clients that want their webapp to work perfectly on IE8. They can’t make all their clients move to the newest browsers. But some times, it can drive you nuts to achieve simple things. Our problem was about a background image in a div that doesn’t want to strech. Just some css will do it for all other browsers, but not for IE8. It needs a special “filter” like this :

DWM is my tiled window manager. It’s fast, flexible and fun. My linux desktop is up and running after a few seconds… (ok, thanks also to the ssd :-) ).

Forget large background image for your web site. Now, comes video time.

So you want to put a nice video as background of your site but don’t know how to do ? “Fear you must not” said Yoda as it’s really simple.

2048 Gremlins 2014.04.28

Let’s Gremlins play 2048 !

2048 : a very famous game where you have to slide the numbered tiles to join same numbers, and cumulate them to obtain 2048 !