Skip to content

Instantly share code, notes, and snippets.

View jmartinesp's full-sized avatar

Jorge Martin Espinosa jmartinesp

View GitHub Profile
PODS:
- CocoaAsyncSocket (7.6.4)
- DACircularProgress (2.3.1)
- dsBridge (3.0.6)
- EZAudio (1.1.5):
- EZAudio/Full (= 1.1.5)
- EZAudio/Core (1.1.5)
- EZAudio/Full (1.1.5):
- EZAudio/Core
- TPCircularBuffer (= 1.1)
protocol Copyable {
func copy<V1>(_ keypath1: WritableKeyPath<Self, V1>, _ value1: V1) -> Self
func copy<V1, V2>(_ keypath1: WritableKeyPath<Self, V1>, _ value1: V1, _ keypath2: WritableKeyPath<Self, V2>, _ value2: V2) -> Self
func copy<V1, V2, V3>(_ keypath1: WritableKeyPath<Self, V1>, _ value1: V1,
_ keypath2: WritableKeyPath<Self, V2>, _ value2: V2,
_ keypath3: WritableKeyPath<Self, V3>, _ value3: V3) -> Self
func copy<V1>(_ copiedValue: CopiedValue<Self, V1>) -> Self
func copy<V1, V2>(_ copiedValue: CopiedValue<Self, V1>, _ copiedValue2: CopiedValue<Self, V2>) -> Self
}
let ipsum = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed dui libero, vehicula non mauris ac, bibendum porta sem. Vestibulum id mauris sit amet elit venenatis auctor id et ante. Praesent laoreet feugiat neque quis maximus. Mauris ac dignissim nibh. Morbi aliquam lacus dignissim, tempus urna interdum, bibendum elit. Integer iaculis non tortor a pretium. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris tellus ipsum, iaculis euismod euismod non, porttitor eget justo. Fusce lacinia vestibulum lectus molestie molestie. Maecenas in ornare ipsum. Etiam suscipit convallis dapibus. Maecenas bibendum ornare risus et porta. In tortor lorem, porttitor quis dignissim sed, pharetra non sem.
Curabitur sapien sapien, porta a dolor vitae, commodo laoreet ligula. Etiam placerat varius erat, sit amet finibus ligula. Mauris ullamcorper lectus sed nulla egestas, in vestibulum ex placerat. Maecenas at ligula ac justo pharetra sagittis volutpat eget sem. Nam mattis vehicula mauris, vel commodo leo
@jmartinesp
jmartinesp / RuntimeArguments.swift
Created August 30, 2017 16:54
RuntimeArguments in Swift 4
//
// Dip
//
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@jmartinesp
jmartinesp / Async.swift
Last active August 29, 2015 14:19
I just got real tired of dispatch_async...
//
// Async.swift
//
// Used as: Async().delay(2).onBackground({ ... }).onMainThread({ ... }).start()
//
// Created by Arasthel on 22/04/15.
// Copyright (c) 2015 Arasthel. All rights reserved.
//
import Foundation
@jmartinesp
jmartinesp / AsyncJob.java
Last active August 29, 2015 14:04
First version of a class that makes async processing a lot cleaner than using an AsyncTask, for example
import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask;
/**
* Created by Arasthel on 08/07/14.
*/
public class AsyncJob<JobResult> {
@jmartinesp
jmartinesp / Slider AsyncTask
Created March 26, 2014 17:24
Tried to fix an AsyncTask so it loads a Bitmap from an ArrayList to a ImageView every second
class GetImagesTask extends AsyncTask<Long, Bitmap, Void>{
@Override
protected ArrayList<Bitmap> doInBackground(Long... id) {
long projectId = id[0];
Project project = getProject(projectId);
ArrayList<Bitmap> i = new ArrayList<Bitmap>();
File[] files = MediaHelper.getProjectFilenames(project.getImagePath());
if(files != null && files.length > 0){
for(File aFile : files){
Bitmap bitmap = MediaHelper.getScaledImage(aFile, screenSize.y / 2, screenSize.x / 2);
package com.arasthel.wfspain.views;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
@jmartinesp
jmartinesp / Seleccionar objeto en lista
Last active December 17, 2015 17:19
La cosa es que los elementos de una lista siempre van a estar reutilizándose, así que el truco está en comprobar cuál tenemos seleccionado en base a la posición del mismo, y cambiarle el fondo a "seleccionado". Como esto haría sólo que cada vez que apareciera por pantalla un view con esa posición este cambiara de color, acabaríamos con todos los…
public class CustomAdapter extends ArrayAdapter<Algo> {
// Indice en la lista del item seleccionado
private int selected = -1;
public View getView(final int position, ...) {
convertView.setOnClickListener(new OnClickListener() {
@Override