‘rsync’ command source and destination explained

information sign on paper

rsync command is super useful because it could incrementally sync files between locations without the overhead of compressing and transferring. There are heaps of tutorials about how to use it, how very few cover the point that how to sync two folders, which I believe is the most common use.

I’d run rsync -avzP dir1 dir2, but unfortunately, this syncs dir1 under dir2. Some people would then run rsync -avzP dir1 dir2-parent. This could work, but it’s particularly dangerous if you add the --delete option. So how to sync the content of the two folders.

If you run man rsync – not many people would use nowadays, you’d get the very import/useful instructions:

A trailing slash on the source changes this behavior to avoid creating an
additional directory level at the destination. You can think of a trailing /
on a source as meaning “copy the contents of this directory” as opposed to
“copy the directory by name”, but in both cases the attributes of the
containing directory are transferred to the containing directory on the
destination. In other words, each of the following commands copies the files
in the same way, including their setting of the attributes of /dest/foo:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo

The instructions are there like forever, right? But the first command is tricky where you could override the destination directory with the content of foo, so I’d recommend you to always use the second way:

rsync -avP dir1/ dir2

And it works the same way for remote directories.

Role transition to a Frontend Developer

modern residential building facade decorated with green plants

There are only two hard problems in Computer Science: cache invalidation and naming things.

Phil Karlton

I recently started a frontend role at Automattic. Just in case any of you still don’t know the company, it’s the company behind WordPress.com, Tumblr, Simplenote etc.

Developers at A8C are all kinda full stack engineers. I was mostly a backend dev in my previous careers, but as fate would have it, I ended up in a front team. A big change I would say. I mean I have done a lot of frontend stuff before, but never served as a frontend developer, meaning I know how things work, but I don’t know how to make it perfect. So I decide to start blogging again, making notes while learning and develop all the skills required.

Found a interesting diagram about the tech stack of a frontend dev nowadays.

Credits: Frontend Master

I’ll explore the nodes on the diagram bits by bits and concentrate mostly on CSS and Reactjs where I’m not 100% confident.

Fix! Unable to Remove bluetooth devices/mouse/keyboard/speaker issue for Windows 10

grayscale photo of a wireless earphone

This is the only working solution for me. Enjoy.

My symptoms:
– Previously working bluetooth speaker (UE BOOM 2 in my case) stops connecting
– Windows 10 ‘Bluetooth and other devices’ menu shows the device as Paired
– Pressing connect makes it attempt to connect but fails then it goes back to Paired
– Remove device hides the device from the menu, but as soon as you turn bluetooth on and off, or restart the computer, the device comes back
– You pull your hair out.

Solution that worked for me after much, much unsuccessful internet trawling and one system restore:
– Download this 7 year old command line bluetooth toolset: Bluetooth command line tools – work with bluetooth from the command line
– Install it, make sure you enable the option to “Add Bluetooth Command Line Tools directory to path”
– Open Powershell
– Put your device that isn’t working properly into pairing mode
WARNING: THE FOLLOWING COMMAND WILL UNPAIR ALL BLUETOOTH DEVICES
– type in “btpair -u”
– Boom, all of a sudden Windows asks me if I want to allow pairing to my device that isn’t working
– Hit yes, successfully connected again
– Cry tears of joy

God I hope that helps someone else.

Credits: xzion .

Example of Sending SMS in PHP Using AWS SNS

person sitting inside car with black android smartphone turned on
$client = AWS::createClient('Sns');
$sms = [
    'Message' => 'sms_content',
    'PhoneNumber' => 'sms_recipient',
    'MessageAttributes' => [
        'AWS.SNS.SMS.SenderID' => [
            'DataType' => 'String',
            'StringValue' => 'AD'
        ],
        'AWS.SNS.SMS.SMSType' => [
            'DataType' => 'String',
            'StringValue' => 'Transactional'
        ],
    ]
];
$result = $client->publish($sms);