Skip to content

Instantly share code, notes, and snippets.

View abelrgr's full-sized avatar
⌨️
Coding in progress...

Abel abelrgr

⌨️
Coding in progress...
  • Bolivia
View GitHub Profile
@abelrgr
abelrgr / uniqid.js
Created March 17, 2016 00:37 — forked from larchanka/uniqid.js
JavaScript function that copies functionality of PHP's 'uniqid'.
(function () {
this.uniqid = function (pr, en) {
var pr = pr || '', en = en || false, result;
this.seed = function (s, w) {
s = parseInt(s, 10).toString(16);
return w < s.length ? s.slice(s.length - w) : (w > s.length) ? new Array(1 + (w - s.length)).join('0') + s : s;
};
result = pr + this.seed(parseInt(new Date().getTime() / 1000, 10), 8) + this.seed(Math.floor(Math.random() * 0x75bcd15) + 1, 5);
@abelrgr
abelrgr / gist:9a15b98f5a64273afbb6
Created October 8, 2015 23:33 — forked from Mithrandir0x/gist:3639232
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"