Skip to content

Instantly share code, notes, and snippets.

View jplazcano87's full-sized avatar
💭
Learning

Juan Pablo Lazcano jplazcano87

💭
Learning
  • Santiago, Chile
View GitHub Profile
@jplazcano87
jplazcano87 / DictionaryKeyPath.swift
Created October 2, 2018 01:15 — forked from dfrib/DictionaryKeyPath.swift
Swift: Reading and writing to (possible) nested dictionaries for a given key path, using a recursive approach
// For details, see
// http://stackoverflow.com/questions/40261857/remove-nested-key-from-dictionary
import Foundation
extension Dictionary {
subscript(keyPath keyPath: String) -> Any? {
get {
guard let keyPath = Dictionary.keyPathKeys(forKeyPath: keyPath)
else { return nil }
return getValue(forKeyPath: keyPath)
@jplazcano87
jplazcano87 / mutate.swift
Created August 16, 2018 13:25
Mutate Collection inside Foreach
var test = [0, 1]
extension MutableCollection {
mutating func updateEach(_ update: (inout Element) -> Void) {
for i in indices {
update(&self[i])
}
}
}
@jplazcano87
jplazcano87 / gist:871bc7cba13c06c583168306604ff150
Created February 13, 2018 13:56
Cleanup your Gradle caches by deleting files not accessed within the last month
#Cleanup your Gradle caches by deleting files not accessed within the last month
find ~/.gradle -type f -atime +30 -delete
find ~/.gradle -type d -mindepth 1 -empty -delete
@jplazcano87
jplazcano87 / reineta.sh
Created August 16, 2017 12:52
Reineta script
#!/bin/bash
open -a "/Applications/Google Chrome.app" https://www.youtube.com/watch?v=BYwqjCj6kgc
@jplazcano87
jplazcano87 / db_open_helper_post.md
Created July 27, 2017 22:27 — forked from achillesrasquinha/db_open_helper_post.md
Database Open Helper Class for Android SQLite Database.

Database Open Helper Class for Android SQLite Database

DatabaseOpenHelper.java

// Copyright 2015 Achilles Rasquinha

// 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
@jplazcano87
jplazcano87 / SerializeToJson.java
Created April 18, 2017 15:50 — forked from cmelchior/ SerializeToJson.java
Serialize Realm objects to JSON using GSON
// GSON can parse the data.
//
// Deserialization:
// Note there is a bug in GSON 2.3.1 that can cause it to StackOverflow when working with RealmObjects.
// To work around this, use the ExclusionStrategy below or downgrade to 1.7.1
// See more here: https://code.google.com/p/google-gson/issues/detail?id=440
//
// Serialization:
// <Type>RealmProxy objects are created by the Realm annotation processor. They are used to control
// access to the actual data instead of storing them in fields and it is therefore them we need to register a
@jplazcano87
jplazcano87 / LocalBroadcastExampleActivity.java
Created March 22, 2017 14:41 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@jplazcano87
jplazcano87 / TimestampUtils.java
Created December 26, 2016 20:45 — forked from kristopherjohnson/TimestampUtils.java
Methods for generating ISO 8601 timestamps in Java/Android
package net.kristopherjohnson.util;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
/**
* Methods for dealing with timestamps
@jplazcano87
jplazcano87 / AsyncTaskTests.java
Created October 23, 2016 15:44 — forked from he9lin/AsyncTaskTests.java
How to test AsyncTask in Android
package jieqoo.android.KASS.test.tasks;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import jieqoo.android.models.RESTListener;
import jieqoo.android.models.RESTResponse;
import jieqoo.android.tasks.FetchRESTResponseTask;
import jieqoo.android.util.Configuration;
import android.test.InstrumentationTestCase;
@jplazcano87
jplazcano87 / EmptyRecyclerView.java
Created September 13, 2016 19:29 — forked from meoyawn/EmptyRecyclerView.java
RecyclerView doesn't have an emptyView support, we gotta fix that
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;