Skip to content

Instantly share code, notes, and snippets.

View jsanta's full-sized avatar

Jose Ignacio Santa Cruz G. jsanta

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jsanta on github.
  • I am jsanta (https://keybase.io/jsanta) on keybase.
  • I have a public key whose fingerprint is 8F01 7220 E8B9 4411 34E2 6E9C BF73 7302 E167 8987

To claim this, I am signing this object:

@jsanta
jsanta / ocLazyLoad-uiRouterDecorator.js
Created May 25, 2017 14:59
OC LazyLoad decorator for UI router
// From: http://plnkr.co/edit/6CLDsz?p=info
define([
'angular',
'uiRouter',
'ocLazyLoad'
], function (angular) {
angular.module('oc.lazyLoad.uiRouterDecorator', ['ui.router']).config(function($stateProvider) {
@jsanta
jsanta / countries.js
Created August 18, 2017 15:26
Missing countries for mrz package
// Generated countries for https://github.com/cheminfo-js/mrz
// taken from https://github.com/newtondev/mrz-parser
var _countries = [];
_countries["AFG"] = "Afghanistan";
_countries["ALB"] = "Albania";
_countries["DZA"] = "Algeria";
_countries["ASM"] = "American Samoa";
_countries["AND"] = "Andorra";
_countries["AGO"] = "Angola";
@jsanta
jsanta / jsanta.zsh-theme
Created January 19, 2018 21:11
A customized oh-my-zsh theme. Works for me.
local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})"
PROMPT='%n@%m [%*]:%d
${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@jsanta
jsanta / launch.json
Created February 14, 2018 15:49
launch,json for debugging using VS Code
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chromium against localhost",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}",
"runtimeExecutable": "/usr/bin/chromium-browser",
@jsanta
jsanta / company-generator-template.txt
Last active March 9, 2018 14:22
Sample data generator template
[
'{{repeat(15, 30)}}',
{
index: '{{index(1)}}',
guid: '{{guid()}}',
color: '{{random("blue", "green", "red", "yellow")}}',
company: '{{company().toUpperCase()}}',
country: '{{country()}}'
}
]
@jsanta
jsanta / toggleFilter.ts
Created March 9, 2018 15:07
toggleFilter function. Adds or removes a simple search filter from the activeFilters array. Then it filters the original data to a filteredData array.
private activeFilters: Array<string> = [];
toggleFilter(_filter: string) {
const filterIdx: number = findIndex(this.activeFilters, (v) => v === _filter );
if (filterIdx !== -1) {
pullAt(this.activeFilters, [ filterIdx ]);
} else {
this.activeFilters.push(_filter);
}
this.filteredData = filter(this.data, (v) => includes(this.activeFilters, v.color));
@jsanta
jsanta / resetFilters.ts
Created March 9, 2018 15:24
resetFilter function, to reset all active filter to their default state (no active filters)
resetFilters() {
this.activeFilters = [];
this.filteredData = this.data;
}
@jsanta
jsanta / data-grid.component.ts
Created March 9, 2018 15:37
DataGridComponent for displaying a filtered data grid.
import { Company } from './../../data/company-data';
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-data-grid',
templateUrl: './data-grid.component.html',
styleUrls: ['./data-grid.component.sass']
})
export class DataGridComponent implements OnInit {
@jsanta
jsanta / grid-page.component.html
Created March 9, 2018 15:42
Grid page with the button filters.
<p>
Press a button to visually filter results
</p>
<form>
<div class="row">
<div class="float-left pr-1"><button type="button" class="btn btn-md"
(click)="resetFilters()">All</button></div>
<div class="float-left pr-1"><button type="button" class="btn btn-md btn-info"
(click)="toggleFilter('blue')">Blue</button></div>
<div class="float-left pr-1"><button type="button" class="btn btn-md btn-success"