Developers Club geek daily blog

Requests in CoreData with aggregate functions and grouping in one line

2 years, 11 months ago
Almost all who uses CoreData, should create requests with aggregate functions and groupings sooner or later. However, syntax of such requests in CoreData is difficult for understanding and is unfairly verbose.

Using the designer of requests we can make, for example, here such request:
NSDictionary *productTotalSumAndAveragePriceGroupedByCountries = 
[[[[[Product all
] aggregatedBy:@[
                 @[kAggregateSum, @"amount"],
                 @[kAggregatorAverage, @"price"]]
] groupedBy:@[@"country"]
] having:predicate
] execute];

This request is equivalent to such:
To request in CoreData
NSFetchRequest *fetchRequest = [[ALFetchRequest alloc] init];
fetchRequest.managedObjectContext = managedObjectContext;

NSString *entityName = @"Product";
NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:managedObjectContext];

[fetchRequest setEntity:entity];
[fetchRequest setIncludesPendingChanges:YES];

// sum amount
NSExpression *fieldExp1 = [NSExpression expressionForKeyPath:@"amount"];
NSExpression *agrExp1 = [NSExpression expressionForFunction:agr arguments:@[fieldExp1]];
NSExpressionDescription *resultDescription1 = [[NSExpressionDescription alloc] init];
NSString *resultName1 = @"sumAmount";
[resultDescription1 setName:resultName1];
[resultDescription1 setExpression:agrExp1];
[resultDescription1 setExpressionResultType:NSInteger64AttributeType];

// average price
NSExpression *fieldExp2 = [NSExpression expressionForKeyPath:@"price"];
NSExpression *agrExp2 = [NSExpression expressionForFunction:agr arguments:@[fieldExp1]];
NSExpressionDescription *resultDescription2 = [[NSExpressionDescription alloc] init];
NSString *resultName2 = @"sumAmount";
[resultDescription2 setName:resultName2];
[resultDescription2 setExpression:agrExp2];
[resultDescription2 setExpressionResultType:NSInteger64AttributeType];

// country
NSDictionary *availableKeys = [entity attributesByName];
NSAttributeDescription *country = [availableKeys valueForKey:@"country"];

fetch.propertiesToFetch = [NSArray arrayWithObjects:country, resultDescription1, resultDescription2, nil];
fetch.propertiesToGroupBy = [NSArray arrayWithObject:country];
fetch.resultType = NSDictionaryResultType;

