Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Gomez danielgomezrico

View GitHub Profile
@danielgomezrico
danielgomezrico / find_replace_all.sh
Created Dec 10, 2018
Bash - Replace all with find
View find_replace_all.sh
#!/bin/bash
find $1 -type f -exec sed -i "s/$2/$3/g" '{}' \;
@danielgomezrico
danielgomezrico / Observable+Extensions.swift
Created Jun 15, 2018
ios - how to add an extension to Observable and generics
View Observable+Extensions.swift
import Foundation
import RxSwift
import RxCocoa
extension ObservableType where E == String {
/// Limit the max size of the string that's been emitted
func limit(maxStringSize: Int) -> RxSwift.Observable<String> {
return scan("") { (previous, new) -> String in
return new.count <= maxStringSize ? new : previous
@danielgomezrico
danielgomezrico / TextViewExtensions.kt
Created Feb 26, 2018
Extension to set a text with HTML tags on TextView
View TextViewExtensions.kt
fun TextView.setHtmlText(text: String) {
val formattedText = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)
} else {
Html.fromHtml(text)
}
setText(formattedText, TextView.BufferType.SPANNABLE)
movementMethod = LinkMovementMethod.getInstance()
}
@danielgomezrico
danielgomezrico / gist:874cd2f7a923173415817136d761d3e8
Created Feb 17, 2018
[Kotlin, rxjava and room] - how to always get a value from Maybe
View gist:874cd2f7a923173415817136d761d3e8
class Optional<out M>(val data: M?)
@Dao
interface PatientDao {
@Query("SELECT * FROM $patientTableName LIMIT 1")
fun getFirst(): Maybe<User>
}
@danielgomezrico
danielgomezrico / rbenv-install-system-wide.sh
Last active Feb 5, 2018 — forked from tomazzlender/rbenv-install-system-wide.sh
rbenv install and system wide install on Ubuntu to /opt/rbenv
View rbenv-install-system-wide.sh
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/rbenv/rbenv.git /opt/rbenv
# Add rbenv to the path:
@danielgomezrico
danielgomezrico / .gitlab-ci.yml
Last active Jun 16, 2020
Android / Gitlab ci - sample setup files to setup your own local gitlab runner with real physical android devices. Check https://github.com/caipivara/awesome-android-scripts
View .gitlab-ci.yml
stages:
- build
- test
- deploy
variables:
GIT_STRATEGY: clone
cache:
key: ${CI_PROJECT_ID}