quote

martedì, ottobre 13, 2015

PassportJS - NodeJS login with Facebook

http://passportjs.org/
https://github.com/jaredhanson/passport-facebook/tree/master/examples/login
Create an appId and App secrete from https://developers.facebook.com/
In local development make sure you follow this http://stackoverflow.com/a/26457495/379173
I added localhost:3000 since my node js process was running on port 3000.

Installing postgresql on Ubuntu [Notes]

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
Ubuntu Software center: pgAdmin III

sudo -u postgres -s
$ psql
postgres=# ALTER USER postgres PASSWORD 'xxx';


https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04

http://www.linuxscrew.com/2009/07/03/postgresql-show-tables-show-databases-show-columns/

exit from psql

venerdì, settembre 25, 2015

MongoDB session


enrico@enrico-XPS13:~/mongodb$ mongo
MongoDB shell version: 3.0.6
connecting to: test

> show dbs
enrico     0.078GB
local      0.078GB
nodetest1  0.078GB
test       0.078GB
> use enrico
switched to db enrico
> for (var i=0;i<10 i="" p="" print="">0
1
2
3
4
5
6
7
8
9
> use blog
switched to db blog
> db
blog

> db.posts.insert({
... title: "My first post",
... authorName: "Alvise",
... authorEmail: "enricogiurin@gmail.com",
... pubDate: new Date
...
... });
WriteResult({ "nInserted" : 1 })
> db.posts.count()
1
> db.posts.findOne()
{
"_id" : ObjectId("5604925564958e61b7a10dda"),
"title" : "My first post",
"authorName" : "Alvise",
"authorEmail" : "enricogiurin@gmail.com",
"pubDate" : ISODate("2015-09-25T00:16:21.649Z")
}
> db.posts.insert({title: "another post", "_id": 123});
WriteResult({ "nInserted" : 1 })
> db.posts.count()
2
> db.posts.find()
{ "_id" : ObjectId("5604925564958e61b7a10dda"), "title" : "My first post", "authorName" : "Alvise", "authorEmail" : "enricogiurin@gmail.com", "pubDate" : ISODate("2015-09-25T00:16:21.649Z") }
{ "_id" : 123, "title" : "another post" }
> db.posts.find().pretty()
{
"_id" : ObjectId("5604925564958e61b7a10dda"),
"title" : "My first post",
"authorName" : "Alvise",
"authorEmail" : "enricogiurin@gmail.com",
"pubDate" : ISODate("2015-09-25T00:16:21.649Z")
}
{ "_id" : 123, "title" : "another post" }
> db.posts.insert({
... title: "My first post",
... author: {
... firstName: "Enrico",
... lastName: "Giurin",
... email: "enricogiurin@gmail.com"
... },
... tags: ["coding", "mongodb", "db"],
... pubDate: new Date
...
... });
WriteResult({ "nInserted" : 1 })
> db.posts.find().pretty()
{
"_id" : ObjectId("5604925564958e61b7a10dda"),
"title" : "My first post",
"authorName" : "Alvise",
"authorEmail" : "enricogiurin@gmail.com",
"pubDate" : ISODate("2015-09-25T00:16:21.649Z")
}
{ "_id" : 123, "title" : "another post" }
{
"_id" : ObjectId("5604946d64958e61b7a10ddb"),
"title" : "My first post",
"author" : {
"firstName" : "Enrico",
"lastName" : "Giurin",
"email" : "enricogiurin@gmail.com"
},
"tags" : [
"coding",
"mongodb",
"db"
],
"pubDate" : ISODate("2015-09-25T00:25:17.293Z")
}

> db.posts.find({title: "My fist post"});
> db.posts.find({title: "My first post"});
{ "_id" : ObjectId("5604925564958e61b7a10dda"), "title" : "My first post", "authorName" : "Alvise", "authorEmail" : "enricogiurin@gmail.com", "pubDate" : ISODate("2015-09-25T00:16:21.649Z") }
{ "_id" : ObjectId("5604946d64958e61b7a10ddb"), "title" : "My first post", "author" : { "firstName" : "Enrico", "lastName" : "Giurin", "email" : "enricogiurin@gmail.com" }, "tags" : [ "coding", "mongodb", "db" ], "pubDate" : ISODate("2015-09-25T00:25:17.293Z") }
> db.posts.find({title: "My first post"}).count()
2
> db.posts.find({title: /po/i}).count()
3
> db.posts.find({title: /pos/i}).count()
3
> db.posts.find({title: /first/i}).count()
2
> db.posts.find({title: /first/i},{title:1})
{ "_id" : ObjectId("5604925564958e61b7a10dda"), "title" : "My first post" }
{ "_id" : ObjectId("5604946d64958e61b7a10ddb"), "title" : "My first post" }
> db.posts.find({title: /first/i},{title:1, _id: 0})
{ "title" : "My first post" }
{ "title" : "My first post" }
> db.posts.find({title: /first/i},{title:1, _id: 0}).pretty()
{ "title" : "My first post" }
{ "title" : "My first post" }
> db.posts.find({"author.email": "enricogiurin@gmail.com"}).pretty()
{
"_id" : ObjectId("5604946d64958e61b7a10ddb"),
"title" : "My first post",
"author" : {
"firstName" : "Enrico",
"lastName" : "Giurin",
"email" : "enricogiurin@gmail.com"
},
"tags" : [
"coding",
"mongodb",
"db"
],
"pubDate" : ISODate("2015-09-25T00:25:17.293Z")
}
> db.posts.find({"author.email": "enricogiurin@gmail.co"}).pretty()
> db.posts.find({"author.email": /urin@gmail.co/}).pretty()
{
"_id" : ObjectId("5604946d64958e61b7a10ddb"),
"title" : "My first post",
"author" : {
"firstName" : "Enrico",
"lastName" : "Giurin",
"email" : "enricogiurin@gmail.com"
},
"tags" : [
"coding",
"mongodb",
"db"
],
"pubDate" : ISODate("2015-09-25T00:25:17.293Z")
}
 

sabato, giugno 20, 2015

Ubuntu - Grouping Windows taskbar

Bottom Left - Right click - Properties


giovedì, giugno 18, 2015

Avoiding CORS issues with chromium

Install 'Chromium Web Browser' in ubuntu through Ubuntu Software Center.
From any location type:

$ chromium-browser --disable-web-security &

This avoid limitations of browsers with CORS.

venerdì, giugno 05, 2015

Firefox SSL issue

Questo riepilogo non è disponibile. Fai clic qui per visualizzare il post.

venerdì, maggio 29, 2015

"Venture" Meet Suport Organizations Zurich - May 28th 2015

Here some notes, in random order, taken from the event which took place yesterday at the ETH in Zurich, subject: support for startups in Switzerland.
Question is, with all these private and government agencies,  from what to start with your idea of startup, assuming you have already it?  I feel a bit confused.

giovedì, aprile 23, 2015

Linux/Unix useful commands

  • ls | wc -l (number of files in a folder)
  • $ find . -iname 'Courses.json' -> find in the current folder and subfolders the file 'Courses.json'
  • $ grep MemTotal /proc/meminfo
  • $find . -type f -name '*.DS_Store*' -delete

mercoledì, aprile 01, 2015

git useful commands

################ git commands  ################

$ git config --global user.name "Enrico Giurin"
$ git init --> creates local repo  /users/enrico/store/.git
$ git add xxx
$ git commit -m ".." .
$ git status
$ git add --all .

branch: master
$ git add --all
creates snapshot
$ git log
##############################

$ git diff
$ git reset
$ git reset --hard - undo local changes since that revision
$ git checkout --   (blow way all changes since last commit)
$ git commit -a -m "xxx"  add & commit
$ git reset --soft HEAD               undo last commit
$ git commit --amend -m "..."         changed the last commit
$ git reset --hard HEAD^   undo last commit and all changes
$ git reset --hard HEAD^^  undo last 2 commits and all changes
$ git push
$ git pull
- origin: name of the remote repository
$ git remote add origin https.//github.com/egch/xxx
$ git remote -v
$ git push -u origin master  (origin: remote / master: local)
##############################

$ git clone
$ git clone yourName
$ git remote -v
$ git branch   (cat)
$ git checkout cat
$ git checkout master
$ git merge cat
$ git branch -d cat (removing branch cat)
$ git checkout -b admin (switch and create a new branch)
--> go back to master
$ git checkout master
(fix something in the master and now we merge the admin)
$ git merge admin
vi editor
git log ( a message log related to the merge)
##############################

$ git pull  (fetch)

$ git push
$ git commit -a -m "merged"(after merge)

<<<<< my version
>>>>> their version

##############################
$ git checkout -b shopping_cart
$ git push origin shopping_cart
$ git push
[jane] $ git pull
$ git branch
$ git branch -r (remote branches)
$ git checkout shopping_cart
$ git remote show origin
$ git push origin :shopping_cart (to delete the remote branch)
$ git branch -d shopping_cart (trying to delete local branch)
$ git branch -D shopping_cart (force to delete local branch)
$ git remote prune origin (to cleanup delete remote branches)
$ git tag (list all tags)
$ git checkout v0.0.1  (checkout code at commit)
$ git tag -a v0.0.3 -m "version" (to create a new tag)
$ git push --tags (to push the tags)

########################################
$ git log
$ git config --global color.ui true
$ git log --pretty=oneline
$ gitl log --pretty=format: "%h %ad- %s [%an]"
(ad=author date, an=author name,h=SSH hash, s=subject,d=ref names)
$ git log --online -p
$ git log --online --stat
$ git log --online --graph
$ git log --since=2000-02-02 --until=2003-10-10
$ git diff
$ git diff HEAD~5  (5 commits ago)
$ git diff master bird
$ git diff --since=1.month.ago --until=2.minutes.ago
$ git blame list.html --date short
.git/info/exlude : to esclude some files from commit
pattern: logs/*.log
.gitignore  (logs/*.log)
$ git rm README.txt
$ git rm --cached mylog.log
$ git config --global core.editor notepad++
ALIASES
$ git config --global alias.mylog "log --pretty=format:'%h %s [%an]' --graph"
$ git myLog

giovedì, marzo 26, 2015

Windows 32-64 bit

http://windows.microsoft.com/en-us/windows7/find-out-32-or-64-bit
Vista: Click the Start button , right-click Computer, and then click Properties.