Skip to content

Instantly share code, notes, and snippets.

View xrigau's full-sized avatar
:shipit:
🚀

Xavi Rigau xrigau

:shipit:
🚀
View GitHub Profile
@xrigau
xrigau / SortingAlgorithms.java
Created June 7, 2014 19:24
Sorting Algorithms
interface SortingAlgorithm {
int[] sort(int[] values);
}
class QuickSort implements SortingAlgorithm {
@Override
int[] sort(int[] values) {
return quickSort(values);
}
// ...
@xrigau
xrigau / ImageCache.java
Created August 4, 2014 16:44
Simple Image cache
public class ImageCache implements Map<String, Bitmap> {
private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
private final Context context;
public ImageCache(Context context) {
this.context = context;
}
@Override
public static WidgetImageLoader newInstance(Resources resources) {
BitmapAdjuster adjuster = BitmapAdjuster.newInstance(resources);
Retriever defaultRetriever = new MemoryRetriever();
Retriever fileRetriever = FileRetriever.newInstance(resources);
return new WidgetImageLoader(defaultRetriever, fileRetriever, adjuster);
}
WidgetImageLoader(Retriever memoryRetriever, Retriever fileRetriever, BitmapAdjuster adjuster) {
this.memoryRetriever = memoryRetriever;
this.fileRetriever = fileRetriever;
@xrigau
xrigau / Url.java
Created May 28, 2015 14:47
Custom Url implementation
package com.foo.bar;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
public class Url implements Serializable {
private final URL url;
@xrigau
xrigau / gist:2351804
Last active October 3, 2015 00:08
Parse a list of items to Json using Gson
final Type listType = new TypeToken<ArrayList<T>>() {}.getType();
String json = new Gson().toJson(list, listType);
@xrigau
xrigau / gist:2500278
Created April 26, 2012 15:12
Define custom attributes namespace in Android layout
<RelativeLayout xmlns:myAttrs="http://schemas.android.com/apk/res-auto" ...>
...
@xrigau
xrigau / brew config
Created July 6, 2016 08:27
Problem with brew
⋊> /u/local on master brew config 10:25:11
HOMEBREW_VERSION: 0.9.9
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: ca005cb8245e7e12ad808d78d49bce3953e1153c
Last commit: 65 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 351775d67b2e8145ac665e53ea467cff894473fa
Core tap last commit: 5 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
@xrigau
xrigau / versionizer.gradle
Created March 7, 2017 15:37
Version using gradle properties file
def versionFile = project.file("version.properties")
Version version = Version.read(versionFile)
ext {
versionizerVersionCode = version.code
versionizerVersionName = version.name
}
task incrementVersionForRelease << {
group = 'release'
@xrigau
xrigau / genesis_public_key
Created February 22, 2018 10:27
genesis_public_key
048065b862d831ce6162907fd624ecdf97a91ea30a19a327263d19e2bb687812d2450bfc639ae6ab5d453c14e112869cbc6b8aa972890a6c6b854fd3c6938b3db5
@xrigau
xrigau / main.dart
Created April 16, 2018 16:16
Introduction to Redux in Flutter (main.dart)
void main() => runApp(ToDoListApp());
class ToDoListApp extends StatelessWidget {
final Store<AppState> store = Store<AppState>(
appReducer, /* Function defined in the reducers file */
initialState: AppState.initial(),
middleware: createStoreMiddleware(),
);
@override