Git: Living on the Edge isn’t for the Dumb

As you may know I’ve been using git as my primary ftp, version control and way to put my projects online for public access and viewing. However, there is a very important thing when considering using these great technology: .gitignore.

Now, when using oAuth, you need a client identity and a client secret. For me, I don’t want to hard code them because that will make them publicly accessible so I stored them in a json file. I thought I followed ignoring the json by adding

^(.*)/secret.(.*)$

to the .git/info/exclude file, however I did not do it right
as ^(.*)/secret.(.*)$ is different than ^(.*)secret\.(.*)$ and quite possibly is completely incorrect

Now first i uploaded it to github, only to find that the file was still there. This through to a flurry as for the last three commits I had assumed everything was peachy clean (I am still learning everything so I don’t hate myself for it. Luckily I was able to find this tutorial on github.

Not only was I able to remove my secret from the commit, but also able to add to the .gitignore in a simple manner. My fears relaxed and a feeling for relief ensued.

Just to add to the security, I also made a proper .htaccess to hide the file

RewriteEngine On
RewriteRule ^(.*)secret\.(.*)$ /404 [L]

 

Version Control: Setting Up Git on Godaddy

So one of the things I’d prefer to do is to work on my website locally then push to github and my server. Easy to say like most concepts…

Now at times I just don’t want to figure things out, as such I chose to use someone elses work. This is a great Article on it. Now despite following the tutorial to a T I ran into issues, not because its a bad tutorial, because for anything, the amount of work and research that goes into something like this is very very very commendable. No work should ever be downplayed, though Its important to look at what is flawed.

I’m not going to rewrite the article but theres a few peices you will want to keep in mind
1) When editing your files from the shell, your most likely going to have to use vi the reason for this is you would have to install other file editors to use them
2) The Command

git remote set-url origin ssh://username@domain.com/~/repo/app_name.git

is actually

git remote add origin ssh://username@domain.com/~/repo/app_name.git

this may seem small, but you’ll be running into headaches if you don’t pay attention

3) if you’d like to include github to the mix, I’ll want to setup an ssh key for github https://help.github.com/articles/generating-ssh-keys

then in a similar fassion

git remote add github git@github.com:UserName/Repository.git

4) Get used to the following commands
-As I’m relatively new to git, I kinda learning the important aspects

Remember to change your directory to the working directory

cd /Path/to/your/local/repository
git add .
git commit -m "your message" .
git push github master
git push origin master

I might store this in a script that I’ll just run as needed

Hello World: Github

So I need to create an application to interact with Github
What I want…

  1. The Current Users Available Repos-Save the User ID
  2. Ability to access a specific Repo-Save the Repo ID
  3. Ability to show work done on that repo

Following the API, here are the basics

GET https://api.github.com/users/formula1/repos with a header specifying version 3

Click to get Current Repos
Click for something pretty
Click to hide

Now this is good for just me, but what about anyone who want to clock in? I need to authenticate… I’ll get to this later

Now, to be able to choose a repo and see the work Click Here

Now the instance work isn’t nearly as important since I can’t quantify that quite same as I can quantify times. However, that is possible as well.

 

Heres the Source code. Simple but straight forward.

