Skip to content

Instantly share code, notes, and snippets.

View NezSpencer's full-sized avatar

Nnabueze Uhiara NezSpencer

  • Portugal
View GitHub Profile
@NezSpencer
NezSpencer / file.ps1
Created April 11, 2016 15:39 — forked from Dalmirog-zz/file.ps1
Create release passing package version
$apiKey = "" #Octopus API Key
$OctopusURL = "" #Octopus URL
$ProjectName = "" #project name
$Header = @{ "X-Octopus-ApiKey" = $apiKey }
#Getting Project By Name
$Project = Invoke-WebRequest -Uri "$OctopusURL/api/projects/$ProjectName" -Headers $Header| ConvertFrom-Json
#Getting Deployment Template to get next release version
@NezSpencer
NezSpencer / CountDownTimer.java
Created April 27, 2016 16:06 — forked from Gautier/CountDownTimer.java
Drop-in alternative for the Android CountDownTimer class, but which you can cancel from within onTick.
/*
* Copyright (C) 2008 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
@NezSpencer
NezSpencer / DpToPxAndPxToDp
Created July 21, 2016 15:53 — forked from laaptu/DpToPxAndPxToDp
Android convert dp to px and vice versa
public static float convertPixelsToDp(float px){
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float dp = px / (metrics.densityDpi / 160f);
return Math.round(dp);
}
public static float convertDpToPixel(float dp){
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float px = dp * (metrics.densityDpi / 160f);
return Math.round(px);
@NezSpencer
NezSpencer / BakingRecipe.java
Created June 23, 2017 16:19
Pojo class for baking app
package com.nezspencer.bakingapp.pojo;
import android.os.Parcel;
import android.os.Parcelable;
public class BakingRecipe implements Parcelable {
public static final Creator<BakingRecipe> CREATOR = new Creator<BakingRecipe>() {
@Override
public BakingRecipe createFromParcel(Parcel source) {
BakingRecipe var = new BakingRecipe();
@NezSpencer
NezSpencer / composer.json
Created July 4, 2017 15:03
class 'Barryvdh\Cors\ServiceProvider' not found issue
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-cors": "^0.9.2",
"fzaninotto/faker": "^1.6",
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
@NezSpencer
NezSpencer / README.md
Created September 15, 2017 03:51 — forked from polbins/README.md
Android Studio as default Git Diff Tool

Create Android Studio Command-line Launcher

  1. Open Android Studio
  2. Go to: Tools > Create Command-line Launcher
  3. Leave as default, Press OK

Configure Git to use Android Studio as default Diff Tool

  1. Add the following lines to your .gitconfig
@NezSpencer
NezSpencer / SetSingleValue.kt
Created July 22, 2018 18:23
How to set a single value to firebase realtime database and firestore
//firebase realtime database (RTDB)
FirebaseDatabase.getInstance().reference.child("phoneNumber").setValue("+2345899xxx")
//Firestore
val map = mutableMapOf<String, Any>()
map["PhoneNumber1"] = "+2345899xxx"
FirebaseFirestore.getInstance().collection("Numbers").document("PhoneNumbers").set(map)
@NezSpencer
NezSpencer / MainActivity.kt
Created September 30, 2018 07:47
query lifecycle state
@Override
fun onSuccess(){
if(lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) {
//perform action here
}
}