Skip to content

Instantly share code, notes, and snippets.

@nesquena
nesquena / PatternEditableBuilder.java
Last active October 21, 2022 10:20
PatternEditableBuilder - Easy way to create colored clickable spans within a TextView!
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.regex.Matcher;
@daicham
daicham / .gitlab-ci.yml
Last active November 13, 2024 07:47
A sample of .gitlab-ci.yml for a gradle project
image: java:8-jdk
stages:
- build
- test
- deploy
before_script:
# - echo `pwd` # debug
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active April 10, 2025 01:40
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@paulocaldeira17
paulocaldeira17 / AppBarStateChangeListener.java
Last active August 22, 2024 06:23
Android AppBarLayout collapsed/expanded state listener
import android.support.design.widget.AppBarLayout;
/**
* App bar collapsing state
* @author Paulo Caldeira <[email protected]>.
*/
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
// State
public enum State {
EXPANDED,
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.security.KeyPairGeneratorSpec;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import java.io.ByteArrayInputStream;
@mohsin
mohsin / StringUtils.java
Last active April 11, 2021 13:40
Function to convert Android menu.xml into string array for use in ArrayAdapter for NavigationDrawer
import android.view.Menu;
import android.view.MenuInflater;
import android.content.Context;
import android.support.v7.view.menu.MenuBuilder;
public class StringUtils {
/*
* Usage: String[] mMenuItems = StringUtils.getArrayFromMenu(this, R.menu.menu_main);
* And then mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.item_listview_drawer, mMenuItems));
/*
* Copyright 2015 Google Inc.
*
* 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
@nisrulz
nisrulz / grayscale_imageview.java
Created December 25, 2015 05:52
Apply grayscale filter to ImageView in android
ImageView imgview = (ImageView)findViewById(R.id.imageView_grayscale);
imgview.setImageBitmap(bitmap);
// Apply grayscale filter
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imgview.setColorFilter(filter);
@justo
justo / atom-invisibles-override.less
Created December 9, 2015 20:56
Style to make Atom's tab character a wide line like Sublime Text and to only show invisibles on document highlight.
atom-text-editor::shadow {
/**
* Put this in your Atom stylesheet to replace the tab character with
* a full-width line like in Sublime Text. Change the background color
* to match your theme.
*
* Open your Atom settings and under "Editor Settings" change your
* "Invisbles Tab" field to a single space (" "). Otherwise you will see
* both tab indicators.
*/