Validate SPF record online

If you are setting up the SPF record for your domain, you can test its validity online.

 


Blank lines in top of file downloaded via PHP

You are serving a file for download directly from your PHP script, by setting its mime type,  sending headers with Content-Type and Content-Disposition, then piping the contents.

Everything works fine, but then suddenly the downloads become corrupted, with extra data added in their top, with blank extra lines clearly visible in downloaded text files.

The first thing to do without thinking much is to go through your PHP files and remove closing “?>“, if they are at the very end of the file. They are not needed and actually can be harmful, as anything after “?>” may served to the user with potentially damaging results.

Just remove those “?>” and your downloads may be fine again.


Obfuscate PHP code

So you write some software in PHP and are about to upload it to the server. But what if the server is not secure, what if it gets compromised, what if somebody steals your intellectual property? There may be situations where you are really concerned about it.

In most situations the best practical solution is to simply obfuscate your code, by making it unreadable to humans. It can still get stolen and used as it is, but it is very hard to practically impossible to restore the logic behind the code. And that is sufficient in most situations.

An extremely simple, fast and effective tool for that is YAK Pro.

The easiest way to install it is to use git.

1) Go to the directory where you want to have the obfuscator directory created, then type:

git clone https://github.com/pk-fr/yakpro-po.git

2) Change into the newly created directory and again type:

git clone –branch=1.x https://github.com/nikic/PHP-Parser.git

NOTE: It is “branch” with two dashes “-” before it, WordPress may mess up the text formatting.

Afterwards you may test it in action.

Read the rest of this entry »


See last shutdown time

If you want to find when was the last time the computer was shut down:

  • last -1x shutdown

See last five shutdowns:

  • last -5x shutdown

Add custom emblems in Linux Mint Mate

You can make and assign your very own Gnome emblems to files and directories in Linux Mint Mate ( Tested on Mint 18 ).

  • Go to Home folder
  • Select from menu Edit -> Backgrounds and Emblems…
  • Choose Emblems
  • Add a New Emblem…
  • Enter the Keyword
  • Click Image to select image file

You can add any custom image of whatever size, as it gets rescaled as needed.

Still you may want to use one of the standard sizes (16×16, 22×22, 24×24, 32×32, 48×48, 96×96) and save it as a PNG file in a location of your choice.

Try to start with the image size of 24×24. You may use one of the existing emblem files for reference, for example /usr/share/icons/Mint-X/emblems/24/emblem-favorite.png .

 

 


Removing line breaks from base64 encoded data

You may experience a weird problem, when you attempt to embed base64 encoded TTF font file in a Web page with CSS @font-face and the font just does not work. You try decompressing the base64 data, and get perfectly valid TTF file. Everything is fine, but nothing works.

Well, the problem is caused by line breaks in the base64 encoded data. It is said that those line breaks are there because once upon a time software could not handle long strings. Well, these days it is obviously the opposite. Web browsers seem unable to handle base64 data with line breaks SOMETIMES, because base64 encoded images work perfectly well even if there are the breaks. The fonts don’t though.

Whatever. Take your base64 encoded file and run this command on the command line:

tr -d "\n\r" < Font.base64 > Font-valid.base64


LibreOffice add external data field to document

You may want to use some external variables that are shared between several of your Writer documents.

One way to do that would be to use Mail Merge, but that may not be what you prefer.

Another solution is to insert the data you want as DDE link to the source document.

Let’s say you have a string in your Calc spreadsheet and you want it to show up in your Writer document:

  • Open the Calc spreadsheet
  • Copy the cell
  • Open the Writer document
  • Select menu Edit -> Paste Special -> DDE Link
  • Press Ctrl+Z
  • Press Ctrl+F
  • Select Variable tab
  • Select Type: DDE Field
  • Select the name of variable in Select control
  • Click Insert button

The method is a bit clumsy, but it works just fine. Possibly you may stop after pasting the DDE link, which gives you a fragment of a table, depends upon what do you need.

To see field values instead of field codes:

  • Select menu View -> Field Names (or press Ctrl+F9)