Literary Awards–part 3–data

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

The data – this was the difficult part. As I said, I wanted the data to be local – but how can I put the first time ? And where ? I cannot be cookie, since the authors are a large database for cookies…

There are 3 options : LocalStorage, WebSql and IndexedDB . You can read about those at https://nolanlawson.com/2015/09/29/indexeddb-websql-localstorage-what-blocks-the-dom/ . I choose LocalStorage because it was simpler – however, this is making the startup of the application slower!

Now, how can I store the data ?  For me, a database with select it was fine – but can I find one that works in the browser ? And with javascript ? Apparently, yes! There is a port from C to js of SQLite – https://github.com/kripken/sql.js/ . That means , I can have a SQLIte database and access via Select. Add I can persist too – see https://github.com/kripken/sql.js/wiki/Persisting-a-Modified-Database .

 

With all those, now I am ready to have the Nobel authoirs in my application – but how can I introduce to my application ? The list exists on Wikipedia( https://en.wikipedia.org/wiki/List_of_Nobel_laureates_in_Literature)  and at Nobel site (https://www.nobelprize.org/prizes/literature/) . How can I load those into my SQLite LocalStorage database ?

Here comes another pet project of mine, stankins  . With this I can transform the wikipedia page into this:


db.run("INSERT INTO tableAuthors (Year,Laureate,Languages,Citation,Genres,PictureUrl,LaureateFullWiki,name) VALUES (?,?,?,?,?,?,?,?)", [

"1901",

"Sully Prudhomme",

"French",

'"in special recognition of his poetic composition, which gives evidence of lofty idealism, artistic perfection and a rare combination of the qualities of both heart and intellect"[12]',

"poetry, essay",

"//upload.wikimedia.org/wikipedia/commons/thumb/3/39/Sully-Prudhomme.jpg/75px-Sully-Prudhomme.jpg",

"https://en.wikipedia.org/wiki/Sully_Prudhomme",

"Sully_Prudhomme"

]);

db.run("INSERT INTO tableAuthors (Year,Laureate,Languages,Citation,Genres,PictureUrl,LaureateFullWiki,name) VALUES (?,?,?,?,?,?,?,?)", [

"1902",

"Theodor Mommsen",

"German",

'"the greatest living master of the art of historical writing, with special reference to his monumental work, A History of Rome"[13]',

"history, law",

"//upload.wikimedia.org/wikipedia/commons/thumb/e/e9/T-mommsen-2.jpg/75px-T-mommsen-2.jpg",

"https://en.wikipedia.org/wiki/Theodor_Mommsen",

"Theodor_Mommsen"

]);

Obvious, it is not perfect – but it works!

What can I do with upgrades * because , obvious, each year I should add the Nobel authors ? Nothing simpler: I will modify the name of the database with the application version from package.json

 

In environement.ts ( and in prod)


VERSION: require('../../package.json').version

In the typescript class:


public version: string = environment.VERSION;

Finally , in the create database


this.dbPers = new SQL.PersistentDatabase(

"nobel_v"+this.version,

async function(sender) {

// Initial creation of database if not found

self.createDatabase(sender).then(()=>{

sender.save();

});

},

function(e) {

// Initialization of existing database failed

alert("database failed" + e);

}

);

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

Literary Awards–part 2–design

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

One of the first problem that I was design. How to make a design that works on mobile and web and desktop ? Nowadays, the standard seems to be a menu on the left , that will be hidden when the mobile is rendering  . Also , this menu has three lines that allows to expand / collapse.

There are several resources at https://angular.io/resources .

I have tested all the resources with Window Resizer from Chrome and I was impressed by I was impressed by http://akveo.com/ngx-admin .

I have found the  empty starter kit (https://github.com/akveo/ngx-admin/tree/starter-kit ) and I started to modify

 

There was a learning curve here:

The search –  I did not know how to make the search  that was provided , until I found something that was called “

NbSearchService” – always search for a service …

It was a while until a figured how to add a new page to the existing pages ( and now I copy /paste)

I ended up with a bunch of images (https://github.com/akveo/ngx-admin/tree/starter-kit/src/assets/images )and other resources that were not needed

 

All in all, I think that it is more convenient to choose something simpler and not choose a big framework.

The design was pretty simple: Add links on the right to Nobel prize, Booker prize, others and list the authors / books.

And a search will be convenient to find fast the authors on the main page.

But about the data , next time

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

Literary Awards–part 1–start

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

I was curious to make a project for web and mobile.

The constraints:

1. database just on local, not on a central repository.

2. All with Javascript( OK, TypeScript).,

3. To work on web , mobile, desktop without changing something

 

The purpose of the project was to list the Literary awards – Nobel, Booker, others. ( I maintain myself a list of best books at http://serviciipeweb.ro/propriu/best-of/ )

You can see the final result at ( It is missing the desktop application – but – can you help me with that  – Electron ):

Site Web:https://ignatandrei.github.io/LiteraryAwards/

Google Play :https://play.google.com/store/apps/details?id=com.msprogrammer.com

Amazon :https://www.amazon.com/AOM-Literary-Awards/dp/B07HPFSZ4C/

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

 

In the next blog posts I will show how I made this application – and problems / features / ideas. .

Chrome extensions in 2018

  1. BehindTheOverlay  –  removes the overlay popups
  2. Export all extensions –  exports the extension to a list like those
  3. Export for Trello – exports in CSV format
  4. FoxClocks – to see the hour around the world           
  5. Image Checker – to see if we should resize the image
  6. JSONView – to have a nice view of hson           
  7. New Tab Page for Trello –  for seeing all task fast
  8. OneTab – instead of Google bookmarks
  9. Project Naptha – to copy text from images
  10. Puppeteer Recorder – record for Chrome
  11. Quick Language Switcher – if some site requires english / french
  12. Text Mode  – to see without ads
  13. Timeline Support –  to have the browsing history on Windows 10
  14. Todoist: To-Do list and Task Manager  – for small tasks
  15. Trello – for adding fast to trello

Latest commits notes from github

For AOP with Roslyn I want to automatically get the latest commits message before doing a new commit.

This was  solved easily using https://github.com/octokit/octokit.net 

The code is  very simple:

public async Task<DateForCommit[]> BetweenLatest2Commits()
{
           
var client = new GitHubClient(new ProductHeaderValue("GitBetweenCommits"));
var rep = await client.Repository.Get(Author, RepositoryName);
var relLatest = await client.Repository.Release.GetLatest(rep.Id);
var relAll = await client.Repository.Release.GetAll(rep.Id, new ApiOptions() { PageSize = int.MaxValue - 1 });
var relBeforeLatest = relAll.OrderByDescending(it => it.CreatedAt).Skip(1).FirstOrDefault();

var dateLatest = relLatest.CreatedAt;
var dateBeforeLatest = relBeforeLatest.CreatedAt;

var commits = await client.Repository.Commit.GetAll(rep.Id, ApiOptions.None);
var res = commits
    .Where(it => 
    it.Commit.Author.Date >= dateBeforeLatest
    &&
    it.Commit.Author.Date<=dateLatest
    )
    .Select(it => new DateForCommit()
    {
        Author = it.Commit.Author.Name,
        Message = it.Commit.Message,
        CommitDate = it.Commit.Author.Date.DateTime
    })
    .ToArray();
return res;
}

It works also as a .NET Global tool
Install with

dotnet tool install –global dotnet-gcr

run with

dotnet gcr

for example for https://github.com/ignatandrei/AOP_With_Roslyn the arguments are

dotnet gcr ignatandrei AOP_With_Roslyn

NuGet at https://www.nuget.org/packages/dotnet-gcr/

Full Code at https://github.com/ignatandrei/GitCommitsBetweenReleases
enjoy

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.