Saturday, December 14, 2019

Shadow Lock Components with Wrapper

Example usage:
Wrapper component: Wrapper component syles:

Tuesday, December 10, 2019

Stateless Way of Handling Modal in React

You ever wanted to call your modal in React as you call builtin alert() method. It can be handy if you want to have a modal that able to be fired anywhere in your application and you don't want to mess with either render tree or redux store with all those actions to be dispatched etc.

Wouldn't be easier to have just show and hide your modal like this :;


Well, you can achieve this by injecting your component directly to HTML DOM.

Check full example :

Sunday, December 08, 2019

Git Cheat Shit v2

Squash last N Commits

Carry the HEAD where you want to start squashing (eg. 3 commits before) :
$> git reset --hard HEAD~3
HEAD@{1} is previous location on branch. Merge it to last commit of your branch :
$> git merge --squash HEAD@{1}
Then commit your change :
$> git commit
Option 2: Soft Reset
Soft reset :
$> git reset HEAD~3
stage all change (better not use --all and handle all of them manually):
$> git add ./ src/ blabla/
commit again with message:
$> git commit -m "This is squash merge"
  • Note: Compared the previous option you need to carefully stage add all files that need to be included and commit message will not automatically include all messages of squashed commits. I can’t see any advantage of this over first option.
Option 3: You may also use interactive rebase for this. But you might end up solving conflicts for past merges. Given solutions above is far more cleaner.

Create & Apply Patch

Create Patch :

Create patch file from stash :
$> git stash show -p stash@{0} > mychanges.patch
Create patch file from commit (this will have commit author data as well) :
$> git format-patch -1 <commit id>

Apply Patch :

  • Check which files will be patched :
$> git apply --stat mychanges.patch
Check if patch file can be applicable :
$> git apply --check mychanges.patch
Just apply :
$> git apply --3way mychanges.patch
Note: You better use this option if you create your patch from diff file where no commit info is included
Apply as a commit (with author and shit) :
$> git am --3way < mychanges.patch

Stash with message

$> git stash push -m "message"
You may use apply option to not lose your

Stash Untracked and Ignored Files

$> git stash --all

Clean Local Branch (BE CAREFULL)

This will remove your uncommited changes, dont forget to stash them if you need them later :
$> git fetch
$> git reset origin/<branch-name> --hard
Carry head to past commits
$> git reset <commit id> --hard

Backward Rebase

Note: You will need to resolve all conflicts for merge commits.
A : branch should go back to commit c0
├── c0 ── c1 ── c2 ── c3

├── c0 ── c1 ── c2 ── c3
$> git checkout A
$> git rebase -i --onto c0 c4^
During rebase solve conflicts, stage them and just do git commit to proceed.

Change Last Commit Author

$> git commit --amend --author="John Doe <>"
Type :wq in vim and proceed.

Change Author of Specific Commit in Past

Include New Changes to Last commit

Stage your change :
$> git add
Include it to last commit :
$> git commit --amend
Type :wq in vim and proceed.
If you wanna change it on remote branch too, then you will need to push it with force as history is changed now :
$> git push --force

Abort Cherry-pick, Rebase or Merge

$> git merge --abort
$> git rebase --abort
$> git cherry-pick --abort

Thursday, September 07, 2017

Duplicate IP Detection in Network

Duplicate IP problem can create trouble time in your network; mostly you will feel it frequenclty dropped connection. It might be caused by wrong DCHP server configuration or more than one network device functioning as DHCP server.

Option 1 :

To detect if it is the case for your problem; you can simply check ARP packets with Wireshark and you will see some packets like the capture below :

Option 2 :

If you dont have Wireshark installed on your device with you. You can use arp-scan command :

$ sudo arp-scan -I eth0 -l | grep -i dup e0:ca:94:d9:ed:80 Askey Computer (DUP: 2) bc:a9:20:e4:85:8e (Unknown) (DUP: 2) 78:31:c1:c4:54:e4 (Unknown) (DUP: 2) 5c:f8:a1:e7:80:5a (Unknown) (DUP: 2) b0:70:2d:a4:9c:97 (Unknown) (DUP: 2) 10:a5:d0:05:9c:85 (Unknown) (DUP: 1) 80:19:34:82:34:a8 (Unknown) (DUP: 2) 40:40:a7:e1:80:02 (Unknown) (DUP: 1) b0:72:bf:7d:e4:f0 (Unknown) (DUP: 2) 64:bc:0c:64:54:87 (Unknown) (DUP: 1) c4:9a:02:5a:2d:db (Unknown) (DUP: 1) c4:9a:02:5a:2d:db (Unknown) (DUP: 2)

