Skip to content

Instantly share code, notes, and snippets.

View rciovati's full-sized avatar

Riccardo Ciovati rciovati

View GitHub Profile
@dpick
dpick / gist:3200431
Created July 29, 2012 17:31
Mountain Lion Gmail Notifications
#! /usr/bin/ruby
require 'net/https'
def previous_count_location
Dir.mkdir('/Users/davidpick/.gmail_notifier') unless File.directory?('/Users/davidpick/.gmail_notifier')
'/Users/davidpick/.gmail_notifier'
end
def baseurl_for(name)
account_domain = name.split("@")
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@arriolac
arriolac / TopCropImageView.java
Last active March 21, 2023 08:01
Custom Android ImageView for top-crop scaling of the contained drawable.
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by chris on 7/27/16.
@romannurik
romannurik / CheatSheet.java
Last active May 16, 2023 13:42
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@slightfoot
slightfoot / SearchActivity.java
Last active October 26, 2023 12:28
SearchView example
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import android.content.Context;
import android.content.Intent;
import android.database.AbstractCursor;
import android.database.Cursor;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
@pboos
pboos / annotation-processor-build.gradle
Last active August 7, 2020 06:38
Gradle stuff for Android
configurations {
apt
}
dependencies {
compile 'com.squareup.dagger:dagger:1.1.0'
apt 'com.squareup.dagger:dagger-compiler:1.1.0'
}
android.applicationVariants.all { variant ->
@vovkab
vovkab / spoon-sample.gradle
Last active December 18, 2015 18:39
Spoon gradle integration for Android
/* Your Android Config Here */
/* Spoon Configuration */
repositories { mavenCentral() }
configurations { spoon }
dependencies { spoon 'com.squareup.spoon:spoon-runner:1.0.5' }
def buildDirPath = project.buildDir.path
def apk = buildDirPath + '/apk/' + project.name + '-debug-unaligned.apk'

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@castorflex
castorflex / .gitignore
Last active May 10, 2016 16:13
android .gitignore
# Eclipse
.project
.classpath
.settings
.checkstyle
# IntelliJ IDEA
.idea
*.iml
*.ipr
@rkistner
rkistner / android_install.rb
Created August 6, 2013 10:18
Automated installation of Android SDK components
require 'pty'
require 'expect'
def parse_android_packages(packages_raw)
packages_raw = packages_raw.split("\n----------\n")
result = []
packages_raw.each do |raw|
id_match = /id: (\d+) or "(.+)"/.match(raw)