Skip to content

Instantly share code, notes, and snippets.

@exallium
exallium / bf.c
Created February 24, 2014 05:23
BF Interpreter in C... Because I can. And I was a bit bored.
/**
* usage: ./bf "<program>"
* example: ./bf ",[>++<-]>. ; multiplies a number by 2"
*
* Brainfuck Interpreter
*
* BF has the following commands:
* > Move to next memory position
* < Move to prev memory position
* + Increment current memory position
@exallium
exallium / Function.java
Last active August 29, 2015 13:57
Very simple Function object with composition in Java.
public abstract class Function<A, B> {
public abstract B apply(A arg);
// Given f :: a -> b and g :: b -> c, we can define h :: a -> c as the composition of f and g
public static <A, B, C> Function<A, C> compose(final Function<A, B> x, final Function<B, C> y) {
return new Function<A, C>() {
@Override
public C apply(A arg) {
return y.apply(x.apply(a));
@exallium
exallium / AutoCompleteCursorAdapter.java
Last active August 29, 2015 14:20
SugarDB Cursor Adapter for AutoComplete Widgets
package org.exallium.tradetracker.app.controller.adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.Filter
import android.widget.Filterable
import android.widget.TextView
import com.orm.query.Condition
@exallium
exallium / datak.kt
Last active August 29, 2015 14:21
kotlinvsxtend
data class MyValueObject(val a: Int, val b: String)
package controller
public class Controller {
val editText : RxEditText<User> = // ...
val model : Model<User> = // ...
val modelObserver: Observer<User>? = null
val editTextObserver: Observer<User>? = null
@exallium
exallium / adapter.java
Last active August 29, 2015 14:25
flat
/* within adapter class */
private static class ItemDeletate<T> {
private final T item;
private boolean isViewed;
public ItemDelegate(T item) {
this.item = item;
}
@exallium
exallium / Action.java
Last active August 29, 2015 14:27
UndoCommand Pattern
public enum Action {
ACTION1, ACTION2
}
@exallium
exallium / build.workaround-missing-resources.gradle
Created September 18, 2015 14:27
Workaround Missing Resources for Robolectric 3.0
// Workaround for missing test resources when run unit tests within android
// studio.
// This copy the test resources next to the test classes for each variant.
// Tracked at https://github.com/nenick/AndroidStudioAndRobolectric/issues/7
// Original solution comes from
// https://code.google.com/p/android/issues/detail?id=136013#c10
// apply with:
// apply from: build.workaround-missing-resources.gradle
gradle.projectsEvaluated {
@exallium
exallium / slider.html
Created June 2, 2011 11:36
Opacity Slider in HTML5/CSS3/JQuery
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#range').change(function() {
$('#page_contents').attr('style', 'opacity:' + $('#range').attr('value')/100);
});
});
</script>
<input id="range" type="range" max='100' min='0' value='100' />
@exallium
exallium / coffee.json
Created June 17, 2011 15:25 — forked from minichate/coffee.json
Timmys Run
{
"Christopher Troup": {
"1x": "Large Double-Double",
"1x": "24 Timbits"
}
}