Monday, April 10, 2017

A Bluetooth IoT Gateway (BLE-CC41A)

An IoT gateway is the bridge for your things (within this project's scope; it is embedded Bluetooth nodes) to make them able to talk to your cloud server. Most of embedded WiFi modules comes with support of application layer capabilities (such as HTTP requests). But non Bluetooth modules that i have seen had such capabilities in application layer - at least the ones i saw. Most of Bluetooth modules that i tested, access to internet through mobile phone applications. But you might not have "a mobile phone" in your system design all the time. So this was one of my project that i started with such motivation, but sadly i had to leave it in half way. This piece of code manages Bluetooth modules  and give them HTTP request capability. Even though this project have long way to go; it does what it has to in modest level.

Github :

What does this Gateway do? :

  1. This Gateway automatically searches for BLE-CC41A module on each serial port.
  2. Configures the serially connected BLE-CC41A module as master.
  3. Searches for availible slave modules around.
  4. Establishes connection between master and slaves.
  5. Sends requests of slaves to cloud server.

Requirements :

  1. A linux machine able to run Python 2.7. I have developed and tested this gateway on Ubuntu 14.04 machine.
  2. Gateway hardware should have at least one ethernet (to cloud server) and one serial USB port (for BLE-CC41A module).
  3. A cloud server: I have used my own cloudserver.
    3.1. You can go with and update the code accordingly.
    3.2. Wait for me to upload my cloudserver code to handle http requests
    3.3. Write your own servercode.
  4. Couple of BLE-CC41A modules. It is clone of HM10.

Configuration :You must modify server_url and api_key variables in

alt tag

Sunday, March 05, 2017

Hands on Docker Tutorial : Running a Container with WordPress - kerem izzet atam

In this tutorial i will show my steps to install Docker on Ubuntu 14.04 and run container having WordPress on it. I have prepared this tutorial within my first attempt to try Docker so don't judge me for any miss leading parts.

I have been hearing mighty """Docker""" and its capabilities for a while but never dare to share time to read and learn so far. Today it was my first attempt to investigate as one of my colleague was talking about it again with such excitement. So i decided give a shot. As i am lazy person to read and excited person to try technologies i directly go into doing something... Lets run some server application (WordPresss) with Docker on my Ubuntu 14.04 machine.

Before we start let me tell how you might like Docker (as my friend's words) : "It runs like virtual machine but lot more light weight with container mechanism" and "You can search for different containers with different configurations and install it to your PC in seconds".

As i am lazy, selfish, solution oriented, so-called engineer, i ask "how is it useful for me?" So...

Is Docker useful for you?
  • Do you remember the time your efforts to prepare your development environment again and again each time you need to copy it other PCs; messing with all these tool chain installations, satisfying all those repository requirements and so on. 
  • Do you remember when you need to create independent environment variables for different projects and applications like php 5 for this php 7 for that.
  • Do you remember the time when you work with team overseas and you need to share same configurations to your colleague of your OS.
  • Do you remember your struggles to move your cloud server; re configuring all those configurations and facing same problems during installations.
If you remember, yes! Probably it will save your time as you will have very light weight version of your PC or server as container. You can keep those containers on cloud and install it whenever you want, like an application.


As summary of istructions on this official tutorial  :

1 - Clean if you have old versions of it : 

$ sudo apt-get remove docker docker-engine

2- Update and Install :

$ sudo apt-get update
$ sudo apt-get install \ linux-image-extra-$(uname -r) \ linux-image-extra-virtual

$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common

$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common

3- Verify finger prints :

$ curl -fsSL | sudo apt-key add -

Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.
$ sudo apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) 
sub   4096R/F273FCD8 2017-02-22
Done! Dockers is installed.

4- Now go to site : , Search for "WordPress" and click on detail of first result.

5- You will see page under this URL and check the command to command to pull this container as :
$ sudo pull wordpress

6- Run the container : 
$ sudo pull wordpress

7- Access to shell of container :
$ sudo docker run -it wordpress /bin/bash

8- Check running containers on host PC  :
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0acccb9e18ce wordpress "docker-entrypoint..." 10 seconds ago Up 9 seconds 80/

9- Query IP of container by ID. We learn ID of our container from previous command as 0acccb9e18ce :
sudo docker inspect 0acccb9e18ce | grep "IPAddress"
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "",

10- Now i can browse through my WordPress container from IP ""

This tutorial is only for testing. Step 6 should be applied with command below according to instruction in WordPress. This will link our WordPress container with another container having mySQL. :
sudo docker run --name some-wordpress --link some-mysql:mysql -d wordpress

Kerem İzzet ATAM