Skip to content

Instantly share code, notes, and snippets.

View abeldantas's full-sized avatar
🔮
Yes!

Abel Dantas abeldantas

🔮
Yes!
  • Kronoverse
  • Portugal
View GitHub Profile
@abeldantas
abeldantas / main.lua
Last active October 12, 2016 18:15
Ellipse animation in LÖVE lua
function love.load()
-- Comet, is going to move around the Sun
comet = {}
comet.x = 0
comet.y = 0
-- These are 'a' and 'b' in the ellipse formula, think aphelion and perihelion
comet.trajectoryHeight = 40
comet.trajectoryWidth = 120
comet.timeItTakesToGoAroundTheSun = 3 -- 3 seconds, pretty fast
comet.timeSinceBeginning = 0
@abeldantas
abeldantas / LerpEllipseExample.cs
Created October 12, 2016 18:14
Ellipse animation in Unity C#
using UnityEngine;
// Add this MonoBehaviour to anything on the scene and it will create a prototype comet moving around a pivot
public class LerpEllipseExample : MonoBehaviour
{
// These are 'a' and 'b' in the ellipse formula, think aphelion and perihelion
float trajectoryHeight = 4; // y
float trajectoryWidth = 12; // x
float timeItTakesToGoAroundTheSun = 6; // 6 seconds, pretty fast
@abeldantas
abeldantas / TogglePin.cs
Created November 21, 2016 16:23
Unity Toggle Pin ESP8266 NodeMCU
using System.Collections;
using UnityEngine;
public class TogglePin : MonoBehaviour
{
private int index;
private string[] commands = new[] { "pin=ON1", "pin=OFF1" };
public void Click()
{
string url = "http://192.168.4.1?" + commands[index];
@abeldantas
abeldantas / AdManager.cs
Created March 2, 2017 11:57
Hit'n'run - Showing ads with supersonic
using System;
using UnityEngine;
public class AdManager : GameObjectSingleton<AdManager>
{
public string appKey = "3fbb9d89";
bool hasRewardBeenGiven;
Action onSuccess;
Action onCanceled;
@abeldantas
abeldantas / FindMonobehaviourInScene.cs
Created April 24, 2018 15:38
Find Monobehaviour In Scene
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class FindMonobehaviourInScene
{
[MenuItem( "Editor Utils/Select Script in Scene #&s" )] public static void SelectScriptInScene()
using System.Collections.Generic;
using System.Linq;
using FullInspector;
using MathUtils;
using UnityEngine.UI;
public class FadeGraphics : BaseBehavior
{
public Dictionary<float, List<Graphic>> GraphicFinalAlphaMap;
#!/bin/sh
FILE=$(find . -name '*.asm.framework.unityweb' -exec basename {} +)
echo 'fixed '$FILE
mv $FILE $FILE.gz
gunzip $FILE.gz
gsed -i.bak 's#function _JS_Sound_Init(){try{window.AudioContext=window.AudioContext||window.webkitAudioContext;WEBAudio.audioContext=new AudioContext;WEBAudio.audioWebEnabled=1}catch(e){alert("Web Audio API is not supported in this browser")}}#function _JS_Sound_Init(){try{window.AudioContext=window.AudioContext||window.webkitAudioContext;WEBAudio.audioContext=new AudioContext();var tryToResumeAudioContext=function(){if(WEBAudio.audioContext.state==="suspended")WEBAudio.audioContext.resume();else{clearInterval(resumeInterval)}};var resumeInterval=setInterval(tryToResumeAudioContext,400);WEBAudio.audioWebEnabled=1}catch(e){alert("Web Audio API is not supported in this browser")}}#g' $FILE
rm $FILE.bak
gzip --best $FILE
mv $FILE.gz $FILE
Transaction CreateUtxoSpendTxn( string rawUtxo, byte[][] msg )
{
var utxo = JsonConvert.DeserializeObject<UTXO>( rawUtxo );
Debug.Log( rawUtxo );
var coin = new Coin( new uint256( utxo.TxId), (uint)utxo.OutputIndex, utxo.Satoshis, bitcoinSecret.ScriptPubKey );
var txnBuilder = NBitcoin.Altcoins.BCash.Instance.Mainnet.CreateTransactionBuilder();
return txnBuilder
.AddCoins( coin )
.AddKeys( bitcoinSecret )
@abeldantas
abeldantas / CreateGameAsync.cs
Created February 27, 2019 21:52
CreateGameAsync.cs
IEnumerator CreateGameAsync()
{
StartCoroutine( GetUsernameFromIdAsync( OpponentName.text, (id, isUsernameValid) =>
{
if ( !isUsernameValid )
{
FadeScreen.FadeBack();
GameCreationError.SetActive( true );
StartCoroutine( CoroutineHelper.WaitAndDo( 3.5f, () => { ShowMenu.OnClick(); } ) );
}
using UnityEngine;
public class Animal<T> : MonoBehaviour
{
public new T Injector;
}
public class Horse : Animal<ISteroidsInjector>
{
}