Skip to content

Instantly share code, notes, and snippets.

View AfzalivE's full-sized avatar

Afzal Najam AfzalivE

View GitHub Profile
$testuser = new User;
$testuser->username = 'testuser';
$testuser->email = 'test@vv.api';
$testuser->password = 'test';
$testuser->first_name = 'Harry';
$testuser->last_name = 'Potter';
$testuser->confirmed = 1;
$testuser->save();
<?php
// Other methods go here
// Auth filter
Route::filter('auth', function()
{
if (\League\OAuth2\Server\Util\Request::buildFromGlobals()->header('Authorization')) {
// TODO DOES NOT WORK!!!
return Route::filter('oauth', 'LucaDegasperi\OAuth2Server\Filters\OAuthFilter');
} else {
@AfzalivE
AfzalivE / GuavaUtils.java
Last active April 1, 2016 18:52
Guava methods for todoapp-mvp
/*
* Copyright (C) 2007 The Guava Authors
*
* 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
@AfzalivE
AfzalivE / Android CI
Created December 1, 2016 00:22 — forked from JvmName/Android CI
Android CI
#Android and CI and Gradle (A How-To)
There are tech stacks in this world that make it dead simple to integrate a <abbr title="Continuous Integration">CI</abbr> build system. <br>
The Android platform is not one of them.
Although Gradle is getting better, it's still a bit non-deterministic, and some of the fixes you'll need will start to feel more like black magic than any sort of programming.
But fear not! It can be done!
Before we embark on our journey, you'll need a few things to run locally:
@AfzalivE
AfzalivE / BottomSheetView.java
Last active March 13, 2017 03:16
DisableSwipeBottomSheetBehavior
public class BottomSheetView extends NestedScrollView {
private BottomSheetBehavior bottomSheetBehavior;
private RecyclerView devicesListV;
public BottomSheetView(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.bottom_sheet_view, this, true);
@AfzalivE
AfzalivE / ConditionalTestRule.java
Last active January 28, 2019 15:42
Run test if a condition is true
import com.azimolabs.conditionwatcher.Instruction;
import org.junit.Assume;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import timber.log.Timber;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@AfzalivE
AfzalivE / LocaleChanger.java
Last active April 7, 2019 16:32
Class to change android OS locale (works till API 24, M)
public class LocaleChanger {
public static void setLocale(ArrayList<Locale> arrayList) {
try {
Class cls = Class.forName("android.app.ActivityManagerNative");
Method method = cls.getMethod("getDefault", new Class[0]);
method.setAccessible(true);
Object invoke = method.invoke(cls, new Object[0]);
method = cls.getMethod("getConfiguration", new Class[0]);
method.setAccessible(true);
@AfzalivE
AfzalivE / ViewModelFactory.kt
Created July 29, 2019 18:29
ViewModelFactory for Dagger2
/**
* Constructs a ViewModelFactory with dependencies
*/
@Singleton
class ViewModelFactory @Inject constructor(
private val creators: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>>
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
var creator = creators[modelClass]
@AfzalivE
AfzalivE / idea
Last active January 15, 2020 09:38 — forked from chrisdarroch/idea
Open/Import a gradle or idea project in Android Studio from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/Android\ Studio.app | tail -n1`
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`

Keybase proof

I hereby claim:

  • I am afzalive on github.
  • I am afzal (https://keybase.io/afzal) on keybase.
  • I have a public key ASCEiRXUkvJrKqp2vh1X3N1jI9nKfF_liHnizkJSvnZFPAo

To claim this, I am signing this object: