Skip to content

Instantly share code, notes, and snippets.

View akhy's full-sized avatar
☁️
Working from cloud

Akhyar Amarullah akhy

☁️
Working from cloud
View GitHub Profile
@akhy
akhy / analytics.conf
Created April 27, 2016 08:12 — forked from jirutka/analytics.conf
Add Google Analytics tracking code to HTML via nginx
#
# Add Google Analytics tracking code to HTML response
#
# Usage:
# set $tracking_id 'UA-12345678-9';
# include incl/analytics.conf;
#
# It needs nginx compiled with option --with-http_sub_module.
# Uses optimized GA code from: http://mathiasbynens.be/notes/async-analytics-snippet
#
@akhy
akhy / disable_nsurlsessionid.sh
Last active May 20, 2018 21:39
Disable NSURLSessionId
launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlstoraged.plist
launchctl unload /System/Library/LaunchAgents/com.apple.nsurlsessiond.plist
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlsessiond.plist
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlstoraged.plist
@akhy
akhy / cleanup.sh
Last active August 26, 2016 19:33
Docker Snippets
#!/bin/sh
# remove image by pattern
docker images | grep "^pattern" | awk '{print $3}' | xargs docker rmi
# remove exited containers
docker ps -q -f status=exited | xargs docker rm
# get container/image label
docker-label () { # [container/image] [label]
@akhy
akhy / MultiDexJunitRunner
Created January 26, 2016 08:46 — forked from mandrachek/MultiDexJunitRunner
AndroidJunitRunner that supports MultiDex
import android.os.Bundle;
import android.support.multidex.MultiDex;
import android.support.test.runner.AndroidJUnitRunner;
public class MultiDexJunitRunner extends AndroidJUnitRunner {
@Override
public void onCreate(Bundle arguments) {
MultiDex.install(getTargetContext());
super.onCreate(arguments);
}
@akhy
akhy / android.sh
Created January 26, 2016 06:14 — forked from mikesorae/android.sh
ansible task for android sdk
export PATH="/opt/android-sdk-linux/tools:${PATH}"
@akhy
akhy / README.md
Last active January 5, 2016 10:12 — forked from polbins/README.md
Simple RecyclerView Divider

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
            getApplicationContext()
    	));

NOTE: Add item decoration prior to setting the adapter

@akhy
akhy / ViewPagerAdapter.java
Created January 5, 2016 08:55 — forked from pocmo/ViewPagerAdapter.java
ViewPagerAdapter: Implementation of PagerAdapter that represents each page as a View
/*
* Copyright (C) 2012 Sebastian Kaspari
*
* 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
@akhy
akhy / android.gitignore
Last active January 4, 2016 08:19
My .gitignore collection
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/build
/captures
.DS_Store
Thumbs.db
@akhy
akhy / BitmapUtils.java
Created December 8, 2015 03:28
Android Utils
// see: http://stackoverflow.com/a/823966/670623
public static Bitmap decodeFile(File f, int size) {
try {
// Decode image size
BitmapFactory.Options opts1 = new BitmapFactory.Options();
opts1.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f), null, opts1);
// The new size we want to scale to
@akhy
akhy / GravatarHelpers.kt
Last active September 26, 2017 14:57
Android Kotlin Helpers
// requires StringHelpers
enum class GravatarDefault(val str: String) {
ERROR_404 ("404"),
MYSTERY ("mm"),
IDENTICON ("identicon"),
MONSTER ("monsterid"),
WAVATAR ("wavatar"),
RETRO ("retro"),
BLANK ("blank"),