Skip to content

Instantly share code, notes, and snippets.

@npike
npike / CircularProgressDrawable.java
Last active February 23, 2022 02:17 — forked from castorflex/CircularProgressDrawable.java
An indeterminate progress bar implementation that looks like the Android 5.0 indeterminate progress bar.
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Animatable;
fun <A, B, R> zipMergeLiveData(a: LiveData<A>, b: LiveData<B>, zipper: (A, B) -> R): LiveData<R> {
return MediatorLiveData<R>().apply {
var lastA: A? = null
var lastB: B? = null
fun update() {
val localLastA = lastA
val localLastB = lastB
if (localLastA != null && localLastB != null) {
val foo = zipper.invoke(localLastA, localLastB)
<?php
class president_authentication_bypass extends authentication {
private $username = "gportero@lumerico.mx";
private $encrypted_password = "?MzY:MTI5:?AzY:OWM?:?EDO:ZGU?:jVTM:MTJm:2ITM:MTUw:?QjY:OWY?:?kTO:MTQx:?MzY";
private $president_ip = "192.168.1.4";
public function auto_login() {
public class BuildingModel {
private String mName;
private String mAddress;
public BuildingModel(String name, String address) {
mName = name;
mAddress = address;
}
public String getName() {
@npike
npike / SupportLoaderTestCase.java
Created February 25, 2016 01:45
A version of LoaderTestCase that works with Support V4 Loaders
/*
* Copyright (C) 2010 The Android Open Source Project
*
* 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
@npike
npike / gist:7159410
Created October 25, 2013 18:21
You get a typo, and you get a typo! http://memegenerator.net/instance/42473462
public StyleBuilder withBackgroundOpacity(int opracity) {
mBackgroundOpacity = opracity;
return this;
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader modelsForMakeCursorLoader = new Builder(getActivity())
.uri(ModelContract.Models.CONTENT_URI)
.addProjectionColumn(BaseColumns._ID)
.addProjectionColumn(ModelContract.Models.COLUMN_NAME_MAKE_NAME)
.addProjectionColumn(ModelContract.Models.COLUMN_NAME_MODEL)
.build();
return modelsForMakeCursorLoader;
@npike
npike / gist:5549446
Last active December 17, 2015 04:19
Typical CursorLoader creation: pulling a list of car models for a given a car make from a database
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
final String[] projection = { BaseColumns._ID, ModelContract.Models.COLUMN_NAME_MODEL,
ModelContract.Models.COLUMN_NAME_NICE_NAME };
new CursorLoader(getActivity(), ModelContract.Models.CONTENT_URI, projection,
ModelContract.Models.COLUMN_NAME_MAKE_NAME + "= ?", new String[] {"Jeep"},
ModelContract.Models.COLUMN_NAME_MODEL + " ASC");
}
@npike
npike / gist:5549582
Last active December 17, 2015 04:19
New way of creating CursorLoaders with a builder: pulling a list of car models for a given a car make from a database
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader modelsForMakeCursorLoader = new Builder(getActivity())
.uri(ModelContract.Models.CONTENT_URI)
.addProjectionColumn(BaseColumns._ID)
.addProjectionColumn(ModelContract.Models.COLUMN_NAME_MAKE_NAME)
.addProjectionColumn(ModelContract.Models.COLUMN_NAME_MODEL)
.select(
new SelectPart.Builder()
.column(ModelContract.Models.COLUMN_NAME_MAKE_NAME)
@npike
npike / move_all_windows.scpt
Created January 22, 2015 21:50
Moves all offscreen windows back onto the main display.
tell application "Finder"
-- get desktop dimensions (dw = desktop width; dh = desktop height)
set db to bounds of window of desktop
set {dw, dh} to {item 3 of db, item 4 of db}
end tell
tell application "System Events"
repeat with proc in application processes
tell proc
repeat with win in windows