Skip to content

Instantly share code, notes, and snippets.

Nicholas Pike npike

Block or report user

Report or block npike

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:765d83299aeeb86f2c0931fc4f221ec9
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)
View class.president-bypass.php
<?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() {
View BuildingModel.java
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 Feb 25, 2016
A version of LoaderTestCase that works with Support V4 Loaders
View SupportLoaderTestCase.java
/*
* 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 / CircularProgressDrawable.java
Last active Aug 29, 2015 — forked from castorflex/CircularProgressDrawable.java
An indeterminate progress bar implementation that looks like the Android 5.0 indeterminate progress bar.
View CircularProgressDrawable.java
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;
@npike
npike / move_all_windows.scpt
Created Jan 22, 2015
Moves all offscreen windows back onto the main display.
View move_all_windows.scpt
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
@npike
npike / dump_appdata.sh
Last active Aug 29, 2015
Given the package name of an Android app on the device, trigger a backup via ADB and then extract the resulting backup file into the current directory. Useful for debuging sql databases in the app.
View dump_appdata.sh
#!/bin/bash
# @author npike@phunware.com
#
# 1. Download script and store somewhere that makes you happy. Perhaps ~/Downloads on a Mac
# 2. From a terminal: chmod +x dump_appdata.sh
# 3. From a terminal: ./dump_appdata.sh com.my.app
# 4. Click "Back up my data" on connected device
# 5. Wait for backup and extraction to complete. An "app" folder will be written in the same directory
# of where this script is saved.
#
@npike
npike / IAPWatchGridView.java
Created Jun 19, 2014
A simple view that builds out a grid.
View IAPWatchGridView.java
package tv.revolt.android.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;
View gist:7159410
public StyleBuilder withBackgroundOpacity(int opracity) {
mBackgroundOpacity = opracity;
return this;
}
View gist:5549706
@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;
You can’t perform that action at this time.