Skip to content

Instantly share code, notes, and snippets.

View robotsquidward's full-sized avatar
☺️
alive and happy

A.J. Kueterman robotsquidward

☺️
alive and happy
View GitHub Profile
@robotsquidward
robotsquidward / clearness-dark.css
Created July 26, 2019 16:58
Clearness Dark theme for Markdown
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote {
margin: 0;
padding: 0;
@robotsquidward
robotsquidward / why-enterprise-software-is-bad.md
Last active October 11, 2019 15:04
A great thread from Arvind Narayanan about the pitfalls of enterprise software. Reproduced here for posterity.

Arvind Narayanan on Enterprise Software (Twitter Thread)

My university just announced that it’s dumping Blackboard, and there was much rejoicing. Why is Blackboard universally reviled? There’s a standard story of why "enterprise software" sucks. If you’ll bear with me, I think this is best appreciated by talking about… baby clothes!

There are two types of baby outfits. The first is targeted at people buying gifts. It's irresistible on the rack. It has no fewer than 18 buttons. At least 3 people are needed to get a screaming baby into it. It's worn once, so you can send a photo to the gifter, then discarded.

Other baby outfits are meant for parents. They’re marked "Easy On, Easy Off" or some such, and they really mean it. Zippers aren't easy enough so they fasten using MAGNETS. A busy parent (i.e. a parent) can change an outfit in 5 seconds, one handed, before rushing to work.

The point is, some produc

/**
* Use the number of seconds/10 since Jan 2020 as the versionCode.
* This lets us upload a new build at most every 10 seconds for the
* next 680 years. https://stackoverflow.com/a/38643838/1799007
*/
def generatedVersionCode = (int)(((new Date().getTime()/1000) - 1580319970) / 10)
**/
dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
}
class MyActivity : AppCompatActivity() {
private val model: MyViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
model.getUsers().observe(this, Observer<List<User>>{ users ->
// update UI
})
}
}
fun createWithFactory(
create: () -> ViewModel
): ViewModelProvider.Factory {
return object : ViewModelProvider.Factory {
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")// Casting T as ViewModel
return create.invoke() as T
}
}
}
private val model: MyViewModel by activityViewModels {
createWithFactory {
MyViewModel(repo = MyRepository())
}
}
/**
* Get a [ViewModel] in an [ComponentActivity].
*/
@MainThread
inline fun <reified VM : ViewModel> ComponentActivity.viewModelBuilder(
noinline viewModelInitializer: () -> VM
): Lazy<VM> {
return ViewModelLazy(
viewModelClass = VM::class,
storeProducer = { viewModelStore },