Searching for the perfect speed

Since I got the crazy idea to radically change this website engine, from Windows+mojoPortal to Linux+PHP, I noticed that I need a LOT of more CPU time to generate each page:

cpu-year

It uses a lot of processor time, but requests are much more faster… if the page has been “cached”:

http_loadtime-year

In my experiments I saw that the forum that I was using (bbpress) slows down the site a lot: it loads a lot of useless javascript in all pages, and doesn’t allow “caching” the pages. So I temporarily disabled the forum, searching for a temporary solution. I’m thinking to use Discourse

What does “root” means?

In computer terms, with root we can mean:

  • Root as user
  • Root as in file path

If we mean root as an user, we mean the main user, the one with the “master” control of the machine. For example, if you have root on Android, it means you can do whatever you want it it.

If you mean root as a file path, it’s the base, just place the file outside any folder. If you’re using the D: drive, by saying “place the file in root”, it means just place it on D:

How to control a lamp via Arduino

In the last posts I wrote that I bought a lot of Arduino stuff, to try to build something interesting, but I didn’t show anything.

This is the first example, the easiest: how to control a lamp.

Ingredients:

The circuit and the code it’s super easy and it’s on GitHub.

Code explanation:

  1. in setup() we declare that pin 7 is an output
  2. in loop() we turn on pin 7
  3. We wait 10000 milliseconds (10 seconds) before running next instruction
  4. We turn off pin 7
  5. We wait another 100000 milliseconds
  6. We start again from point 2

The result is that we have turn on and off the lamp every 10 seconds.

Obviously, this is an useless circuit, but we can expand it, for example by controlling the lamp via Bluetooth or via WiFi.

How to change the email in WordPress

I don’t see a logical reason behind it, but WordPress is designed for sending emails from the address [email protected]

Did you spent hours to search where in the settings it’s possible to change this address? Wasted time, there the address is hardcoded, you can’t easily change it!

There are 2 ways to change it:

  1. Install a plugin like this: https://wordpress.org/plugins/wp-change-default-email/
  2. Write a few lines inside the functions.php in the theme (better if it’s a child theme)

Since I try to avoid to install WordPress plugins, I chose option 2.

In functions.php, add this:

// change the email
function wpb_sender_email( $original_email_address ) {
    return '[email protected]';
}

// change the name
function wpb_sender_name( $original_email_from ) {
    return 'Your Name';
}

// Hook those functions to WP 
add_filter( 'wp_mail_from', 'wpb_sender_email' );
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );

Send all new files saved in a directory as email attachments

I wanted to send by email scans made with the printer I have at work. Once I have them in my email, it’s easier to archive/send them more easily.

Problem: the printer software is bugged and doesn’t allow to use my long, complex password, so I had two options:

  • Change the email password to be shorter
  • Think a workaround via a linux server

Obviously I opted for the second option!

It works like this: we tell the printer to save the PDFs on a network share, inotifywait waits that a new file is created, and then sendEmail sends it as an email attachment

The script has to be ran in a screen, and it runs in an infinite loop

Your website could be used for a mail bombing

Today, by pure luck, I looked quickly to the mail server logs. Since the beginning of the year it has sent about 1500 emails.

“Ah, ok”, I think, and I move on.

Then I think about it. Hey, 1500 emails sent in a couple of days???

Looking the logs I immediately found the culprit:

After every post of a WordPress website it was enabled “share by email”!

A chinese bot, every minute, was going to the page and was sending the content to the same email address!

Result: a mail bombing!

I hope that my IP address reputation is not tarnished and doesn’t affect my deliverability…. 😡

Codeanywhere – the review

I clicked on “free account”, I wrote an email and password and boom, already registred!

Once logged in it asked me which preinstalled “stack” I want to use, from:

  • PHP
  • Node.js
  • Ruby
  • Python
  • C++
  • HTML5

Or, I can just connect to my own VM via SSH.

For example, PHP says:

PHP Development Box on Ubuntu 14.04 with Apache, PHP, MySQL, phpMyAdmin and Composer preinstalled. 

Starting up is very quick, the virtual machine is created in a few seconds, and Apache is already listening on port 80.

In less than a minute I can publish online a php file.

It’s well integrated with GIT.

The only drawback is that everything is organized like “every project gets its own virtual machine”, with GIT and Apache set to work in the main directory.

Of course, since it’s a virtual machine, I can live without native integration, I configure Apache and git in my way via command line, but that’s not as comfortable as doing with a few clicks.

It can automatically save files, but it’s disabled by default, because the free version doesn’t keep the edit history: if you pay you can get the history, and that’s a nice feature for who doesn’t want to use GIT and prefers to save on Dropbox.

Another great thing is that the SSH public key of the virtual machine can be generated and copied with just one click on the username, so it’s very fit for git. About git, when I have a commit, I can’t select a single file, but it’s “all or nothing”. I think this is still because of the logic “every project gets its own virtual machine”, and this makes sense: why should I sign up to the Freelance edition and pay $7 monthly if the free version can easily allow me to manage an unlimited amount of projects? If I don’t pay I have to set and use apache/git/other tool from the command line. If I was to use this webapp everyday for work, the Freelance subscription would be a no-brainer. It’s so handy to have a perfectly “clean” virtual machine with the right tools and always available for every project?

If you register to Codeanywhere using my link:
http://codeanywhere.com/referralsignup/?r=44733c37687e396531
you will receive $15 in free credit if you sign up for a paid subscription.

List of online developing environments

Now that there’s the “cloud mania”, there are dozens of websites that allow to code online without install any program on the local computer. That’s perfect for who, like me, uses 2 computers at work, 2 computers at home, and often uses someone else’s computer: the problem is that my free time is limited, but if I don’t have all the tools set up as I need, I can’t develop or continue a project.

In this way I could write something during lunch time break at work, continue it in my train commute, finishing at home.

The most promising online developing environments (cloud IDE) that I found are:

For me, the most important feature is native GIT support. It looks like that all those seven webapps have this feature.

First of all, I will try codeanywhere, because it looks like it’s the only one with an Android app, so, maybe, I can use it from my BlackBerry Z10.

Another “feature” is the price, because almost all my project aren’t generating profits, so I can’t pay big subscription fees. This is the reason I won’t even try Codio, because, if you don’t pay, after 30 days the workspaces become public.

Soon I will publish a review for Codeanywhere 😀

A Javascript code that looks like Japanese smileys

What do you see here?

゚ω゚ノ= /`m´)ノ ~┻━┻   //*´∇`*/ [‘_’]; o=(゚ー゚)  =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: ‘_’ ,゚ω゚ノ : ((゚ω゚ノ==3) +’_’) [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ+ ‘_’)[o^_^o -(゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3) +’_’)[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +’_’) [c^_^o];(゚Д゚) [‘c’] = ((゚Д゚)+’_’) [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];(゚Д゚) [‘o’] = ((゚Д゚)+’_’) [゚Θ゚];(゚o゚)=(゚Д゚) [‘c’]+(゚Д゚) [‘o’]+(゚ω゚ノ +’_’)[゚Θ゚]+ ((゚ω゚ノ==3) +’_’) [゚ー゚] + ((゚Д゚) +’_’) [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +’_’) [゚Θ゚]+((゚ー゚==3) +’_’) [(゚ー゚) – (゚Θ゚)]+(゚Д゚) [‘c’]+((゚Д゚)+’_’) [(゚ー゚)+(゚ー゚)]+ (゚Д゚) [‘o’]+((゚ー゚==3) +’_’) [゚Θ゚];(゚Д゚) [‘_’] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3) +’_’) [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+((゚Д゚)+’_’) [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +’_’) [o^_^o -゚Θ゚]+((゚ー゚==3) +’_’) [゚Θ゚]+ (゚ω゚ノ +’_’) [゚Θ゚]; (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]=’\\’; (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ +’_’)[c^_^o];(゚Д゚) [゚o゚]=’\”‘;(゚Д゚) [‘_’] ( (゚Д゚) [‘_’] (゚ε゚+(゚Д゚)[゚o゚]+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) – (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) – (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (c^_^o)+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+(゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) – (゚Θ゚))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚o゚]) (゚Θ゚)) (‘_’);

It may look like a random array of kaomoji, the japanese smileys like (o^_^o) , (゚ー゚) , ゚ω゚ノ , *´∇`* or this monkey head (゚Θ゚); instead it’s real Javascript code, and you can run it by, clicking here.

Awesome, right?

You can find the obfuscator here: http://utf-8.jp/public/aaencode.html

Also, from the same website there is also one that only uses []()!+ and another one that makes stuff like this:

dandandin=~[];dandandin={___:++dandandin,$$$$:(![]+””)[dandandin],__$:++dandandin,$_$_:(![]+””)[dandandin],_$_:++dandandin,$_$$:({}+””)[dandandin],$$_$:(dandandin[dandandin]+””)[dandandin],_$$:++dandandin,$$$_:(!””+””)[dandandin],$__:++dandandin,$_$:++dandandin,$$__:({}+””)[dandandin],$$_:++dandandin,$$$:++dandandin,$___:++dandandin,$__$:++dandandin};dandandin.$_=(dandandin.$_=dandandin+””)[dandandin.$_$]+(dandandin._$=dandandin.$_[dandandin.__$])+(dandandin.$$=(dandandin.$+””)[dandandin.__$])+((!dandandin)+””)[dandandin._$$]+(dandandin.__=dandandin.$_[dandandin.$$_])+(dandandin.$=(!””+””)[dandandin.__$])+(dandandin._=(!””+””)[dandandin._$_])+dandandin.$_[dandandin.$_$]+dandandin.__+dandandin._$+dandandin.$;dandandin.$$=dandandin.$+(!””+””)[dandandin._$$]+dandandin.__+dandandin._+dandandin.$+dandandin.$$;dandandin.$=(dandandin.___)[dandandin.$_][dandandin.$_];dandandin.$(dandandin.$(dandandin.$$+”\””+dandandin.$_$_+(![]+””)[dandandin._$_]+dandandin.$$$_+”\\”+dandandin.__$+dandandin.$$_+dandandin._$_+dandandin.__+”(\\\”\\”+dandandin.__$+dandandin.___+dandandin._$$+”\\”+dandandin.__$+dandandin.$_$+dandandin.__$+dandandin.$_$_+dandandin._$+”\\\”)”+”\””)())();