jQuery(function(){ jQuery(".githubrepo").click(function(e){  e.preventDefault(); 
 jQuery.ajax({
 url: "https://api.github.com/users/formula1/repos",
 type: "GET",
 beforeSend: function(xhr){
 xhr.setRequestHeader('Accept','application/vnd.github.v3.full');
 },
}).done(function(content){ 
 jQuery("#github-repos-example").text(JSON.stringify(content)); 
 }); 
});
jQuery(".githubpretty").click(function(e){ 
 e.preventDefault(); 
 jQuery.ajax({
 url: "https://api.github.com/users/formula1/repos",
 type: "GET",
 beforeSend: function(xhr){
 xhr.setRequestHeader('Accept','application/vnd.github.v3.full');
 },
}).done(function(content){ 
 for(var i=0;i<content.length;i++){
 jQuery("#github-repos-example").append("<span style='display:inline-block; padding:10px; background:#000; color: #FFF;margin:1px;'>"+content[i].full_name+"</span>");
 }
 }); 
});

jQuery(".githubhide").click(function(e){
e.preventDefault();
 jQuery("#github-repos-example").text("");
});
jQuery(".githubproj").click(function(e){
 e.preventDefault(); 
 jQuery.ajax({
 url: "https://api.github.com/users/formula1/repos",
 type: "GET",
 beforeSend: function(xhr){
 xhr.setRequestHeader('Accept','application/vnd.github.v3.full');
 },
 }).done(function(content){ 
 jQuery("#github-repos-example2").text("");
 for(var i=0;i<content.length;i++){
 jQuery("#github-repos-example2").append("<a href='"+content[i].url+"/commits' style='display:inline-block; padding:10px; background:#000; color: #FFF;margin:1px;'>"+content[i].full_name+"</a>"
 );
 }
 jQuery("#github-repos-example2>a").click(function(e){
 e.preventDefault();
 jQuery.ajax({
 url: jQuery(this).attr("href"),
 type: "GET",
 beforeSend: function(xhr){
 xhr.setRequestHeader('Accept','application/vnd.github.v3.full');
 },
 }).done(function(content){ 
 jQuery("#github-repos-example2").text("");
 for(var i=0;i<content.length;i++){
 jQuery("#github-repos-example2").append("<div style='border:1px solid #000;'><span>Date: "+content[i].commit.committer.date+"</span><br/><span>Name: "+content[i].commit.committer.name+"</span><br/><span>Message: "+content[i].commit.message+"</span></div>"
 )
 }
 });
 }); 
 }); 
});
});


 

Clock In: Top Down Design

One of the major components that made my old site special was my clockin service. What it offered was for me to be able to clockin to any of my projects, this saved a start time. That started a listener (Imagine a machine that waits for something to happen before it does what it does) for any new file being created to see what work I did. Then On clock out, stop the listener and save a stop time.

Pseudo Code

Now Overall here is the Way it works
1) As a User, I choose from a variety of projects or have the ability to start my own
2) I then clock into that project
2a) The start time is saved
2b) A listener to see what work I’ve done is created
3) Once I’m done I clock out
3a) The stop time is saved
3b) The listener is stopped

On top of that other people can go through the various projects and users to see their start and stop times as charts
1) Daily
2) Weekly
3) Monthly

UI

For UI, this is something basic to go off of
UI (2)UI (1)UI

 

FlowChart

For Flow Charting This is what I’m Looking At

UI (3)UI (4)

Objects

User
-ID-Integer (Auto Increment)
-Projects they can edit-Array[ProjectID] (If a project is deleted, this needs to be updated)

Project
-ID-Integer (Auto Increment)
-String-Path/URL/Location to start listener (must be real)

ClockIn
-ID-Integer (Auto Increment)
-User-UserID
-Project-ProjectID
-StartTime-Date
-EndTime-Date

Work
-Id-Integer(Auto Increment)
-Clockin-ClockIn ID (Dependent, if its Clockin is deleted, its deleted)
-Time-Date
-Type-Create, Save, Delete (Research may also be included)

Technology

Now this is all pretty straight forward, lets take a look at what technology we want to use

  1. User-Whatevers convenient, Preferably WordPress considering that’s my cms
  2. Project-Github Github and Github
    -Github is the standard of version control. As a Result, we want people to use good things, the best of things in addition to user our clockin service.
  3. ClockIn
    -This is something I realized is a bit of an issue. I can have hundreds of Clockins which isn’t necessarilly a problem. But what Is a problem is when I lose my data when my server goes down. Or even when I transfer servers like I’m doing now. Though I don’t want to use a third party service I fear I may have to.

    I generally like to use technologies I will most likely use later so…

    So I have 3 choices…

    1. Google Spreadsheets
    2. MongoDB
    3. Google Calander
  4. Work
    -Though My old system was based off of the servers file system, the system I want to create is more likely to be based off of Github. As such I need to be able to grab from github whatever they do. That means pull requests, pushes, etc. I need to tell my people, push often 😉

So…
User-GIthub
Project-Github
Clockin-Google Calander for now (as it is the most reusable technology)
Work-Github