Cmd #5 [Git]

Petit pense-bête pour la suppression du dernier commit local dans Git. A utiliser donc pour le cas où l’on a pas encore effectué un git push.

git reset --soft HEAD~1

L’option soft permet de conserver les modifications apportées aux fichiers que « contenait » le commit. Si on souhaite simplement se débarrasser de l’ensemble, on pourra utiliser l’option hard.

Par ailleurs, si le commit a été poussé vers le serveur et que quelqu’un a déjà effectué un git pull, il faudra passer par un revert:

git revert HEAD

Cover Picture Background

I wanted to display a picture in the background of a page for a project of mine. I’ve already used this solution twice. It works good and looks really great.

Here is the code using the property background-size from CSS3.

body {
  /*Full picture in the background.*/
  background: url(background.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

So, as an example, this is the original picture I’ve used.

Original Picture
French singer Martial from the band Manau.

And this is how it looks when used as a cover picture in my project Orchestre.

fullScreenBackground

[SQL] Count results from stored procedure (without return)

It’s been a while since I haven’t used SQL. Now that I’m using it on a daily basis at work, I may write a little more about SQL than before. So here is an article the aim of which is to show how to find the number of results returned by a stored procedure. It’s in fact a problem which can be easily solved.

So let’s say we have a table containing animals names. Nothing fancy, just something like this:

name
----
Cat
Dog
Rabbit

That’s it for the table. Now we need a stored procedure, so let’s assume we have one : findNameLike which take letters as parameter and returns animals names beginning with these letters.

EXEC findNameLike @beginWith = N'C'

Cat.
Yes, the above call will return Cat.

So, if we want to know how much results were found, we will just write the following code:

DECLARE @numberOfMatch INT
EXEC findNameLike @beginWith = N'C'
SELECT @numberOfMatch = @@ROWCOUNT

The number of results is now available in variable numberOfMatch.

That’s it.
But maybe you also don’t want the stored procedure to return results when you call it. So we need to modify our code a little so that results will be stored in a temporary table and thus not returned, but rather stored in the table.

DECLARE @numberOfMatch INT
DECLARE @tmpTable TABLE (
    name VARCHAR(25)
)

INSERT INTO @tmpTable 
EXEC findNameLike @beginWith = N'C'
SELECT @numberOfMatch = @@ROWCOUNT

I think we’re done here. In a few lines, we’re able to count the results from a stored procedure as well as suppressing its return.

Proxy

Lorsqu’on travaille derrière un proxy, on se retrouve vite à devoir configurer nos outils pour être certain que leur trafic passera bien par celui-ci. Voici donc quelques paramètres de configuration pour répondre à ce problème.

GNU/Linux

Les variables d’environnement qui nous intéresse sont les suivantes:

  • http_proxy
  • https_proxy
  • ftp_proxy
  • no_proxy

On peut également les retrouver en majuscule: HTTP_PROXY par exemple.

La configuration s’effectue de la manière suivante dans un terminal:

export http_proxy=http://yourproxyaddress:proxyport
export no_proxy='127.0.0.1, *.local'

Pour visualiser le contenu d’une variable:

echo $http_proxy

GNOME

gsettings set org.gnome.system.proxy ignore-hosts "['127.0.0.1','*.local' ]"

APT-GET/APTITUDE

Si aptitude n’utilise pas le proxy défini au niveau système pour une raison ou une autre, on peut modifier le fichier /etc/apt/apt.conf pour y ajouter la ligne suivante:

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

GIT

git config --global http.proxy http://yourproxyadress:port
git config --global https.proxy http://yourproxyaddress:port

Si le proxy bloque le protocole git://, on force l’utilisation de http:// :

git config --global url."http://".insteadOf git://

Et en cas de problème avec le protocole https://, on peut envisager :

git config --global http.sslVerify false

WINDOWS

NPM

Dans le fichier .npmrc, ajouter les lignes:

proxy=http://yourproxyadress:port
strict-ssl = false

BOWER

Dans le fichier .bowerrc, ajouter les lignes:

{
  "proxy":"http://yourproxyadress:port",
  "https-proxy":"http://yourproxyadress:port"
}

[Xorg] no screens found

During my previous installation of Arch Linux, I encountered the « error no screens found » when trying to launch X graphic server. It took me a couple hours to understand that my motherboard had « embedded graphic functionality ». So in order to solve my problem, I had to deactivate Intel pilot from the motherboard in the BIOS, so that the system would use the graphic card instead. So an easy solution in my case, but it seems that this error can be obtained in a wide variety of case. If you’re reading this having a similar problem, I hope you’ll find a solution.

Useful command to see graphic cards detected by the system:

lspci | grep VGA