Skip to content

Instantly share code, notes, and snippets.

View romelgomez's full-sized avatar
:octocat:
https://www.linkedin.com/in/romelgomez/

Romel Gomez romelgomez

:octocat:
https://www.linkedin.com/in/romelgomez/
View GitHub Profile
@romelgomez
romelgomez / cloudinary.js
Last active December 15, 2015 02:30
(Solved) How get the form data. Express 5.0.0-alpha.2
Where i use $upload service
var uploadFile = function(file,fileId){
var deferred = $q.defer();
file.upload = $upload.upload({
url: "/files",
fields: {
public_id: 'publications/'+fileId,
upload_preset: 'ebdyaimw',
@romelgomez
romelgomez / algolia.js
Last active December 28, 2015 02:35
Firebase Algolia, ReIndex, set Settings, observe changes
var Q = require('q');
var algoliasearch = require('algoliasearch');
var Firebase = require('firebase');
var _ = require('lodash');
var async = require('async');
var moment = require('moment');
var colors = require('colors');
var client = algoliasearch('················', '················································');
@romelgomez
romelgomez / destroy-the-synchronization.js
Last active April 17, 2016 20:19
Firebase is like mongodb, there are cases when you can use the ref.once('value') to get a unsorted object without having synchronization, but when you need a order array of objects, the way to avoid concurrent connections is this:
var fireData = {
locations: {}
};
// Create a synchronized array, and then destroy the synchronization after having the data
var locations = $firebaseArray(FireRef.child('locations').orderByChild('left'));
locations.$loaded()
.then(function () {
fireData.locations = angular.copy(locations);
locations.$destroy();
.directive('changeImg', [function () {
return {
restrict:'A',
scope:{
imgA: '=',
imgB: '='
},
link: function (scope, element) {
element.mouseover(function(event){
@romelgomez
romelgomez / truncate.php
Created September 29, 2016 14:33
Truncate text in PHP
<?php
function truncate($text, $chars = 25) {
$text = $text." ";
$text = substr($text,0,$chars);
$text = substr($text,0,strrpos($text,' '));
$text = $text."..."; // Si no se desea tener tres puntos suspensivos se comenta esta línea.
return $text;
}
@romelgomez
romelgomez / development.ts
Created December 8, 2016 22:31
Express Server with TypeScript
import * as server from "./server";
new server.App

Add material to angular2-webpack-starter in three steps:

a) Add material

  • Step 1

npm install --save @angular/material material hammerjs

  • Step 2
@romelgomez
romelgomez / Filters.ts
Created December 9, 2016 11:41
TypeScript Filters
import { Pipe, PipeTransform } from '@angular/core';
/**
* @Description Slug or lispCase; All letters are downCased and spaces and specialChars are replaced by hyphens '-'.
*
* EXAMPLE: {{ 'Your best days are not behind you; your best days are out in front of you.' | slug }} // your-best-days-are-not-behind-you-your-best-days-are-out-in-front-of-you
*
* @param {String}
* @return {String}
* */
@romelgomez
romelgomez / app.js
Last active March 4, 2017 22:08
Firebase login with Angular 1
'use strict';
angular.module('app',[
'ngRoute',
'siteConfig',
'angular-loading-bar',
'filters',
'validators',
'firebase',
'routes',
@romelgomez
romelgomez / node-asap.sh
Last active November 4, 2018 02:05
Install node ASAP
#!/bin/bash
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
if [[ ! -d "$NODE_PATH" ]]; then
export NODE_PATH=/usr/local/lib/node_modules
echo 'export NODE_PATH=/usr/local/lib/node_modules' >> ~/.bashrc
fi