Skip to content

Instantly share code, notes, and snippets.

View aminelaadhari's full-sized avatar

Amine Laadhari aminelaadhari

  • thefabulous.co
View GitHub Profile
@JakeWharton
JakeWharton / ViewHoldingAdapter.java
Created April 26, 2012 06:54
Template for a list adapter which uses a view holder to cache lookups.
public class TweetAdapter extends BaseAdapter {
// ...
public View getView(int position, View convertView, ViewGroup parent) {
TweetViewHolder vh = TweetViewHolder.get(convertView, parent);
Tweet item = getItem(position);
vh.user.setText(item.user);
vh.tweet.setText(item.tweet);
@JakeWharton
JakeWharton / ContractFragment.java
Created May 6, 2012 09:12
Base fragment to ensure the parent activity implements a contract interface.
/* Base fragment to ensure the parent activity implements a contract interface. */
public abstract class ContractFragment<T> extends Fragment {
private T mContract;
@Override
public void onAttach(Activity activity) {
try {
mContract = (T)activity;
} catch (ClassCastException e) {
throw new IllegalStateException(activity.getClass().getSimpleName()
@kmansoft
kmansoft / drawable_convert.py
Created May 22, 2012 21:39
A simple script to create lower-resolution Android drawables from higher-resolution ones.
#!/usr/bin/python
import sys
import argparse
import os
import re
'''
A simple script to create lower-resolution Android drawables from higher-resolution ones.
@j4rs
j4rs / client.js
Created July 9, 2012 22:26
NodeJS GCM Server to send message to android devices...
var GCM = require('./gcm');
var gcm = new GCM(<YOUR GOOGLE API KEY>); // https://code.google.com/apis/console
// create the message
var msg = {
registration_ids: [token], // this is the device token (phone)
collapse_key: "your_collapse_key", // http://developer.android.com/guide/google/gcm/gcm.html#send-msg
time_to_live: 180, // just 30 minutes
data: {
@arpit
arpit / layout_transition_stagger.java
Created July 13, 2012 22:27
Stagger LayoutTransitions in Android
package com.arpit.animatortest;
import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
@erikreagan
erikreagan / mac-apps.md
Created August 4, 2012 19:18
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

@sealskej
sealskej / gist:3273440
Created August 6, 2012 10:55
Custom TabBar on Android
package cz.eman.android.hosl.ui.widget;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
@billynyh
billynyh / VerticalScrollView.js
Created August 25, 2012 03:16
Using horizontal viewpager inside vertical scrollview
//http://stackoverflow.com/questions/2646028/android-horizontalscrollview-within-scrollview-touch-handling
public class VerticalScrollView extends ScrollView {
private float xDistance, yDistance, lastX, lastY;
public VerticalScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
@tinifni
tinifni / gist:3756796
Created September 20, 2012 16:04
Remember what you've done since your last standup
# zsh script checks first if there were any commits done
# by author yesterday. If there were, return those. If
# there weren't, look for all commits since last Friday
# at midnight as it may have been a weekend.
#
# Use your name in the --author for all commands
gitstandup() {
if [ -z "$(git log --all --pretty=format:'* %s' --no-merges --reverse --author=Justin --since=yesterday.midnight)" ]; then
git log --all --pretty=format:'* %s' --no-merges --reverse --author=Justin --since=last.friday.midnight;
@thanksmister
thanksmister / EllipsisTextView.java
Created October 16, 2012 23:10
Adds listener to Android TextView when text has ellipsis.
/**
* Author: Michael Ritchie, ThanksMister LLC
* Date: 10/16/12
* Web: thanksmister.com
*
* Extension of <code>TextView</code> that adds listener for ellipses changes. This can be used to determine
* if a TextView has an ellipses or not.
*
* Derived from discussion on StackOverflow:
*