Skip to content

Instantly share code, notes, and snippets.

View Chrispassold's full-sized avatar

Christian Passold Chrispassold

View GitHub Profile
@patrickhammond
patrickhammond / EspressoTestCase.java
Last active September 21, 2021 13:42
Base class for Espresso (https://code.google.com/p/android-test-kit/wiki/Espresso) tests that deals with some of the library ugliness and gotchas. Implementations **must** ensure super.setUp() and super.tearDown() are called if they are overridden.
import android.app.Activity;
import android.content.Context;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.test.ActivityInstrumentationTestCase2;
/**
* This requires to be declared in the effective manifest:
* <uses-permission android:name="android.permission.WAKE_LOCK"/>
*
@cbeyls
cbeyls / ContentLoadingProgressBar.java
Last active December 20, 2021 22:16
ContentLoadingProgressBar implemented The Right Way™
package be.digitalia.common.widgets;
import android.content.Context;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ProgressBar;
/**
* ContentLoadingProgressBar implements a ProgressBar that waits a minimum time to be
@Jeevuz
Jeevuz / Extensions.kt
Last active January 3, 2023 10:25
Here I collect some of my most useful Kotlin extensions
inline fun SharedPreferences.edit(changes: SharedPreferences.Editor.() -> SharedPreferences.Editor) {
edit().changes().apply()
}
fun ImageView.tintSrc(@ColorRes colorRes: Int) {
val drawable = DrawableCompat.wrap(drawable)
DrawableCompat.setTint(drawable, ContextCompat.getColor(context, colorRes))
setImageDrawable(drawable)
if (drawable is TintAwareDrawable) invalidate() // Because in this case setImageDrawable will not call invalidate()
}
@marioluan
marioluan / remover-acentos.js
Created October 10, 2013 18:27
Funcao marota para remover acentos de strings. Foi utilizado expressao regular em cima de caracteres representados na base hexadecimal.
/**
* Remove acentos de caracteres
* @param {String} stringComAcento [string que contem os acentos]
* @return {String} [string sem acentos]
*/
function removerAcentos( newStringComAcento ) {
var string = newStringComAcento;
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
e : /[\xE8-\xEB]/g,
@bvaughn
bvaughn / react-lifecycle-cheatsheet.md
Last active March 2, 2023 13:29
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
@passsy
passsy / material text sizes.md
Last active May 25, 2023 04:24
Material font sizes
@akexorcist
akexorcist / app_listing.java
Last active August 29, 2023 02:16
Get application name android package name from all application which have launcher (Not all app in device)
PackageManager pm = getPackageManager();
Intent main = new Intent(Intent.ACTION_MAIN, null);
main.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> packages = pm.queryIntentActivities(main, 0);
ArrayList<String> app_name_list = new ArrayList<String>();
ArrayList<String> app_package_list = new ArrayList<String>();
for(ResolveInfo resolve_info : packages) {
try {
@jonlabelle
jonlabelle / string-utils.js
Last active October 30, 2023 20:33
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@brianclements
brianclements / dkcleanup.sh
Last active November 13, 2023 10:49
Bash script helper to remove Docker images and containers.
#!/bin/bash
# options:
# remove stopped containers and untagged images
# $ dkcleanup
# remove all stopped|running containers and untagged images
# $ dkcleanup --reset
# remove containers|images|tags matching {repository|image|repository\image|tag|image:tag}
# pattern and untagged images
# $ dkcleanup --purge {image}
@sabarasaba
sabarasaba / gist:3080590
Created July 10, 2012 02:19
Remove directory from remote repository after adding them to .gitignore
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master