Skip to content

Instantly share code, notes, and snippets.

View ldmarz's full-sized avatar
💯
Dandolo todo mientras me divierto

Lenin martinez ldmarz

💯
Dandolo todo mientras me divierto
View GitHub Profile
@ldmarz
ldmarz / ExampleDebounce.js
Last active August 19, 2018 18:14
Example of how to use debounce from lodash, more information at http://ldmarz.com/improve-the-speed-of-your-javascript-code-with-debounce/
function writeDOM(e) {
// Imagine some slow/hard function
$("#result").text(`${e.clientX} - ${e.clientY}`);
}
const $checkBox = $('#checkbox');
const debouncedWriteDom = _.debounce(writeDOM, 100);
$("#container-result").mousemove(e => {
if ($checkBox.is(':checked')) {
@ldmarz
ldmarz / Debounce example
Last active August 19, 2018 18:17
Example of how to use debounce from lodash, more information at http://ldmarz.com/mejora-la-velocidad-de-tu-javascript-con-debounce/
Just for naming purpose
@ldmarz
ldmarz / KeydownGist
Last active July 31, 2018 01:10
Capture keydown in multiple divs using JQuery Running sample at: http://jsfiddle.net/gh/gist/jQuery/3.3.1/ed86caa7186b17858f4f200e8b636a1f
Just for name purpose
@ldmarz
ldmarz / index.js
Created June 27, 2018 14:32
Get list of events bound on an element with jQuery
console.info($._data($(document)[0], 'events'));
// Example output
// {
// "mousedown": [
// {
// "type": "mousedown",
// "origType": "mousedown",
// "guid": 1,
// "namespace": ""
@ldmarz
ldmarz / unit-test-service.js
Created February 5, 2018 19:22
Unit testing service in angularjs
const module = angular.mock.module;
const inject = angular.mock.inject;
let searchService;
describe('Testing some awesome service', () => {
beforeAll(module('yourModule'));
beforeEach(inject($injector => {
searchService = $injector.get('SearchClass');
}));
@ldmarz
ldmarz / http-interceptor.ts
Last active April 17, 2021 12:00
Http interceptor for ionic 3, this allow us to make actions like obtain a JWT token before send the request. Sample of implementation at http://ldmarz.com/ionic3-http-interceptor/
import {Http, RequestOptionsArgs, Response, RequestOptions, ConnectionBackend, Headers} from '@angular/http';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
import { Storage } from '@ionic/storage';
export class HttpProvider extends Http {
constructor (connectionBackend: ConnectionBackend, requestOptions: RequestOptions, public storage: Storage ) {
super(connectionBackend, requestOptions);
}