Git Hub Tutorial / Cheat Sheet

git tutorial / cheat sheet

 

 

Using Git was a bit of a headache the first time around.

I remember day 1 complaining about it every 5 minutes. After a few days it becomes a trusted friend.

Here is the tutorial I wish I found when learning to use it.

Enjoy…and download the pdf version for the yellow highlighting which helps a lot

 

Download PDF Here

 

GIT CHEAT SHEET

Highlighted yellow are steps to load new project for first time

git version

Make sure git is installed

git config –global user.name “yourname”

git config –global user.email “youremail”

add your contact and signature to commits automatically

git config –list

see you current set up

git help <verb>

git <verb> –help

get help and commands about subject

dir cd “name of folder” cd ..

dir show a list of file and cd takes you there. Cd .. takes you back

git init

This creates a folder in your local code which will keep track of the code and communicate with remote code source. Nothing si automatic. Your “working folder” contents must be added in future steps for the folder git init to work with it.

git status

(See .gitignore at this point)

This will show files that are not being tracked by your git init object.

This will show files that are being tracked and are in the staging area

git add <somefile>

git add -A

This will add files to the staging area. They are still in working folder but git understand you want to work with themin future git commands.

git reset <filename>

git reset

removes this from staging are. Git still sees it but is not working with it anymore.

git commit -m “your message”

commit command creates a data point saying someone updated the project at this point. The -m command is required so you can send a message to let future readers know what this commit was about. (Try git status now. It will say that your working directory is clean. You havent uploaded yet but there is nothing more to upload besides the files buffered into your commit)

git log

You can see the log of commits

git remote add “somename” “somelocation”

This command will link your git init object to the remote repository. “somename might be “origin” and “somelocation might be ” c:projectsfilesthisproject” or “https://bitbucket.org/yourprofile/yourproject/project.git

git push -u origin master

Remember when you made a commit? This takes that commit and pushes it to the remote repository. The -u symbol i have no idea. The origin defines the repository location which was added in the previous instruction. And the master means added to the master branch

git pull origin master

same as above but reverse. Bring remote to local

git clone <url>

Navigate your console to desired download location and clone a repository there wth this command. Remmber this does everything for youso no need to make a git init.just reference project folder probably

git remote -v

view remote repo info

git branch -a

check branches. Unless you a master commit kinda person(your not)

git diff

see code changes between working and local staging

The post Git Hub Tutorial / Cheat Sheet appeared first on SignalHillTechnology.

Powered by WPeMatico

Easy Time Card

Many offices today are still filling out paper time cards. Why you ask?

  1. How nefarious software integration is
  2. The learning curve
  3. Bugs or “features”

Almost everyone is guilty of it. Products are designed to work with constant support resulting in monthly or yearly fees. Upgrades, server costs etc. But most people aren’t getting paid to figure out software. They want the solution that stays the same. Not one that changes with the weather. As they sort through all the numerous buttons they passively fear that the next upgrade will change things and they will spend more time relearning. Barf.

 

But paper time cards suck!

Paper time cards take time to fill out. There is zero space to write. They get smudged and lost plus people have to hand deliver them back to the office. Someone needs to sort through them. Its not really a great solution.

 

My Solution

A compromise between the two.  This app is real easy. Two buttons to operate it and if the setup is too hard someone else can do it once and its done. Below is a screen shot from the main screen of the app. You can see the current day being shown as clocked in and below. When the user is ready to clock out just press the big red button. When the user is ready to report their time they can press the button on the bottom  labeled report time.

 

Here is the main activity below which is android class that you build your app around. Here there are a few boilerplate function to get the app onto your screen and a few more to to make dates, times or save files to your device.

This UI of this app is built within the Fragment and Dialogue Fragment classes within android library which is conveniently optimized with android studio which has great autocomplete.

Me thinking about autocomplete. Colorized. Circa 1999.

The main design of this app relies on java calendar. By using the calendar .get instance I can pull a number of int objects representing the minute, hour, day, week or month of the year. In order to build this app I created a listview showing the previous data.

I have several onClick methods calling my different methods throughout the fragment class I created.

 @Override
public void onClick(View view) {

switch (view.getId()){

case R.id.clockIn_Out_button:

if (CURRENT_STATUS.equals(CLOCKED_IN)) {

clockOut();

} else { clockInFromClick(view); }

break;

case R.id.report_button:

deleteOldData();

boolean infoToReport = createReport();

if (infoToReport) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, recipientOfEmail);
i.putExtra(Intent.EXTRA_SUBJECT, subjectOfEmail);
i.putExtra(Intent.EXTRA_TEXT, bodyOfEmail);

try {

startActivity(Intent.createChooser(i, "Send email..."));

} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(), "No email Client installed", Toast.LENGTH_LONG).show();
}

}else if (reportErrorExplain.equals("You must fill out your name in settings") || reportErrorExplain.equals("You must fill out an email recipient in settings")) {
Toast.makeText(getActivity(), reportErrorExplain, Toast.LENGTH_SHORT).show();

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
((MainActivity)getActivity()).loadSettingsFrag();

}
}, 2000);

}
else {

Toast.makeText(getActivity(), reportErrorExplain, Toast.LENGTH_SHORT).show();
}

toReport.clear();

clearScreen();

break;

}

}

My big mistake was not breaking down the data processing into smaller more usable methods. Instead I ended up with two lengthy methods for pulling data from the device and making a human readable list. One of these methods serves the device users list. The other serves a method which creates the email to be sent. See below!

