Skip to content

Instantly share code, notes, and snippets.

View ch8n's full-sized avatar
💻
Always on to writing my next article.

Chetan Gupta ch8n

💻
Always on to writing my next article.
View GitHub Profile
@soheilhy
soheilhy / nginxproxy.md
Last active May 16, 2024 08:59
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

/*
* Copyright (C) 2015 Jake Wharton
*
* 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
@cristianpalomino
cristianpalomino / Connectivity
Last active October 31, 2018 06:11
Connectivity
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
/**
* Check device's network connectivity and speed
* @author emil http://stackoverflow.com/users/220710/emil
*
*/
@Tikitoo
Tikitoo / AndroidManifest.xml
Last active October 31, 2018 06:11
Android check network available
<manifest>
<!-- other code -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
@maheshwarLigade
maheshwarLigade / build.gradle
Created February 2, 2016 05:25 — forked from jackgris/build.gradle
Example of use from Proguard, from Android Studio
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
@jonikarppinen
jonikarppinen / 1_RxJava-connectivity-status-example.md
Last active November 23, 2022 18:16
Example of listening to connectivity status in Android and reacting to going offline. (Subscription, Observable, Observer, PublishSubject are from RxJava.)

Example of using RxJava to listen to connectivity status in Android

You could use the same approach to listen to any status, but this example includes network connectivity specifics too (ConnectionChangeReceiver and AndroidUtils.isConnected).

@paulocaldeira17
paulocaldeira17 / AppBarStateChangeListener.java
Last active December 21, 2023 09:50
Android AppBarLayout collapsed/expanded state listener
import android.support.design.widget.AppBarLayout;
/**
* App bar collapsing state
* @author Paulo Caldeira <paulo.caldeira@acin.pt>.
*/
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
// State
public enum State {
EXPANDED,
@kaushikgopal
kaushikgopal / RxSchedulerHook.java
Created July 8, 2016 16:50
Lazy man's RxJava Espresso Scheduler Hooks
public class RxSchedulerHook {
private ISRxSchedulerHook() {
// no instances
}
/**
* this makes sure that when we run the tests all of RxJava
* operates on a single thread (Scheduler.immediate)
*/

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@cretz
cretz / kotlin-annoyances.md
Last active November 12, 2019 22:54
Kotlin Annoyances

Kotlin Annoyances

These are things that I found annoying writing a complex library in Kotlin. While I am also a Scala developer, these should not necessarily be juxtaposed w/ Scala (even if I reference Scala) as some of my annoyances are with features that Scala doesn't even have. This is also not trying to be opinionated on whether Kotlin is good/bad (for the record, I think it's good). I have numbered them for easy reference. I can give examples for anything I am talking about below upon request. I'm sure there are good reasons for all of them.

  1. Arrays in data classes break equals/hashCode and ask you to overload it. If you are going to need to overload it and arrays have no overridability, why not make the least-often use case (the identity-comparison equals) the exception?