Skip to content

Instantly share code, notes, and snippets.

View 0xSG's full-sized avatar
💻
ᴡᴏʀᴋ 🎧

ѕσσяуα gαηgαяαנ 0xSG

💻
ᴡᴏʀᴋ 🎧
View GitHub Profile
@0xSG
0xSG / dnsmasq OS X.md
Created October 18, 2022 16:52 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@0xSG
0xSG / ForceCacheOrNetwork.java
Created February 1, 2020 05:17 — forked from Tetr4/ForceCacheOrNetwork.java
How to force a cached or network response on Android with Retrofit + OkHttp
OkHttpClient okHttpClient = new OkHttpClient();
try {
int cacheSize = 10 * 1024 * 1024 // 10 MiB
Cache cache = new Cache(getCacheDir(), cacheSize);
okHttpClient.setCache(cache);
} catch (IOException e) {
Log.e(TAG, "Could not set cache", e);
}
// Forces cache. Used for cache connection
@0xSG
0xSG / MyFragementWithViewPager.java
Created May 6, 2019 08:37
smooth animation of a ViewPager on start of the activity. (in case you can't or won't use ViewPagerIndicator to announce the presence a ViewPager)
@Override
public void onStart() {
super.onStart();
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(new PagerHintMovement(-10), "progress", -1f, 1f);
objectAnimator.setInterpolator(new AccelerateInterpolator());
objectAnimator.setDuration(500);
objectAnimator.setRepeatCount(3);
objectAnimator.setRepeatMode(ValueAnimator.REVERSE);
objectAnimator.addListener(new Animator.AnimatorListener() {