&lt;pre&gt;
public void createList()
{

    eachDaysData = new String[20];
   String s;
   String[] d = new String[20];



    for (int i = 0; i &lt; 20; i++) {


       s = ((MainActivity)getActivity()).createCalendarDate(i);

        //Log.i("createdates: ", s);

        d[i] = ((MainActivity)getActivity()).getData(s);      //at this point d has each days raw data



    }


    for (int i = 0; i &lt; d.length; i++) {

        if (i == 0 &amp;&amp; CURRENT_STATUS.equals(CLOCKED_IN)){
            String q = ((MainActivity)getActivity()).createCalendarDate(i);
            eachDaysData[i] = q + "\n" + "CURRENT STATUS: CLOCKED IN";
        }


        else if (!d[i].equals("")){

           String min = "";
           String myHr = "";
            String prevHour = "";
            String prevMinute = "";
            String startTime = "";
            String endTime = "";
            String timeWorked, timeBreaked;
            int pHr,pMt, Hr, Mt;
            int cumHrW = 0;
            int cumMinW = 0;
            int cumHrB = 0;
            int cumMinB = 0;
            String currLoc ="", nextLoc ="";

            boolean inEvent = true;

            Log.i("createList: ", d[i]);

            String[] e = d[i].split(DELIM_O);    //e[0] = "clockedin_13_53, e[1] = "clockedout_13_53

            for (int j = 0; j &lt; e.length; j++) {

               String[] p = e[j].split(DELIM_I);  //p[0] = clockedin p[1] = 13 p[2] = 53 p[3] = "some location"

                if (p.length == 4) {

                    addToRecentLocations(p[3]);
                   // Log.i("location found", "true");
                }

                if (startTime.equals("")) {                                                        //this does start time

                    String marker = "am";

                    int t = Integer.valueOf(p[1]);
                    if (t &gt; 12){  t+= -12; marker = "pm"; }
                   myHr = String.valueOf(t);

                    t = Integer.valueOf(p[2]);
                    if (t &lt; 10){min = "0" + String.valueOf(t);}
                    else {min = String.valueOf(t);}


                    startTime += myHr + ":" + min + marker;
                }
                if (j == e.length-1){                                                               //this records endtime


                    if (p[0].equals(CLOCKED_IN)){



                    }else {


                        String marker = "am";

                        int t = Integer.valueOf(p[1]);
                        if (t &gt; 11) {
                            marker = "pm";
                        }
                        if (t &gt; 12) {
                            t += -12;
                        }
                        myHr = String.valueOf(t);

                        t = Integer.valueOf(p[2]);
                        if (t &lt; 10) {
                            min = "0" + String.valueOf(t);
                        } else {
                            min = String.valueOf(t);
                        }

                        endTime += myHr + ":" + min + marker;

                    }

                }



               if (j != 0) {

                 //  Log.i(TAG, "createList: " + prevHour);
                 //  Log.i(TAG, "createList: "+ prevMinute);
                 //  Log.i(TAG, "createList: " + p[1]);
                 //  Log.i(TAG, "createList: " + p[2]);


                   pHr = Integer.parseInt(prevHour);
                   pMt = Integer.parseInt(prevMinute);
                   Hr = Integer.parseInt(p[1]);
                   Mt = Integer.parseInt(p[2]);

                   if (!inEvent) {

                       cumHrW += Hr - pHr;

                       cumMinW += Mt - pMt;
                   }else {
                       cumHrB += Hr -pHr;
                       cumMinB += Mt -pMt;

                   }


               }


                prevHour = p[1];
                prevMinute = p[2];



                inEvent = !inEvent;

            }

                   //this is where we put what we figured out into text

            if (cumMinW &gt; 60) {

                cumHrW += cumMinW /60;
                cumMinW = cumMinW%60;
            }else if (cumMinW &lt; 0 ){
                cumMinW = -cumMinW;
                cumHrW =cumHrW - 1-( cumMinW/60);
                cumMinW = 60 - cumMinW%60;
            }


            if (cumMinW &lt; 10){min = "0" + String.valueOf(cumMinW);}
            else {min = String.valueOf(cumMinW);}

           timeWorked = " " + String.valueOf(cumHrW) + ":" + min + " Total Time Worked";

            if (cumMinB &gt; 60) {

                cumHrB += cumMinB /60;
                cumMinB = cumMinB %60;
            }else if (cumMinB &lt; 0 ){
                cumMinB = -cumMinB;
                cumHrB = cumHrB- 1 -(cumMinB /60);
                cumMinB = 60 - cumMinB%60;
            }

            if (cumMinB &lt; 10)
            {min = "0" + String.valueOf(cumMinB);}
            else  {min = String.valueOf(cumMinB);}
               timeBreaked = " " + String.valueOf(cumHrB) + ":" + min + " Total Breaks ";

            String q = ((MainActivity)getActivity()).createCalendarDate(i);

            Log.i("createList: ", q);

            eachDaysData[i] = q + "\n" + startTime + " - " + endTime + " Start and Finish" + "\n" + timeBreaked + "\n" + timeWorked;



        }else  {


           String q = ((MainActivity)getActivity()).createCalendarDate(i);

            eachDaysData[i] = q + "\nNo work performed";


        }

    }



}

After all said and done though its working perfectly. I’m debugging it now and tracking time on my different projects. My pan is to release it on google play store and maybe figure out a way to market it a bit better than just waiting for people to search it.

 

The post Easy Time Card appeared first on SignalHillTechnology.

Powered by WPeMatico