I hereby claim:
- I am adityabhaskar on github.
- I am adityabhaskar (https://keybase.io/adityabhaskar) on keybase.
- I have a public key whose fingerprint is 5CC9 D757 A7A1 E844 EB56 4ACC 5027 D117 846E 7CAE
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
const selection = getSelection(); | |
const isALink = selection.type.toLowerCase() == "range") && // Selection is a range, and | |
selection.anchorNode == selection.focusNode && // Starts & finishes in the same node, and | |
selection.anchorOffset == 0 && // Starts at beginning of the node, and | |
selection.focusOffset == selection.focusNode.textContent.length && // Finishes at end of the node, and | |
(selection.anchorNode.nodeName.toLowerCase() == 'a' || // Node is of type 'a' (link/anchor), or | |
selection.anchorNode.parentElement.nodeName.toLowerCase() == 'a') // Node parent is of type 'a' (link/anchor) | |
protected String[] doInBackground(String... credentials) { | |
String consumer_secret = mActivity.getString(R.string.oauth_consumer_secret); | |
HttpClient client = new DefaultHttpClient(); | |
HttpPost request = new HttpPost("https://www.instapaper.com/api/1/oauth/access_token"); | |
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(mActivity.getString(R.string.oauth_consumer_key), | |
consumer_secret); | |
List<BasicNameValuePair> params = Arrays.asList( | |
new BasicNameValuePair("x_auth_username", credentials[0]), | |
new BasicNameValuePair("x_auth_password", credentials[1]), | |
new BasicNameValuePair("x_auth_mode", "client_auth")); |
@file:Suppress("NOTHING_TO_INLINE") | |
import kotlin.experimental.and // Used for Byte | |
import kotlin.experimental.inv // Used for Byte | |
import kotlin.experimental.or // Used for Byte | |
inline fun Int.hasFlag(flag: Int) = flag and this == flag | |
inline fun Int.withFlag(flag: Int) = this or flag | |
inline fun Int.minusFlag(flag: Int) = this and flag.inv() |
import android.net.ConnectivityManager | |
import android.net.NetworkCapabilities | |
import android.content.Context | |
object Utils { | |
internal fun isOnline(context: Context): Boolean { | |
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val activeNetwork = cm.activeNetwork ?: return false | |
val capabilities = cm.getNetworkCapabilities(activeNetwork) ?: return false | |
return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) |
body { | |
/* content width is 2x 350px */ | |
margin: auto calc(50% - 350px); | |
color: rgba(0, 0, 0, .8); | |
font-size: 16px; | |
font-family: system-ui, 'Roboto', sans-serif; | |
line-height: 1.6; | |
} | |
@media (max-width: 767px) { |
# Add macOS window screenshot style dropshadow | |
convert inputfile.png \( +clone -background Black -shadow 50x25+0+20 \) +swap -background none -layers merge +repage outputFile.png |
Copyright 2020 Google LLC | |
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 | |
https://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, |
/** | |
* Whether the device has an active connection to the internet | |
*/ | |
val Context.isConnected: Boolean | |
get() { | |
val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val activeNetwork = cm.activeNetwork ?: return false | |
return cm.getNetworkCapabilities(activeNetwork) | |
?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true |