Skip to content

Instantly share code, notes, and snippets.

View forestrf's full-sized avatar

Andrés Leone Gámez forestrf

View GitHub Profile
@forestrf
forestrf / setup_http_server_on_android_with_termux.md
Last active October 27, 2023 00:56 — forked from vilkoz/setup_http_server_on_android_with_termux.md
setup http server on android with termux

Setting up http server on android with termux

Setting SSH server

To be able to make all procedures without pain you should have physical keyboard or just install ssh server and connect to your device shell from computer.

Folow this guide to setup ssh server.

Installing needed stuff

@forestrf
forestrf / gist:4bc9e2cc56acb74a6719547e22072d68
Created August 5, 2023 20:08 — forked from ykst/gist:6e80e3566bd6b9d63d19
WebAudio+WebSocketでブラウザへの音声リアルタイムストリーミングを実装する

WebAudio+WebSocketでブラウザへの音声リアルタイムストリーミングを実装する

WebRTCでやれよ!と言われそうなところですが、 WebSocket+WebAudioの組み合わせで音声ストリーミングをシンプルに構成する方法を紹介してみます。

サーバーサイド(Node.js + ws + pcm)

サーバーサイドは何でも良いのですが、 とりあえずNode.jsでtest.mp3というサンプルファイルをpcmモジュールでデコードし、 wsでクライアントに垂れ流す作りにしておきます。

@forestrf
forestrf / DefineSymbolUtil.cs
Last active July 8, 2023 01:17 — forked from LaneF/DefineSymbolUtil.cs
Unity Define Symbols Utility
using UnityEditor;
using UnityEngine;
using System.Linq;
using UnityEditor.Callbacks;
namespace Ashkatchap {
public static class DefineSymbolUtil {
static readonly (string, string)[] TypeAndSymbol = new[] {
("UltEvents.UltEventBase, UltEvents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "USE_ULTEVENTS"),
};
@forestrf
forestrf / PhotoshopMathFP.hlsl
Created March 4, 2023 23:38 — forked from unitycoder/PhotoshopMathFP.hlsl
PhotoshopMath hlsl shader
// https://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/
/*
** Photoshop & misc math
** Blending modes, RGB/HSL/Contrast/Desaturate
**
** Romain Dura | Romz
** Blog: http://blog.mouaif.org
** Post: http://blog.mouaif.org/?p=94
*/
@forestrf
forestrf / BlurEffect.compute
Created April 8, 2022 19:46 — forked from Refsa/BlurEffect.compute
Unity URP custom render feature for UI Blur
#pragma kernel Downscale
#pragma kernel GaussianBlurVertical
#pragma kernel GaussianBlurHorizontal
#pragma kernel BoxBlur
Texture2D<float4> _Source;
RWTexture2D<float4> _Dest;
float _Amount;
float2 _Size;
@forestrf
forestrf / ExtendedScriptableObjectDrawer.cs
Created November 13, 2021 02:06 — forked from tomkail/ExtendedScriptableObjectDrawer.cs
Displays the fields of a ScriptableObject in the inspector
// Developed by Tom Kail at Inkle
// Released under the MIT Licence as held at https://opensource.org/licenses/MIT
// Must be placed within a folder named "Editor"
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
@forestrf
forestrf / fbfetch.shader
Created September 22, 2021 12:27 — forked from aras-p/fbfetch.shader
Framebuffer fetch shader in Unity
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
// in practice: only compile for gles2,gles3,metal
#pragma only_renderers framebufferfetch
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
@forestrf
forestrf / DebugUtil.cs
Created March 26, 2021 11:52 — forked from AlexanderDzhoganov/DebugUtil.cs
Dump RenderTexture to PNG in Unity
public static class DebugUtil
{
public static void DumpRenderTexture(RenderTexture rt, string pngOutPath)
{
var oldRT = RenderTexture.active;
var tex = new Texture2D(rt.width, rt.height);
RenderTexture.active = rt;
tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
@forestrf
forestrf / ComputeGunLead.cs
Created March 24, 2021 20:41 — forked from brihernandez/ComputeGunLead.cs
Computes a point for a gun to aim at in order to hit a target using linear prediction.
/// <summary>
/// Computes a point for a gun to aim at in order to hit a target using linear prediction.
/// Assumes a bullet with no gravity or drag. I.e. A bullet that maintains a constant.
/// velocity after it's been fired.
/// </summary>
public static Vector3 ComputeGunLead(Vector3 targetPos, Vector3 targetVel, Vector3 ownPos, Vector3 ownVel, float muzzleVelocity)
{
// Extremely low muzzle velocities are unlikely to ever hit. This also prevents a
// possible division by zero if the muzzle velocity is zero for whatever reason.
if (muzzleVelocity < 1f)
@forestrf
forestrf / Distortion.shader
Created February 21, 2021 02:06 — forked from Fewes/Distortion.shader
Distortion shader for Unity. Supports a normal map.
Shader "Distortion"
{
Properties
{
_Refraction ("Refraction", Range (0.00, 10.0)) = 1.0
_Power ("Power", Range (1.00, 10.0)) = 1.0
_AlphaPower ("Vertex Alpha Power", Range (1.00, 10.0)) = 1.0
_BumpMap( "Normal Map", 2D ) = "bump" {}
_Cull ( "Face Culling", Int ) = 2