Skip to content

Instantly share code, notes, and snippets.

@kaushikgopal
kaushikgopal / jdk8u77_download
Created April 4, 2016 01:08
Download JDK 8 patch 77 directly using wget
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-macosx-x64.dmg
@kaushikgopal
kaushikgopal / android_lifecycle_recommendations.md
Last active February 2, 2022 07:28
Notes on opportune moments to do "stuff" in the Android Lifecycle
  • In general you want to try and put things in onStart and onStop for logical start and stops.

Activity

onCreate

  • Dagger inject self into graph
  • setContentView(R.layout.xxx)
  • Butterknife.bind(this)
  • RxJava CompositeSubscription.add (if NON UI related work being done)
  • realm = Realm.getDefaultInstance();
@kaushikgopal
kaushikgopal / pre-commit
Last active April 19, 2023 09:22
pre-commit git hook - no "hacking"
#!/usr/bin/env ruby
# This pre-commit hook will prevent any commit to forbidden branches
# (by default, "staging" and "production").
# Put this file in your local repo, in the .git/hooks folder
# and make sure it is executable.
# The name of the file *must* be "pre-commit" for Git to pick it up.
def current_branch()
branches = `git branch --no-color`.split(/\n/)
@kaushikgopal
kaushikgopal / .phoenix.js
Last active January 23, 2016 22:38
Kaushik Gopal's Phoenix.Js window management script
// Generated by CoffeeScript 1.10.0
(function() {
var EMACS, FINDER, GRID_HEIGHT, GRID_WIDTH, ITERM, MARGIN_X, MARGIN_Y, TERMINAL, VIM, changeGridHeight, changeGridWidth, debug, focused, key_binding, keys, lastFrames, mash, moveWindowToNextScreen, moveWindowToPreviousScreen, snapAllToGrid, windowDownOneRow, windowGrowOneGridColumn, windowGrowOneGridRow, windowLeftOneColumn, windowRightOneColumn, windowShrinkOneGridColumn, windowShrinkOneGridRow, windowToFullHeight, windowUpOneRow, windows;
debug = function(o, label) {
if (label == null) {
label = "obj: ";
}
Phoenix.log(label);
@kaushikgopal
kaushikgopal / update.sh
Last active February 1, 2022 16:36
My morning cli ritual
echo "y" | android update sdk --no-ui; echo "yes" | apm upgrade; softwareupdate -i -a; brew update; brew upgrade; brew cleanup; brew cask cleanup; npm update npm -g; npm update -g; gem update
@kaushikgopal
kaushikgopal / bash_to_zsh_history.rb
Created December 13, 2015 22:55 — forked from goyalankit/bash_to_zsh_history.rb
Import bash history to zsh history.
#################################################################
# = This script transfers bash history to zsh history
# = Change bash and zsh history files, if you don't use defaults
#
# = Usage: ruby bash_to_zsh_history.rb
#
# = Author: Ankit Goyal
#################################################################
# change if you don't use default values
@kaushikgopal
kaushikgopal / bp_rxjava_share_warm_to_hot_hack.java
Created July 12, 2015 00:01
snippet hack to make share operator hot
storeObservable =
Observable.interval(1, TimeUnit.SECONDS)
.map(new Func1<Long, Integer>() {
@Override
public Integer call(Long aLong) {
return aLong.intValue();
}
})
.take(20)
.share();
@kaushikgopal
kaushikgopal / bp_rxjava_warm_share.java
Created July 11, 2015 22:28
warm observable snippet for a blog post
Observable
.interval(1, TimeUnit.SECONDS)
.map(new Func1<Long, Integer>() {
@Override
public Integer call(Long aLong) {
return aLong.intValue();
}
})
.take(20)
.share();
@kaushikgopal
kaushikgopal / .phoenix.1.js
Last active September 13, 2017 23:32
Kaushik Gopal's Phoenix.Js window management script
// Forked originally from @JasonM23’s config in literate coffee-script
// https://github.com/jasonm23/Phoenix-config/blob/master/Phoenix-config.litcoffee
// Released under MIT license - http://opensource.org/licenses/MIT
var BROWSER, EDITOR, FINDER, GRID_HEIGHT, GRID_WIDTH, MARGIN_X, MARGIN_Y, MUSIC, TERMINAL, VIDEO,
changeGridHeight, changeGridWidth, debug, forApp, key_binding, lastFrames, layouts, mash,
moveWindowLeftOneColumn, moveWindowRightOneColumn, moveWindowToNextScreen, moveWindowToPreviousScreen,
snapAllToGrid, switchLayout, transposeWindows,
windowDownOneRow, windowGrowOneGridColumn, windowGrowOneGridRow, windowShrinkOneGridColumn,
windowShrinkOneGridRow, windowToFullHeight, windowUpOneRow,
@kaushikgopal
kaushikgopal / RoundedBitmapDrawableUsage.java
Last active March 25, 2024 13:55
RoundedImageView - drop dead easy way to do this with RoundedBitmapDrawable
Bitmap batmapBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.batman);
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), batmapBitmap);
// option 1 h/t [Chris Banes](https://chris.banes.me/)
circularBitmapDrawable.setCornerRadius(batmapBitmap.getWidth());
// option 2 h/t @csorgod in the comments
circularBitmapDrawable.setCircular(true);