Skip to content

Instantly share code, notes, and snippets.

View patarkf's full-sized avatar

Patrick Ferreira patarkf

View GitHub Profile
@patarkf
patarkf / git_to_deploy
Last active August 29, 2015 14:15
GIT to deploy website
Hey, folks. Below, the steps that I followed (after a little search on the web) to deploy my application
(website) using GIT, on the cleanest and easiest way. The advantage of this method is that any small
change pushed to remote repo will be published in your live website.
Step 1: Create the local GIT repository
$ cd /var/www/project/
$ git init
$ git add *
/* A little snippet to see how to integrate another ajax request data with Google Chart API using JQuery */
var = DOM {
/**
* Function that initialize all
* @return {[void]}
*/
onReady: function() {

Step by step to install Scala + Play Framework in Ubuntu 14.04 with Activator.

Install Scala

sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.6.deb
sudo dpkg -i scala-2.11.6.deb
sudo apt-get update
sudo apt-get install scala
@patarkf
patarkf / nodejs-promises-example.js
Last active June 12, 2017 14:43
Promise request example
function getFromGitHub() {
const userName = 'patarkf';
const url = 'https://api.github.com/users';
fetch(`${url}/${userName}/repos`)
.then(reposResponse => {
return reposResponse.json();
})
.then(userRepos => {
console.log(userRepos);
async function getFromGitHub() {
try {
const userName = 'patarkf';
const url = 'https://api.github.com/users';
const reposResponse = await fetch(`${url}/${userName}/repos`);
const userRepos = await reposResponse.json();
console.log(userRepos);
} catch (error) {
console.log(error);
async function myAsyncFunction() {
const result = await somethingThatReturnsAPromise();
console.log(result);
}
async function myAsyncFunction() {
try {
const result = await somethingThatReturnsAPromise();
console.log(result);
} catch (error) {
console.log(error);
}
}
function makeRequest() {
try {
fetch('foo')
.then(response => {
const result = JSON.parse(response);
console.log(result);
})
.catch(error => {
console.log(error);
async function makeRequest() {
try {
const result = JSON.parse(await fetch('foo'));
console.log(result);
} catch (error) {
console.log(error);
}
}
function makeRequest() {
return fetch('foo')
.then(response => {
if (data.doesItNeedAnotherRequest) {
return makeAnotherRequest(response)
.then(secondResponse => {
console.log(secondResponse);
return secondResponse;
});