Skip to content

Instantly share code, notes, and snippets.

View marlonlom's full-sized avatar
😎

Marlon López marlonlom

😎
View GitHub Profile
@marlonlom
marlonlom / dateDiff.spec.ts
Last active August 30, 2022 03:32 — forked from RienNeVaPlus/dateDiff.ts
🕤 dateDiff() - returns a detail object about the difference between two dates
describe('date-diff', () => {
it('Should check if no date diff results shown for comparing exact same dates', () => {
const date0 = new Date('2020-11-01T01:00:00');
const date1 = new Date('2020-11-01T01:00:00');
const expectedResult = {
millennium: 0,
century: 0,
decade: 0,
year: 0,
quarter: 0,
@marlonlom
marlonlom / Key_starUML.md
Created November 18, 2020 16:34 — forked from danielquisbert/Key_starUML.md
Key para starUML
@marlonlom
marlonlom / SearchViewStyle.java
Created December 20, 2019 15:55 — forked from jaredrummler/SearchViewStyle.java
Customize the SearchView in an ActionBar for Android
/*
* Copyright (C) 2015 Jared Rummler <jared.rummler@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@marlonlom
marlonlom / RecyclerViewItemTouchListener.java
Created December 3, 2018 02:44
A helper class for handling click events on a RecyclerView
/**
* Created by Rany Albeg Wein on 07/11/2015.
* Since we currently don't have a LongItemClick listener for the {@link RecyclerView}
* this is an implementation that uses a {@link GestureDetector} to notify us for long click events on one of
* {@link RecyclerView}'s child views. It also handles single-tap-up ( a click ) and a double-click on a child view.
*/
public class RecyclerViewItemTouchListener extends RecyclerView.SimpleOnItemTouchListener {
/**
* A listener that will be invoked on item click events.
@marlonlom
marlonlom / slugify.js
Created November 20, 2017 02:03 — forked from codeguy/slugify.js
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@marlonlom
marlonlom / simple-pagination.js
Created April 7, 2016 22:07 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@marlonlom
marlonlom / EmptyRecyclerView.java
Last active September 7, 2015 20:41 — forked from mobiRic/EmptyRecyclerView.java
RecyclerView doesn't have an emptyView support, we gotta fix that
/*
* Copyright (C) 2015 Glowworm Software
* Copyright (C) 2014 Nizamutdinov Adel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
package com.github.manuelpeinado.toolbartest;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software