martes, 5 de diciembre de 2017

install your own local git server


This is an easy way of having your  local git server up and running

 * install docker

 $ docker pull jacekkow/gitblit
 $ docker run -d --name=gitblit \
    -p 8080:8080 -p 8443:8443 \
    -p 9418:9418 -p 29418:29418 \
    jacekkow/gitblit


Gitblit interface should be available at http://127.0.0.1:8080/

(user/password: admin/admin)

sábado, 1 de julio de 2017

install dropal in ubuntu server

So, I found a couple of articles, very practical, that explain how to install drupal in a ubuntu linux from scratch. First one is how to install LAMP http://idroot.net/tutorials/install-lamp-stack-ubuntu-16-04/ and the second one is how to install drupal http://idroot.net/linux/install-drupal-ubuntu-16-04/. Just copy and paste command lines in your ubuntu as root, first the LAMP part and second the drupal article.

domingo, 25 de diciembre de 2016

https web server with ubuntu, letsencript and nodejs

sudo apt-get install letsencrypt
letsencrypt certonly --standalone -d example.com

Note: this will generate the following files in folder /etc/letsencrypt/live/example.com: cert.pem chain.pem fullchain.pem privkey.pem

Now you are ready to implement and execute your nodejs https server. Run the following program and then open https://example.com and it should be working without any browser warning, ready for production.

const https = require('https');
const fs = require('fs');

// cert.pem  chain.pem  fullchain.pem  privkey.pem

const options = {
  key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem'),
  cert: fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem')
};

https.createServer(options, (req, res) => {
  res.writeHead(200);
  res.end('hello world\n');
}).listen(443);

Or using http-server command line utility:

http-server . -p 443 --ssl --cert "/etc/letsencrypt/live/example.com/cert.pem" --key "/etc/letsencrypt/live/example.com/privkey.pem"

miércoles, 22 de junio de 2016

writing selenium in javascript node with webdriverio - instructions for impatients

The following is what you need to do in order to write a javascript program that will command your browser through selenium using webdriver.io node library.

 First is about installing and running the selenium server. Second is a little webdriverio example. 

Installing the selenium server

The following instructions are give in a shell script that was tested on mac:
#install java

# download selenium server: 

curl -O http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar

#download googlechrome selenium drivers: 

curl -O http://chromedriver.storage.googleapis.com/2.22/chromedriver_mac32.zip
unzip chromedriver_mac32.zip


#Execute selenium server: 

java -Dwebdriver.chrome.driver=./chromedriver -jar selenium-server-standalone-2.53.0.jar


The Program

From here the instructions are the same as in http://webdriver.io/guide.html - just execute ```npm install webdriverio``` in your node project and execute the following file. In this simple program that will navigate to google and when is ready print the document title in the console:
var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        browserName: 'chrome'
    }
};
webdriverio
    .remote(options)
    .init()
    .url('http://www.google.com')
    .getTitle().then(function(title) {
        console.log('Title was: ' + title);
    })
    .end();

Appendix: Technologies used

  • http://www.seleniumhq.org/ - the infrastructure that talks to browsers (java) 
  • http://webdriver.io/guide.html - the selenium javascript api 
  • http://chromedriver.storage.googleapis.com/index.html - selenium driver to manage chrome browser.
  • java and node

jueves, 19 de mayo de 2016

Minify JavaScript code with esprima and escodegen


var esprima = require('esprima'), 
escodegen = require('escodegen');

function doUglify(s)
{
 try
 {
  var ast = esprima.parse(s);
  s = escodegen.generate(ast, {format: escodegen.FORMAT_MINIFY}) || s;
 }
 catch(ex)
 {
  console.log(ex);
 }
 return s;
}

lunes, 18 de enero de 2016

first steps with postgresql for inpatients

The following is a bash script that show easy steps for getting started with postgresql and verified in a arch linux distribution. There are also some comments for explaining, ideal for inpatients:
DATA_FOLDER=.data
mkdir myproject
cd myproject

initdb -D $DATA_FOLDER

#TODO DONT DO THIS IN PRODUCTION
sudo chmod -R a+wr /run/postgresql/ 

postgres -D $DATA_FOLDER >logfile 2>&1 &

createdb mydb

sábado, 7 de noviembre de 2015

jasmine for node: execute test files and set jasmine timeout globally

When developing jasmine tests in node, I want to declare which files to run. I don't want / like the way of indicating this in a jasmine.json file and it wasn't working as expected.
Also I had some difficulties guesssing how to set the timeout interval globally. Mainly my difficuly was not to now that jasmine was creating a global 'jasmine' object when requiring it.
The following code shows both things:
var
 path = require('path')
, glob = require('glob').sync
, Jasmine = require('jasmine')

var jasmineRunner = new Jasmine();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 99999999;

jasmineRunner.specFiles = glob(path.join(__dirname, '*Spec.js'));
jasmineRunner.execute();