NSError *error;
NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
NSArray *fetchedObjects = [managedObjectContext executeFetchRequest:self error:&error;];
if (!fetchedObjects || error) {
    NSLog(@"Error: Execution of the fetchRequest: %@, Failed with Description: %@",self,error);
return fetchedObjects;

Read more »

github attracted $250 of the M investments

3 years ago
The TechCrunch edition reports:
GitHub, service for command a vzaimodeytsviya of developers and the control of versions based on the popular Git tool declared attraction of 250 million dollars of investments from Sequoia Capital with the participation of Institutional Venture Partners today.

The total amount of attachments makes 350M of dollars now. The Wall Streat Journal edition estimates the company at 2 billion dollars.

Read more »

OpenSource the project can develop and make profit?

3 years ago
Already quite long time I ask a question: Whether "Open Source the project can live and develop in our severe realities?". This question periodically disturbs me as I am the author of one such project — WysiBB. I asked a similar question on different resources, there were questions and on the Toaster. But in fact everything was reduced to the fact that in a Russian-speaking segment of the Internet the buttons "Support the Project", "Offer", etc. do not work and only projects with huge audience and/or paid functions can develop.


In what essence?

But here at last one fine day, I came across interesting idea as it is possible to receive some financial injections in development and to see what features are most demanded by users. I saw this idea on the website Robomongo (who does not know, it is GUI for MongoDB). And its essence consists in the following: the user is given an opportunity to select from the issues list (from a dzhitkhab) most it disturbing and to offer funds for its completion. When the user does a donation, the rating of priority of this feature raises. So the author of the project receives funds for the purse and sees what features have the top priority (most of all donations) and respectively are the most demanded. The author starts their development first of all, the project develops, and the user receives a long-awaited feature. This idea was pleasant to me and I decided to implement the similar mechanism on the project and when began work on this service, understood that such service can be useful not only to me. So GitFund was born.

Read more »

Shadow DOM: specification

3 years, 1 month ago
Andrey Glazkov, Ito Hayato from Google, and also other specialists on Github work on engineering characterization of Shadow DOM. Huge work is already done, however it is necessary to make a lot. Within support of work on this direction transfer of the existing version of the specification of July 7 is created.

This specification describes way of association of several DOM trees in one hierarchy, and interaction of these trees with each other in one document that allows to construct DOM more correctly.

Read more »

7 steps to start of gh-pages for the AngularJS-projects created by means of Yeoman

3 years, 1 month ago
In this publication I will tell how to create GitHub Pages for AngularJS-projects which have been created by means of Yeoman generators. gh-pages is convenient to that allows to see visually the web page, but not its source code. As it is written in the description of gh-pages, they are used for static HTML pages [1]. However, and in case of AngularJS-framework, gh-pages can be useful.

Read more »

Secrets of the lost kommit in Git

3 years, 1 month ago
Git — piece not that especially difficult, but flexible. Sometimes this flexibility leads to amusing effects. For example, look at this kommit on GitHub. It looks as normal kommit but if you clone to yourself this repository, such kommit in it will not find. Because it is lost kommit, better known as git loose object or orphaned commit. Under cat — it is a little about Git interiors, from where such undertakes and what to do if it to you has met.

Read more »

Mission of AllMyChanges

3 years, 1 month ago
When our project only arose, it was based on hypothesis that almost for any library it is possible to find changelog and if it is impossible to find, it is possible to construct it of the kommit-messadzhy. But the reality was not so iridescent as we wanted that: that the changelog file in any ugly format will get, it have ceased to conduct, and the product meanwhile develops, something else. And then we have understood that to rasparsit the world – a little, it is necessary to change it.

To change something for one instant — extraordinary complex challenge

Therefore we do not set to ourselves such purpose. Mission of AllMyChanges in letting to developers of the whole world know that ChangeLog it is their way of interaction with the outside world, the same channel as the blog or the twitter account.

Mr. Speaker

Before emergence of our service, it was difficult to compare simple ChangeLog to the blog as there was no way to subscribe for updatings. After all the link to rss fid the blog it is possible to throw the eReader in rss, on sotsprofil it is possible to subscribe, having followed the person, and it was difficult to subscribe for changes of library.

Read more »

Correction of mistakes — phppgadmin

3 years, 3 months ago
One of our clients has set the task — the database dump through phpPgAdmin is not filled in. In log of errors messages of type are displayed: ERROR: relation "public". "company" does not exists.

The scheme public is available, the table company is not present. In the course of search it becomes clear that via the console the same dump is filled in without problems. If to load into web form in phpPgAdmin — that too everything fulfills. But here if to load this dump into the same phpPgAdmin as the file — there are errors.

Read more »

The polite invitation to development

3 years, 4 months ago

You criticize – offer

Us quite often abuse on Habrakhabr that articles insufficiently technical, and the description of program runtime is badly detailed. But actually each reader understands that to describe all in one post – it is simply impossible because some years development of DRP went in set of the directions.

The part from them is connected directly with executable file, notorious .ekhe'shnikom; another – with creation of archive and that is important, index of drivers; the third – with application testing and separate versions of drivers for the different equipment both on different versions of Windows OS, and on iron racks. We give part from these solutions to testing to the users who have shown special interest.

Read more »

Google Code is closed and suggests all to pass to GitHub

3 years, 5 months ago
To all owners of projects the corresponding letter came to Google Code.
The reduced transfer of news:
Since today, we stop a possibility of creation of new projects on Google Code. Service will be closed approximately in 10 months by January 25, 2016. Links to the instruments of migration designed to help you to transfer your projects are listed below.

12 Marta, 2015 — Creation of new projects is turned off.
On August 24, 2015 — Transition to the mode "only for reading".
On January 25, 2016 — service Closing. Downloading of archive of the project including the source code, the bug tracker and Wicky will be available. The archive will be available until the end of 2016.

Google will continue to provide Git and Gerrit a hosting for such projects as Android and Chrome. We will still support mirrors of such projects as Eclipse, and others.

Read more »