Skip to content

Instantly share code, notes, and snippets.

@agustinhaller
agustinhaller / init-library-tracking.ts
Created September 14, 2020 14:45
Idea de como mejorar el código que carga las librerías de tracking para el Store
import {Injectable, Inject, Optional, Type} from '@angular/core';
import {HammerGestureConfig} from '@angular/platform-browser';
import {MAT_HAMMER_OPTIONS} from '@angular/material/core';
/**
* Noop hammer instance that is used when an instance is requested, but
* Hammer has not been loaded on the page yet.
*/
const noopHammerInstance = {
on: () => {},
@agustinhaller
agustinhaller / angulat-templates.html
Created November 15, 2019 15:23
Angular Templates Examples
<div class="product-expanded-details col-5 col-lg-6" *ngIf="(_mode === 'expanded')">
<!-- Conditional template Outlet (see: https://stackoverflow.com/a/52448001/1116959) -->
<ng-container *ngTemplateOutlet="_product?.highlighted ? highlightedDetails : normalDetails; context: { product: _product }">
</ng-container>
</div>
</div>
<!-- Product - Normal Details template -->
<ng-template #normalDetails let-product="product">
<div class="variant-details" *ngIf="product?.type === 'single' || product?.type === 'multi'">
// See: https://www.learnrxjs.io/operators/combination/forkjoin.html
// Added take(1) bc of this behaviour: https://github.com/angular/angularfire2/issues/617#issuecomment-255513958
forkJoin(
this.firebaseService.getUserEventsForDevice(selectedDevice.key, filterCriteria).pipe(take(1)),
this.firebaseService.getEventsFromDevice(selectedDevice.key, filterCriteria).pipe(take(1))
)
.subscribe(
([userEvents, deviceEvents]) => {
console.log('userEvents', userEvents);
console.log('deviceEvents', deviceEvents);
@agustinhaller
agustinhaller / server.js
Created August 28, 2018 12:48
Simple express server
var express = require('express'),
app = express();
app.use(express.static('dist/browser'));
// CORS (Cross-Origin Resource Sharing) headers to support Cross-site HTTP requests
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
@agustinhaller
agustinhaller / package.json
Created March 15, 2017 17:43
deploy a heroku
{
"name": "mobile-ui-design-client",
"version": "1.0.0",
"description": "A simple starter Angular2 project",
"scripts": {
"build": "rimraf dist && webpack --progress",
"watch": "npm run build -- --watch",
"server": "webpack-dev-server --inline --progress --port 3000 --content-base src",
"start-dev": "npm run server",
"prestart": "npm run build",
@agustinhaller
agustinhaller / gist:df8e7680058eb1b31cbe
Created October 2, 2015 17:39 — forked from ghinda/gist:6036998
local/session storage polyfill (@Rem's version + with support for opera mini)
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@agustinhaller
agustinhaller / heroku_strongloop_deploy.log
Created April 28, 2015 05:42
heroku_strongloop_deploy.log
-----> Fetching custom git buildpack... done
-----> Node.js app detected
PRO TIP: Specify a node version in package.json
See https://devcenter.heroku.com/articles/nodejs-support
-----> Defaulting to latest stable node: 0.12.2
-----> Downloading and installing node
-----> Installing StrongLoop dependencies
> heapdump@0.3.5 install /tmp/build_a8813eae17f467f38dea32f9e4790273/vendor/node/lib/node_modules/strongloop/node_modules/strong-supervisor/node_modules/heapdump
> node-gyp rebuild
make: Entering directory `/tmp/build_a8813eae17f467f38dea32f9e4790273/vendor/node/lib/node_modules/strongloop/node_modules/strong-supervisor/node_modules/heapdump/build'
# Prerequisites
- Fisrt install protractor following this tutorial: https://github.com/angular/protractor/blob/master/docs/tutorial.md
- Then follow this tutorial to get things going: http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-karma.html
- After installing protractor, we configure Grunt. For that we have to do the following:
- npm install
- grunt
- And if we want to run the test, just run: grunt test (o grunt test:midway)
# How and what to test?
[
{
"type" : "add",
"id" : "AA0001",
"version": 1,
"lang": "es",
"fields" : {
"product_id": 1,
"variant_id": 11,
"title": "Quilt Real Patchwork de microfibra Amarelo. Modelo Rio de Janeiro. Varios tamaños a elección",
Faceted Search
Faceted search takes the documents matched by a query and generates counts for various properties or categories. Links are usually provided that allows users to "drill down" or refine their search results based on the returned categories.
The following example searches for all documents (*:*) and requests counts by the category field cat.
...&q=*:*&facet=true&facet.field=cat
Notice that although only the first 10 documents are returned in the results list, the facet counts generated are for the complete set of documents that match the query.