Skip to content

Instantly share code, notes, and snippets.

View albodelu's full-sized avatar

Al B. albodelu

View GitHub Profile
@albodelu
albodelu / delete-from-repo.md
Created April 4, 2016 22:59 — forked from scy/delete-from-repo.md
How to delete a file from a Git repository, but not other users' working copies

How to delete a file from a Git repository, but not other users' working copies

Suppose you have, by mistake, added your IDE's project folder (you know, these .idea folders with all kinds of local paths and configuration data and settings in it) to the Git repository of your project. (We're talking about a whole folder here, but the same rules apply to individual files as well.)

Of course, you only realize that two days after the fact and have already pushed it, and your colleagues have already pulled it. They use the same IDE as you do, so whenever they change a setting or fix paths, they can either

  • commit that, causing nasty merge conflicts for you and others or
  • ignore the changes and carry around a modified file until the end of time without ever committing it.

Why .gitignore won't help

@albodelu
albodelu / git rm
Created April 4, 2016 23:00 — forked from thomasJang/git rm
git rm -rf .idea; git commit -m "delete .idea"; git push;
@albodelu
albodelu / tmdb.rb
Created October 22, 2016 00:24 — forked from rectifyer/tmdb.rb
Get images from TMDB
require 'httparty'
# TMDB
TMDB_API_KEY = '[your api key]'
# get configuration parameters
response = HTTParty.get("https://api.themoviedb.org/3/configuration?api_key=#{TMDB_API_KEY}")
config = JSON.parse(response.body)
image_prefix = config['images']['secure_base_url']
@albodelu
albodelu / emulator-fix
Created April 7, 2017 17:02 — forked from gelldur/emulator-fix
Fix for android emulator -noaudio and CPU problems
#!/bin/bash
# http://stackoverflow.com/a/35822173/1052261
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
@albodelu
albodelu / LocalJsonClient.java
Created July 20, 2017 23:10
Retrofit LocalJsonClient
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import retrofit.client.Client;
import retrofit.client.Header;
import retrofit.client.Request;
import retrofit.client.Response;
import retrofit.mime.TypedInput;
@albodelu
albodelu / build.gradle
Created July 21, 2017 01:35 — forked from koral--/build.gradle
testApt to testAnnotationProcessor migration, workaround for issue: https://code.google.com/p/android/issues/detail?id=224272
android.applicationVariants.all {
def aptOutputDir = new File(buildDir, "generated/source/apt/${it.unitTestVariant.dirName}")
it.unitTestVariant.addJavaSourceFoldersToModel(aptOutputDir)
}
@albodelu
albodelu / colors.xml
Created July 27, 2017 00:46
Material Design Color Palette Colors.xml Resource file for Android
<?xml version="1.0" encoding="utf-8"?>
<!--
Google Material Design Color Palette for Android http://www.google.com/design/spec/style/color.html#color-ui-color-palette
Spreadsheet used to create this reosurce - http://bit.ly/mdcolor_spreadsheet
Link to this colors.xml resource file - http://bit.ly/mdcolorsxml
Harshad Kale
https://github.com/kalehv
-->
@albodelu
albodelu / Dagger2SimpleExample.java
Created August 3, 2017 09:33 — forked from vestrel00/Dagger2SimpleExample.java
A: Dagger.android 2.11 simple example with support for Singleton, PerActivity, PerFragment, and PerChildFragment scopes
// This is a super simplified example of how to use the new dagger.android framework
// introduced in Dagger 2.10. For a more complete, in-depth guide to dagger.android
// read https://proandroiddev.com/how-to-android-dagger-2-10-2-11-butterknife-mvp-part-1-eb0f6b970fd
// For a complete codebase using dagger.android 2.11, butterknife 8.7, and MVP,
// see https://github.com/vestrel00/android-dagger-butterknife-mvp
// Note that this example uses Dagger 2.11, where @ContributesAndroidInjector was
// introduced removing the need to define @Subcomponent classes.
@albodelu
albodelu / ButterknifeBindingExample.java
Created August 5, 2017 02:21 — forked from vestrel00/ButterknifeBindingExample.java
B: 2 - Butterknife binding in onViewCreated vs onViewStateRestored
/**
* Logs lifecycle events and provides subclasses a method to bind the views, bindViews().
*
* Note that the bindViews() uses Butterknife to bind the views. However, the views
* can also be bound without using Butterknife. Using Butterknife or not
* plays no part in this demonstration.
*/
// BaseFragment.java
public abstract class BaseFragment extends Fragment {
data class Video(
val id: String,
@Json(name = "video_url") val videoUrl: String,
@Json(name = "preview_image") val previewImage: Image,
@Json(name = "video_title") val videoTitle: String = EMPTY_STRING,
val duration: Int = 0,
@Json(name = "view_count") val viewCount: Int = 0,
val type: VideoType = VideoType.unknown
)