Skip to content

Instantly share code, notes, and snippets.

View jirevwe's full-sized avatar
🏠
Working from home

Raymond Tukpe jirevwe

🏠
Working from home
View GitHub Profile
@jirevwe
jirevwe / gist:0a0a1eade41a34bcbeb69340332b8853
Created April 27, 2018 22:47 — forked from yqritc/gist:ccca77dc42f2364777e1
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration

ItemOffsetDecoration

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
    }
@jirevwe
jirevwe / BottomBarNavigation.java
Created April 17, 2018 10:31
BottomBarNavigation code to retain fragment state
package com.ouida.app.ui.home;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
@jirevwe
jirevwe / ScreenBase.cs
Created February 25, 2018 22:35
ScreenBase is a base class for Unity UI Panels. It handles transitions, adding tasks before and after the screen has shown and delays. It depends on DOTween
using UnityEngine;
using System.Collections;
using DG.Tweening;
using System;
[RequireComponent(typeof(CanvasGroup))]
public abstract class ScreenBase : MonoBehaviour
{
CanvasGroup canvasGroup;
@jirevwe
jirevwe / ScreenBase.cs
Created February 25, 2018 22:34
ScreenBase is a base class for Unity UI Panels. It handles transitions,
using UnityEngine;
using System.Collections;
using DG.Tweening;
using System;
[RequireComponent(typeof(CanvasGroup))]
public abstract class ScreenBase : MonoBehaviour
{
CanvasGroup canvasGroup;
@jirevwe
jirevwe / CameraShake.cs
Last active February 25, 2018 22:28
A script to start a screen shake in Unity
using UnityEngine;
using System.Collections;
public class CameraShake : MonoBehaviour
{
public static CameraShake main;
// Transform of the camera to shake. Grabs the gameObject's transform
// if null.
public Transform camTransform;
package ng.smartalumni.smartsocket;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import org.json.JSONException;
import org.json.JSONObject;
@jirevwe
jirevwe / HologramShader2D.cs
Created October 15, 2017 11:53
SpriteRe 2d Hologram Shader
Shader "Unlit/maskedSprite"
{
Properties
{
[Toggle]_ShowMask ("Preview mask", Float) = 0
[Space]
[Toggle]_UseAlpha ("Vertex Alpha > Threshold", Float) = 0
[Space]
_MaskThrs ("Mask Threshold", Range(0,1)) = .5
_MaskSoft ("Mask Width", Range (0.001, 3)) = 1
@jirevwe
jirevwe / RotateOverTime.cs
Last active October 8, 2017 23:41
Unity C# snippet to rotate a transform to a new relative rotation over a number of seconds
// Rotate the object from it's current rotation to "newRotation" over "duration" seconds
void StartRotate(Vector3 newRotation, float duration = 0.5f)
{
if (SlerpRotation != null) // if the rotate coroutine is currently running, so let's stop it and begin rotating to the new rotation.
StopCoroutine(SlerpRotation);
SlerpRotation = Rotate(newRotation, duration);
StartCoroutine(SlerpRotation);
}
@jirevwe
jirevwe / Player.cs
Last active April 25, 2017 16:46
Script for Barrel Roll... Explains how to use Unity3d's Quaternion.Slerp (Use a Coroutine instead)
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using UnityEngine;
public class Player : MonoBehaviour {
[SerializeField]
float flippedTime = 0f;
float startFlip = 0f;
@jirevwe
jirevwe / dropzone example.js
Last active April 7, 2017 11:38
DropzoneJS nodejs example code
//helper to get a file extension
String.prototype.getExtension = function() {
var basename = this.split(/[\\/]/).pop(), // extract file name from full path ...
// (supports `\\` and `/` separators)
pos = basename.lastIndexOf("."); // get last position of `.`
if (basename === "" || pos < 1) // if file name is empty or ...
return ""; // `.` not found (-1) or comes first (0)
return basename.slice(pos + 1); // extract extension ignoring `.`