Skip to content

Instantly share code, notes, and snippets.

View dhiraj's full-sized avatar

Dhiraj Gupta dhiraj

View GitHub Profile
@llamacademy
llamacademy / BuildDisplayer.cs
Last active September 12, 2024 17:06
Build Incrementor Scripts from https://www.youtube.com/watch?v=PbFE0m9UMtE. If you get value from LlamAcademy, consider becoming a Patreon supporter at https://www.patreon.com/llamacademy
using TMPro;
using UnityEngine;
[RequireComponent(typeof(TextMeshProUGUI))]
public class BuildDisplayer : MonoBehaviour
{
private TextMeshProUGUI Text;
private void Awake()
{
@bernardopacheco
bernardopacheco / 00_README.md
Last active June 27, 2024 06:28
Unity Event Manager event-driven architecture.

Unity Event Manager

This Gist represents an event-driven architecture that helps to structure my games in Unity. It uses events to trigger and communicate between decoupled parts of a game.

Usage

In the first game scene, create an empty Game Object named EventManager and attach the EventManager.cs script to it. This script is set to DontDestroyOnLoad, i.e., it won't be destroyed when reloading scene.

The Producer.cs and Consumer.cs classes show how an event is published and consumed. In this example, when a coin is collected, an addCoins event is published with the collected amount. A Consumer receives the amount of coins collected and update its own coins amount.

@loftywaif002
loftywaif002 / api_keys_android.md
Last active June 4, 2024 13:03
Hiding Api Keys in Anroid

Hiding API keys in local.properties

  1. Make sure your build directory is gitignored. It should be, by default, in a new Android Studio project -- you can double check by making sure that your .gitignore file contains the line:
/build
  1. In your project root directory, add the API key to local.properties file like this:
@lopspower
lopspower / README.md
Last active November 14, 2024 08:32
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@msh9
msh9 / olingoWrapperService.js
Last active August 29, 2015 14:12
Olingo--AngularJS
'use strict';
myApp.factory('olingoWrapperService', ['localStorageService','$location', '$q', '$rootScope', function (localStorageService, $location, $q, $rootScope) {
var _recipeService = {};
var _oldOlingoODataClient = odatajs.oData.net.defaultHttpClient;
var _authSensitiveOlingoClient = {
request: function (request, success, error) {
request.headers = request.headers || {};
var authData = localStorageService.get('authorizationData');
@swizzlr
swizzlr / blockdeclsyntax.md
Created August 19, 2013 13:11
Block Declaration Syntax List, originally by [pcperini](http://stackoverflow.com/a/9201774/929581), parsed to markdown for printing with your favourite CSS (I recommend @ttscoff's Marked)

List of Block Declaration Syntaxes

Throughout, let

  • return_type be the type of object/primitive/etc. you'd like to return (commonly void)
  • blockName be the variable name of the block you're creating
  • var_type be the type object/primitive/etc. you'd like to pass as an argument (leave blank for no parameters)
  • varName be the variable name of the given parameter And remember that you can create as many parameters as you'd like.

Blocks as Variables

Possibly the most common for of declaration.

@dhiraj
dhiraj / AlbumRatingReset.scpt
Last active April 24, 2018 19:30
This AppleScript may allow you to remove or set the album rating on one or more of your tracks to a value you decide. If you use Smart Playlists based on the track rating field, this may be *the* AppleScript you were looking for. If not, then consider moving on, this is probably not what you were looking for. I've modified the script in this fil…
(*
"Album Rating Reset" for iTunes
written by Doug Adams
dougadams@mac.com
v1.0 sept 6 2007
-- initial release
v2.0 mar 6 2013
updated by Dhiraj Gupta (http://www.dhirajgupta.com)