Skip to content

Instantly share code, notes, and snippets.

View zmdominguez's full-sized avatar

Zarah Dominguez zmdominguez

View GitHub Profile
@zmdominguez
zmdominguez / FUN_reset_preferences.kt
Last active November 16, 2018 05:19
Selectively reset Shared Preferences
fun resetPreferences() {
val dataDir = File("${filesDir.parent}/shared_prefs")
// Get the prefs files we are concerned with
val sharedPrefsFiles = dataDir.listFiles().filter { file ->
file.name.startsWith(BuildConfig.APPLICATION_ID)
}
// Get the nice displayable name
val sharedPrefsFileNames = sharedPrefsFiles.map {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
DataBindingUtil.setContentView<ActivityConstraintBinding>(this, R.layout.activity_constraint)
}
@zmdominguez
zmdominguez / bind_views_old_school.java
Created November 11, 2018 21:12
Effectively Wrangling Views via Groups
@BindView(R.id.checkbox) CheckBox mCheckbox;
@BindView(R.id.container) ViewGroup mContainer;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_constraint);
ButterKnife.bind(this);
mCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@zmdominguez
zmdominguez / ViewPagerBindingAdapter.java
Created November 9, 2017 02:12
ViewPager OnPageChangeListener Databinding
import android.databinding.BindingAdapter;
import android.databinding.InverseBindingAdapter;
import android.databinding.InverseBindingListener;
import android.databinding.InverseBindingMethod;
import android.databinding.InverseBindingMethods;
import android.databinding.adapters.ListenerUtil;
import android.support.v4.view.ViewPager;
import com.zdominguez.sdksandbox.R;
@zmdominguez
zmdominguez / mov_to_gif.sh
Last active April 8, 2020 20:37
Converts a .mov to an animated .gif.Requires ffmpeg and gifsicle.
#!/bin/bash
for i in "$@"
do
case $i in
-f=*|--file=*)
FILENAME="${i#*=}"
;;
-o=*|--out=*)
OUTPUT="${i#*=}"
@zmdominguez
zmdominguez / google-io-2016.sh
Created May 31, 2016 13:03
Mostly Android and Firebase sessions from Google I/O 2016
youtube-dl -i https://www.youtube.com/watch?v=w45y_w4skKs
youtube-dl -i https://www.youtube.com/watch?v=LqBlYJTfLP4
youtube-dl -i https://www.youtube.com/watch?v=WJY2tGVQDGQ
youtube-dl -i https://www.youtube.com/watch?v=r_LpCi6DQME
youtube-dl -i https://www.youtube.com/watch?v=70WqJxymPr8
youtube-dl -i https://www.youtube.com/watch?v=B08iLAtS3AQ
youtube-dl -i https://www.youtube.com/watch?v=k3IT-IJ0J98
youtube-dl -i https://www.youtube.com/watch?v=sO9aX87hq9c
youtube-dl -i https://www.youtube.com/watch?v=fFF2Yup2dMM
youtube-dl -i https://www.youtube.com/watch?v=MnvUlGFb3GQ
Weirdness Solution
No debuggable applications Untick then tick again Tools > Android > Enable ADB integration. If that does not work, disable USB debugging on device then re-enable.
Can't put breakpoint in a place where it is normally allowed Unplug device then plug it back in
Stuck in "Scanning files to index" when deploying Unplug device then plug it back in
Everything suddenly becomes really really slow. Really slow, even autocomplete. Check for updates! Pending updates usually cause this.
public static void hideSoftKeyboard(Context context, View view) {
InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
@zmdominguez
zmdominguez / git-branch-term
Created July 4, 2015 12:30
git branch name in Terminal prompt
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "