My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com









Tuesday, January 22, 2019

How to undo a Git commit that was not pushed

To undo a Git commit that was not pushed, you are given a few major options:

Method 1:
Undo the commit but keep all changes staged
git reset --soft HEAD~; 


Method 2:
Undo the commit and unstage the changes
git reset HEAD~; 
or 1 git reset --mixed HEAD~; 


Method 3:
Undo the commit and lose all changes
git reset --hard HEAD~;


Method 4:
In case you just want to rewrite the commit message, you could use:
git –amend instead.



I will add following more helpful commands to check commit history, go back to a commit, and remove commits etc:
  1. git log
  2. git log --oneline to simplify the output:
  3. To test a specific commit: git checkout . You will be in 'detached HEAD' state. You can look around, make experimental changes and commit them, even create a new branch from here using git checkout -b new_branch_name
  4. To fix the detached head issue: git checkout
  5. Undo this commit: git revert . This will create another commit operation in github

Cheers :)
-Anwar Jamal Faiz


Read some of my other posts related to Git tricks below :

Saturday, January 12, 2019

Stylesheet Types : CSS, SaSS, SCSS - What do they mean

Ever wondered what is the difference between SCSS and Sass. More importantly, how are they different from CSS.

To start with let me point out that Sass is a language or a pre-processor that makes CSS more powerful with variable and math support. It provides syntax advancements. Style sheets in the advanced syntax are processed by the program, and turned into regular CSS style sheets. However, they do not extend the CSS standard itself. You can do operations like additions and introduce variables in CSS using Sass.


The SCSS is also called Sassy CSS. This is an extension of the syntax of CSS. This means that every valid CSS stylesheet is a valid SCSS file. Files using this syntax have the .scss extension.


The Saas format described earlier is also known as the indented syntax. It provides a more concise way of writing CSS. It uses indentation rather than brackets to indicate nesting of selectors, and newlines rather than semicolons to separate properties. Files using this syntax have the .sass extension. However, as already told that all this works only with the Sass pre-compiler. In the end what is created is simple CSS. It is not an extension to the CSS standard itself.



The Sass .sass file is visually different from .scss file, e.g.

Example.sass - sass is the older syntax

$color: red

=my-border($color)
  border: 1px solid $color

body
  background: $color
  +my-border(green)

Example.scss - sassy css is the new syntax as of Sass 3

$color: red;

@mixin my-border($color) {
  border: 1px solid $color;
}

body {
  background: $color;
  @include my-border(green);
}
Any valid CSS document can be converted to Sassy CSS (SCSS) simply by changing the extension from .css to .scss.

Thursday, January 3, 2019

Packing and unpacking tar/gzip files on Windows


A few years ago I wrote a similar blog for Linux. Refer https://www.w3lc.com/2011/06/tar-command-in-linux-to-archive-and.html. However, the question is again very relevant if your OS is Windows and its family. Hence this post.


Method 1: Using compression utility

First you compress it to tar with 7-zip and then to gzip with 7-zip.
You u can do using their UI or command line support provided by them.

Following is the example if you want to use 7z tool or its dll:

  • Create .tar.gz: 7z a -ttar -so dwt.tar dwt/ | 7z a -si dwt.tar.gz
  • Extract .tar.gz: 7z x dwt.tar.gz -so | 7z x -si -ttar



Method 2: Using bash shell on Windows like UnixUtils or any other Bash of Ubutu etc on Windows.

If installed, make a directory and proceed as follows:
cd /mnt/c/[path to folder to archive]
tar -pczf archive.tar.gz *
In fact, if you notice this approach is similar to my earlier blog for Windows.


Method 3: Write your own subroutine/function to generate a Zip file.

Yeah! you can do it. Thousands of companies do it. And you can find open source solutions as well. Because these formats are in any case open source! Pretty easy :)


Method 4: Extending method 1 more, you can use Gzip for Windows - GnuWin32. This utility has command line version as fell. Refer http://gnuwin32.sourceforge.net/packages/gzip.htm

Thursday, December 27, 2018

Assign different machine/ build agent in Teamcity - CICD server

Log on to the machine that you want to make as a build agent. Access your teamcity site (http://teamcity) through a browser from the target build agent machine eg windows server, and download the installer.
Also, do note that there are limitations on the number of agents you can have under you license so you may need to purchase an additional one, but I suspect in this case you'll be okay - TeamCity Licensing
The final step will be to run the build scripts using the build agents. For this detailed can be read on https://confluence.jetbrains.com/display/TCD18/Setting+up+and+Running+Additional+Build+Agents. This page also talks about pre-requisites and the installtion on build agents. However, for the sake of clarity, I have added those details in a simple manner as following:

Steps to install a build agent for Teamcity:
  1. Open the administration section and click on Install Build Agents. From here download the agentinstaller.exe
enter image description here
enter image description here
2.Start the installer and ensure you are installing a windows service
3. Enter your destination directory for the build agent - This is where the working directory and configuration will reside, and click next to perform the installation
4. Give details of you TeamCity server so the agent can communicate back to the server. Run the agent under the SYSTEM account for now, unless you have a dedicated network account (recommended) and start the build agent service. You will now need to enable the agent inside of the TeamCity UI (this may take a few minutes to appear). It might appear as unauthorized and you'll have to wait for it to upgrade and reconnect.
5. Once this has happened, you can authorize the agent by clicking the Authorize agent button. A dialog will popup where you can enter some notes if required.
From the Agent summary, you can note and crosscheck the IP of the machine and links to be used to refer later. TeamCity build agents can be started manually or configured to start automatically.

To start the agent manually, run the following script:
  • for Windows: \bin\agent.bat start
  • for Linux and macOS: \bin\agent.sh start

Refer: TeamCity Documentation - Installing via MS Windows Installer
Cheers :)

Sunday, July 29, 2018

Definition of Smart Devices by W3LC - World Wide Web Learners Consotium

Definition of Smart device.


"A smart device is any electronic computing device that has an ability to interact autonomously and yield information to its user and other smart devices."

© 2018, Mohd Anwar Jamal faiz


Some examples if Smart devices are:
  • Smartphones
  • Smart speakers like Alexa Echo Series, or Google Home
  • Smart Home systems like of Philips Hue and Samsung line
  • tablets
  • phablets
  • PDAs
  • Smart watches
  • Smart Fitness trackers
  • Smart Glasses
And, the list continues.