Skip to content

Instantly share code, notes, and snippets.

View marlonlom's full-sized avatar
😎

Marlon López marlonlom

😎
View GitHub Profile
@marlonlom
marlonlom / Preferences.java
Last active July 23, 2017 03:04
Gist for Preferences.java, Utility class for handling read/write operations using SharedPreferences
/*
* Copyright (c) 2017, marlonlom
*
* 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,
@marlonlom
marlonlom / MiddleNumber.java
Created August 22, 2017 00:10
MiddleNumber.java
public class MiddleNumber
{
public static void main(String[] args)
{
MiddleNumber myObject = new MiddleNumber();
int[] numberz = {1,2,4,60,8,20};
int[] resultz= myObject.makeMiddle(numberz);
System.out.print("myObject.makeMiddle: "+resultz[0]);
}
@marlonlom
marlonlom / Aes128EncryptionCompat.java
Last active October 2, 2017 21:12
AES 128bit Cross Platform (Java) Encryption Compatibility
/*
* Copyright (c) 2017, marlonlom
*
* 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,
@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 / google_staticmaps_router.js
Last active January 26, 2018 21:43
Google staticmaps Router implementation. Used for map images downloading using Nodejs + ExpressJS
/**
* Google staticmaps Router implementation.
*/
const express = require('express'),
request = require('request'),
router = express.Router(),
StaticMaps = {
baseHost: "https://maps.googleapis.com/maps/api"
};
@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 / 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 / CollapseDateRanges.kt
Last active April 15, 2020 03:13
Formats a dates (start,end) range in Kotlin, presenting the result in a collapsed date range format.
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale.ENGLISH
/**
* Creates a "collapsed" date range String representing the period of time
* between two Dates.
*
* @author marlonlom
*/
@marlonlom
marlonlom / japanese-name-generator.js
Last active November 6, 2020 20:08
Simple Javascript function for Japanese name generator
const japaneseName= (name) => {
const dictionary = {"a": "ka","b": "tu","c": "mi","d": "te","e": "ku","f": "lu","g": "ji","h": "ri","i": "ki","j": "zu","k": "me","l": "ta","m": "rin","n": "to","o": "mo","p": "no","q": "ke","r": "shi","s": "ari","t": "chi","u": "do","v": "ru","w": "na","x": "mei","y": "fu","z": "ra"};
return name.substring(0, name.indexOf(' ') >=0 ? name.indexOf(' ') : name.length).replace(/[a-z]/gi, m => dictionary[m]);
}
@marlonlom
marlonlom / Key_starUML.md
Created November 18, 2020 16:34 — forked from danielquisbert/Key_starUML.md
Key para starUML