Skip to content

Instantly share code, notes, and snippets.

View mrmike's full-sized avatar

Michal Moczulski mrmike

View GitHub Profile
@mrmike
mrmike / AnnotatedStringExt.kt
Created January 27, 2022 17:57
Extension function for simpler annotated string creation with decoration in Jetpack Compose Compose
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.ParagraphStyle
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TtsAnnotation
fun AnnotatedString.Builder.appendDecorated(
text: String,
spanStyle: SpanStyle? = null,
paragraphStyle: ParagraphStyle? = null,
textAnnotation: TextAnnotation? = null,
@mrmike
mrmike / AndroidComposeRule.kt
Created November 2, 2021 06:29
Create Android Compose Rule using Intent
import android.content.Intent
import androidx.activity.ComponentActivity
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.ext.junit.rules.ActivityScenarioRule
inline fun <reified A : ComponentActivity> createAndroidComposeRule(intent: Intent): AndroidComposeTestRule<ActivityScenarioRule<A>, A> {
return AndroidComposeTestRule(
activityRule = ActivityScenarioRule<A>(intent),
activityProvider = { scenario -> scenario.getActivity() }
)
@mrmike
mrmike / .bash_profile
Created January 21, 2019 20:37
.bash_profile
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# bash-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
. /opt/local/etc/profile.d/bash_completion.sh
fi
# Git auto-completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
@mrmike
mrmike / toggle-files-github.js
Last active February 13, 2018 08:56
Github - toggle all files in "File changed" tab
// Toggles all files in "Files changed" tab in pull request
// Can be exectued through javascript console
var buttons = document.querySelectorAll('button[aria-label="Toggle diff text"]')
for (var i = 0; i < buttons.length; i++) {
buttons[i].click()
}
// One liner that can be used as a bookmark
javascript:void((function(d){d.querySelectorAll('button[aria-label="Toggle diff text"]').forEach(function(x){x.click()});})(document));
@mrmike
mrmike / App.java
Last active July 14, 2017 16:12
Replacing modules with dagger component builder
# In App class
public void onCreate() {
applicationComponent = initializeAppComponentBuilder().build();
applicationComponent.inject(this);
}
protected DaggerAppComponent.Builder initializeAppComponentBuilder() {
return DaggerAppComponent.builder()
.applicationModule(new ApplicationModule(this))
.networkModule(new RealNetworkModule())
@mrmike
mrmike / wrapper_task
Created May 22, 2015 10:54
Gradle version update
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
@mrmike
mrmike / getCommitId()
Created April 22, 2015 13:58
Get CommitId in build.gradle
def getCommitId() {
def output = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = output
}
return output.toString()
}
@mrmike
mrmike / gist:8bb221e6461cc44d62cb
Last active December 8, 2015 13:47
prepare-commit-msg
#!/bin/sh
# save file in .git/hooks/prepare-commit-msg
# chmod +x prepare-commit-msg
BRANCH=$(git symbolic-ref --short HEAD)
TICKET=`echo $BRANCH | grep -o 'MOB-\d\{1,\}'`
status=$?
if [ $status -eq 0 ] ; then
echo "[$TICKET]\n$(cat $1)" > $1
@mrmike
mrmike / .bash_profile
Created November 13, 2014 07:29
git settings
alias gst='git status'
alias gd='git diff'
alias gl='git lg'
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_light_red="$(tput setab 1)"
c_sgr0=`tput sgr0`
@mrmike
mrmike / lg
Created November 13, 2014 07:27
Git lg alias
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
co = checkout