Skip to content

Instantly share code, notes, and snippets.

View arnaudbos's full-sized avatar
😶‍🌫️

Arnaud Bos arnaudbos

😶‍🌫️
View GitHub Profile
@arnaudbos
arnaudbos / Ektorp doc test
Created June 17, 2011 09:38
Testing CouchDB doc create/get with Ektorp.
HttpClient authenticatedHttpClient = new StdHttpClient.Builder().host("host").port(5984).username("user").password("pass").build();
CouchDbInstance dbInstance = new StdCouchDbInstance(authenticatedHttpClient);
CouchDbConnector db = dbInstance.createConnector("luscinia", true);
List<String> countries = new ArrayList<String>();
countries.add("Paris");countries.add("Marseille");countries.add("Bordeaux");countries.add("Toulouse");
Map<String, List<String>> majorCitiesByCountry = new HashMap<String, List<String>>();
majorCitiesByCountry.put("France", countries);
Map<String, Object> referenceData = new HashMap<String, Object>();
@arnaudbos
arnaudbos / gist:1042525
Created June 23, 2011 13:27
Python for loop on a Java Map
// Where map is a filled hashmap
for (Map.Entry<String, String> entry : map.entrySet())
{
String key = entry.getKey();
String value = entry.getValue();
System.out.printf("%s %s\n", key, value);
}
@arnaudbos
arnaudbos / FolderActivity.java
Created June 24, 2011 16:25
(Robo)ActivityGroup holding one child activity at a time in a specified view container.
package uk.ac.brookes.arnaudbos.luscinia.views;
import java.util.ArrayList;
import java.util.List;
import org.miscwidgets.widget.EasingType.Type;
import org.miscwidgets.widget.ExpoInterpolator;
import org.miscwidgets.widget.Panel;
import roboguice.inject.InjectExtra;
@arnaudbos
arnaudbos / DocumentView.java
Created July 11, 2011 23:17
(Android)Extended item view
package uk.ac.brookes.arnaudbos.luscinia.widget;
import uk.ac.brookes.arnaudbos.luscinia.R;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@arnaudbos
arnaudbos / ScrollViewListener.java
Created August 1, 2011 23:24
(Android)Create a ScrollView synchronizer
public interface ScrollViewListener
{
void onScrollChanged(SynchronizerScrollView scrollView, int x, int y, int oldx, int oldy);
}
@arnaudbos
arnaudbos / gist:1237119
Created September 23, 2011 10:48
A great commit message
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the present tense: "Fix bug" and not "Fixed
@arnaudbos
arnaudbos / delete.png
Created October 4, 2011 13:13
Create a UIBarButtonItem with a red (or other image) background
http://i.stack.imgur.com/P0xJO.png
@arnaudbos
arnaudbos / Test.m
Created October 17, 2011 15:45
Multiply a NSNumber
NSDecimalNumber * n1 = [NSDecimalNumber decimalNumberWithString:[weather.vitesseMaxMS stringValue]];
NSDecimalNumber * n2 = [NSDecimalNumber decimalNumberWithString:@"3.6"];
NSDecimalNumber * res = [n1 decimalNumberByMultiplyingBy:n2];
@arnaudbos
arnaudbos / gist:1626567
Created January 17, 2012 13:05
Set gradient color in Objective-C
theView.backgroundColor = [UIColor clearColor];
CAGradientLayer *layer = (CAGradientLayer *)theView.layer;
CGColorRef liteColor = [UIColor colorWithWhite:0.92f alpha:0.8f].CGColor;
CGColorRef darkColor = [UIColor colorWithWhite:0.32f alpha:0.8f].CGColor;
layer.colors = [NSArray arrayWithObjects:(id)liteColor, (id)darkColor, nil];
@arnaudbos
arnaudbos / gist:1985534
Created March 6, 2012 10:15
Add Multiple UIBarButtonItems to UINavigationBar
UIToolbar *tools = [[UIToolbar alloc]
initWithFrame:CGRectMake(0.0f, 0.0f, 103.0f, 44.01f)]; // 44.01 shifts it up 1px for some reason
tools.clearsContextBeforeDrawing = NO;
tools.clipsToBounds = NO;
tools.tintColor = [UIColor colorWithWhite:0.305f alpha:0.0f]; // closest I could get by eye to black, translucent style.
// anyone know how to get it perfect?
tools.barStyle = -1; // clear background
NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:3];
// Create a standard refresh button.