Skip to content

Instantly share code, notes, and snippets.

View edudobay's full-sized avatar

Eduardo Dobay edudobay

View GitHub Profile
@edudobay
edudobay / git-allrepos
Last active May 7, 2019 17:19
Script to sync (fetch) all git repos within a directory
#!/usr/bin/env python3
from argparse import ArgumentParser, Namespace
import os
import subprocess
def is_git_repo(entry):
from os.path import join, isdir
return isdir(entry) and isdir(join(entry, '.git'))
@edudobay
edudobay / git-branch-protection.md
Last active August 26, 2024 14:56
Command-line script for protecting/unprotecting branches in a GitHub repository

(To be improved)

Requirements

  • httpie (which provides the http command) — pip install httpie

Setup

  • Save the git-branch-protection.sh as git-branch-protection somewhere in your path (something like ~/bin or ~/.local/bin if you already use it)
  • Generate a GitHub token and save it as ~/.config/github_token.
@edudobay
edudobay / StateMachine.kt
Created January 15, 2018 20:22
RxJava state machine
package example
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import io.reactivex.functions.BiFunction
import io.reactivex.subjects.BehaviorSubject
import java.util.concurrent.TimeUnit
import kotlin.concurrent.thread
enum class InternalState { ON, OFF, GOING_ON, GOING_OFF }
@edudobay
edudobay / EnumValue.kt
Last active November 4, 2017 16:37
Kotlin reified types issue
enum class Gender {
MALE, FEMALE
}
inline fun <reified T : Enum<T>> wrapEnumValueOf(name: String) = enumValueOf<T>(name)
inline fun postInline(block: () -> Unit) = block()
fun post(block: () -> Unit) = block()
@edudobay
edudobay / to_string_builder.py
Created March 22, 2017 20:46
Simple "ToStringBuilder" for Python
def to_string_builder(obj, fields, filters={}):
return '<{name}({fields})>'.format(
name=type(obj).__name__,
fields=', '.join(
'{}={!r}'.format(name, value)
for name, value, predicate in
((name, getattr(obj, name), filters.get(name)) for name in fields)
if predicate is None or predicate(value)),
)
@edudobay
edudobay / FixedBottomAwareScrollViewBehavior.kt
Last active May 15, 2023 16:48
Behavior for CoordinatorLayout that handles views fixed at the bottom
package com.github.edudobay.android
import android.content.Context
import android.support.design.widget.AppBarLayout
import android.support.design.widget.CoordinatorLayout
import android.support.v4.view.ViewCompat
import android.support.v7.widget.Toolbar
import android.util.AttributeSet
import android.view.Gravity
import android.view.View
@edudobay
edudobay / 0_reuse_code.js
Created August 10, 2016 16:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Keybase proof

I hereby claim:

  • I am edudobay on github.
  • I am edudobay (https://keybase.io/edudobay) on keybase.
  • I have a public key ASDbROyO0asRhHnBlKOiDl69yN_7KiOl2mumL5AKpLiHXgo

To claim this, I am signing this object:

@edudobay
edudobay / progfun1-week3.md
Last active August 9, 2016 21:44
Functional Programming with Scala - Course notes

Week 3: Object-Oriented Sets

Note about union performance/complexity

(Taken from the discussion forums)

def union1(that: TweetSet): TweetSet = right.union(left.union(that)).incl(elem)
def union2(that: TweetSet): TweetSet = right.union(that).union(left).incl(elem)
def union3(that: TweetSet): TweetSet = right.union(left.union(that.incl(elem)))
@edudobay
edudobay / java.md
Last active February 15, 2016 13:40
Notes about Java

Useful libraries

  • RxJava - reactive programming (see also Introduction to ReactiveX)
  • Dagger - dependency injection (note: this is the Google fork (version 2). Version 1 is maintained by Square and seems to be still alive)
  • Gson - JSON (de)serialization to/from Java objects

Database, persistence, etc.