Skip to content

Instantly share code, notes, and snippets.

View ashishb's full-sized avatar

Ashish Bhatia ashishb

View GitHub Profile
@ashishb
ashishb / crash.java
Last active September 1, 2023 19:35
com.google.auth:google-auth-library-oauth2-http:1.12.0 is good but com.google.auth:google-auth-library-oauth2-http:1.12.1 onwards is broken on API 21
java.lang.NoSuchMethodError: No virtual method getAndSetObject(Ljava/lang/Object;JLjava/lang/Object;)Ljava/lang/Object; in class Lsun/misc/Unsafe; or its super classes (declaration of 'sun.misc.Unsafe' appears in /system/framework/core-libart.jar)
E at com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.gasWaiters(AbstractFuture.java:1394)
E at com.google.common.util.concurrent.AbstractFuture.releaseWaiters(AbstractFuture.java:1110)
E at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1000)
E at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:783)
E at com.google.auth.oauth2.OAuth2Credentials$RefreshTask.access$400(OAuth2Credentials.java:600)
E at com.google.auth.oauth2.OAuth2Credentials$RefreshTask$1.onSuccess(OAuth2Credentials.java:617)
E at com.google.auth.oauth2.OAuth2Credentials$RefreshTask$1.onSuccess(OAuth2Credentials.java:614)
E at com.google.common.util.concurrent.Fut
@ashishb
ashishb / ghurl.sh
Created November 16, 2018 19:50
Opens github.com url of a file corresponding to a local file
# Usage: ghurl <filepath>
# Opens the file in github corresponding to a local path. Respects repo name, branch name (defaults to master).
function ghurl() {
domain='http://github.com' &&
repo=$(git config --get remote.origin.url | cut -d: -f2 | cut -d. -f1) &&
# Fallback to master branch
remoteBranch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo 'master') &&
# Remove origin prefix
remoteBranch=${remoteBranch#origin/} &&
currentDir=$PWD &&
@ashishb
ashishb / aspath.py
Last active September 21, 2015 18:19
from collections import Counter
FILENAME = 'aspath.txt'
f = open(FILENAME, 'r')
for line in f:
# print 'Line read is ', line
mylist = line.split()
@ashishb
ashishb / gist:da145a877139fcd91e3f
Created July 6, 2014 08:36
Fix for "Unapproved caller. SecurityAgent may only be invoked by Apple software"
- Start on single user mode: Hit the Command and S keys at start-up
Wait until the writing stops completely
-At the line, type (after root): /sbin/fsck -fy (space after the k)
Hit the ENTER key
wait until it finishes and says "... appears to be OK"
next, type: /sbin/mount -uw / (space after the t and after the w)
@ashishb
ashishb / gist:266a71d06d308bd96eed
Created June 27, 2014 21:06
Fix to a problem installing "Android Studio" via homebrew on Mac OS X.
# Problem
$ open -a Android\ Studio
LSOpenURLsWithRole() failed for the application /opt/homebrew-cask/Caskroom/android-studio/0.6.1 build-135.1224218/Android Studio.app with error -10810.
# Fix
$ /usr/libexec/PlistBuddy -c 'Set :JVMOptions:JVMVersion 1.8*' //opt/homebrew-cask/Caskroom/android-studio/0.6.1\ build-135.1224218/Android\ Studio.app/Contents/Info.plist
@ashishb
ashishb / gist:9334297
Created March 3, 2014 20:46
Install atom without invite
#!/bin/sh
# Install Atom directly without invitation
# by @leaskh
cd ~
curl -L https://www.atom.io/api/updates/download -A "Atom/0.1 CFNetwork/1.5" > Atom.zip
open Atom.zip
mv Atom.app /Applications/
rm -rf Atom.zip
@ashishb
ashishb / gist:9245170
Created February 27, 2014 06:01
Keybase
### Keybase proof
I hereby claim:
* I am ashishb on github.
* I am ashishb (https://keybase.io/ashishb) on keybase.
* I have a public key whose fingerprint is DC5D 1E98 F335 E7B3 8E78 C25F 1BDE 4BB1 723D 0912
To claim this, I am signing this object:
// A fault tolerant Google apps script for fetching dividend data from Yahoo Finance (original fault intolerant script was taken from http://seekingalpha.com/article/568641-using-google-spreadsheet-as-your-watch-list
function GetDividends(symbol) {
/* Manipulate the symbol, as necessary */
if (symbol.search(/\.b/i) >= 0)
{
symbol = symbol.replace(/\.b/i, "-B");
}
@ashishb
ashishb / gist:7838656
Last active December 30, 2015 13:58
A small monkeyrunner script to automate "Tinder" likes
# Run this script using Monkeyrunner.
import commands
import time
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
def click(device, x, y):
device.touch(x, y, MonkeyDevice.DOWN_AND_UP)
@ashishb
ashishb / gist:7668357
Created November 26, 2013 23:46
SHA256 demo
import hashlib
even_count = 0
odd_count = 0
for x in xrange(0, 1000, 1):
if int(hashlib.sha256(str(x)).hexdigest(), 16)%2 == 0:
even_count += 1
else:
odd_count += 1