Agras Zeta Atino

Un blog mas de tecnologia, locuras y procrastinacion

Git repository from scratch | Creando un repositorio GIT desde cero

Just go to the end of the post if you dont wanna read all of it
So you’ve been playing with git, and you’ve already done the common thing:

$ git init
$ git add .
$ git commit

And then, you decide to upload your code somewhere else than github, gitorius or anywhat lets you use git (and where the workflow is: first create the repo, clone, then develop). That’s when you meet it, the hell… Its very annoying specially when you just want quick development, and what you really need is to start something, after you finish you decide to track the code, and then you see yourself in something like this:

$ mkdir ../myproject-new
$ cd ../myproject-new
$ git init
$ mv ../myproject/* .
$ git add .
$ git commit

And then, you meet the unconfortable truth, you dont have a bare rep to push your changes… so you kind of start over, to create a new repo so you can clone from it (although its empty) then add your files, commit and push… An easy way to do this would be like this:

Say you have a local branch, no other locations to pull from or to push to, your only working copy, and want to upload somewhere… before going into the git init|add|commit|clone|add origin hell just do this within your working copy:

git clone --bare $(pwd) git://server.com/path.git

And that’s it, this will create a new bare directory under the the path you specified… with no additional setup, and no madness. So you can ask your team members to just clone from server.com/path.git and that’s it… Painless

Recently i found myself having to generate a md5 hash to specific lines in a file… after googling a while (being addicted to automation more than repeating myself) i came with this simple solution in perl:

1
perl -M'Digest::MD5 qw(md5_hex)' -e 'print md5_hex("`date +%d%m%y`")'
view raw md5.sh This Gist brought to you by GitHub.

This is a post of the series: How I.
Este es un post simple en la serie “Como yo“.

The idea for now is to show JSON strings in a fashion way so that we can read complex JSON strings easier, ill show some ways, its up to you which one to use.

La idea es poder ver cadenas JSON en una forma bonita y sencilla de leer complejas cadenas JSON, de una forma realmente sencilla. Mostrare algunas formas, tu decides cual te conviene.

Python:

cat file.json | python -mjson.tool

Perl:

cat file.json | perl jsonpp.pl
1 2 3 4 5 6 7 8 9
#!/usr/bin/env perl
 
use JSON;
 
my $json = JSON->new;
undef $/;
while (<>) {
print $json->pretty->encode($json->decode($_));
}
view raw jsonpp.pl This Gist brought to you by GitHub.

ps: Most of the info comes from a post at endpoint’s blog

Social links powered by Ecreative Internet Marketing