Assuming that you have a created a respository by cloning or initialisation and you want to add content to the repository. Open a terminal and from the command prompt enter the following command:
First go into your working folder where the repository has been initialised, and create an index.html file with a text “Hello, World!” and then give the command git add to add the index.html file.
Please note when adding files to the repository it will not affect the latest version until you give it the commit command, I will discuss the commit command in my next post.
Next if you wish to add multiple files at the same time you can do the following:
$git add .
The dot or period “.” means all files that hasn’t been added to the repository.
To create a repository from an existing folder you need to enter the following command in your terminal:
$mkdir HelloWorld
$cd HelloWorld
$git init
First command is to create a new folder called HelloWorld, then change directory to HelloWorld. Now inside the HelloWorld folder we enter the command git init to initial the repository.
After the repository have been initialised Git will place all the revision information into a hidden folder called .git, so now we have a new local repository.
Facade Pattern is a class (complex system) that contains multiple instances of objects (subsystem) each of these objects has its own methods that perform certain tasks. Inside the complex system class it can have one or more methods that wraps one or more subsystem object methods.
To demonstrate this I will use a Car as an example, building car consist of several process or subsystems to build the parts such as wheels, seats, engines and the body. The main system or complex system is to assemble the car.
Below I have a class called Body, Engine, Seats and Wheels, and each of these class contain a method to add certain parts.
The Body class contains a method called AddBody() which takes a enumerated type of BodyType, the body type can be either a sedan, hatch or a suv.
public class Body
{
public Body ()
{
}
public void AddBody(BodyType bodyType)
{
Console.WriteLine ("{0} Body Added", Enum.GetName(typeof(BodyType), bodyType));
}
}
The Engine class contains a method called AddEngine() which takes an integer value to specify the engine’s cyclinder.
public class Engine
{
public Engine ()
{
}
public void AddEngine(int cyclinders)
{
Console.WriteLine("{0} Cylinder Engine Added", cyclinders.ToString());
}
}
An Object Adapters is a wrapper class the wraps an old object that needs data manipulated before the new object can use it, just like you would with a real life object such as an electronic device where main power plugs are different in each country, so you will need a power adapter to plug it in. This post I will demonstrate one type of adapter which is the object adapter, this type of adapter basically contains an instance of the object that needs adapting or also known as the adaptee.
Lets put this into a real word situation where you have an old class called OldPerson which only allows you to set and get a person name by calling a member method called SetFullName() and GetFullName(). In the new system you have a new class called Person which only takes First and Last name as strings. So what do we do you ask, we need to write a PersonAdapter class!
The Person class implements the IPersion interface which contains four methods, SetFirstName(), GetFirstName(), SetLastName() and GetLastName(). In PersonAdapter class we will implement the IPerson interface so that we have the same implementation as Person class.
public class PersonAdapter : IPerson
{
// code here.
}
In the PersonAdapter class constructer we are going to pass the OldPerson object as a parameter and retrieve the person’s full name. By using the string’s Split method we can separate the first and last name and assign it to the private member variables called firstName and LastName.
I been working on a project recently and one of the pages required a list view from another site from the same site collection. So this is what I had to do to make it work.
var site = SPContext.Current.Site;
var spList = site.AllWeb["yourwebsite"].Lists["listname"];
var xsltLvWp = new XsltListViewWebPart(){
Title = "My Cross Site List View",
WebId = spList.ParentWeb.ID,
ListName = spList.ID.ToString("B").ToUpper(),
ListId = spList.ID,
ViewGuid = spList.Views["View Name"].ID.ToString("B").ToUpper()
}
Git is an awesome source control, there are two sites that allow you to host repositories like GitHub and BitBucket. If you are looking for a free private repository hosting I would recommend BitBucket.
Anyways let’s get started with cloning a repository on to your computer. First you will need some tools, if you are a windows user I would recommend you to get msysgit, and for Linux and Mac you can follow the download instruction from git-scm.com.
I am going to use an existing public repository from GitHub called MonoGame, it’s a cross platform XNA development library for Mono. So open your terminal and enter the following commands:
After the cloning has finish perform a ls -al command in your projects folder and you will see a MonoGame folder created with copies of the source code. Now you have cloned your first Git repository!
If your Mac OS X application has stopped working and you need to force it to quit, you can try pressing Command-Option-Esc to bring up a list of running applications.
I have decided to write a watcher daemon to watch a specified folder for any newly created files or folders. I did some googling and found that it was very simple to create a daemon program in Linux.
First you will need to create your source file and include the following header file:
#include <unistd.h>
In the main function you need to call daemon() like this:
int main()
{
if (daemon(0,0) == -1)
err(1, NULL);
while(1)
{
Do something here....
}
}
In the while loop you can put your own code to perform a specific task.
To run the daemon when your system boots up edit the file /etc/init.d/rc.local and add the following line at the end of the file:
/usr/sbin/yourdaemon
note: make sure the you copied the file to /usr/sbin or else the file can not be found when the system is booting up.
The daemon function parameters, I have specifice 0 for the first paramter to use the root “/” folder instead of the working folder and the second parameter I have done the same which will redirect all standard input, output and errors to /dev/null.
Detailed information on how to use the daemon function can be found here.
To bind a SPList to a binding control list for example the DetailsView data control you will need to provide a DataSource to it. The problem is SPList doesn’t implment the IDataSource interface, but I have discovered that there is a SPDataSource which allows you to pass a SPList object as a parameter in the constructor. Below is a code
var spList = SPContext.Current.Web.Lists["List Name"];
var ds = new SPDataSource(spList);
DetailsView1.DataSource = ds;
DetailsView1.DataBind();