Skip to content

Instantly share code, notes, and snippets.

View ahmed-shariff's full-sized avatar
👓
Having fun working

Ahmed Shariff ahmed-shariff

👓
Having fun working
View GitHub Profile
@ahmed-shariff
ahmed-shariff / UnityEditorDrawDefaultExcluding.cs
Created December 12, 2024 22:03
Drawing the default inspector while ignoring some of the properties
public class EstimateConeRayAnglesEditor: UnityEditor.Editor
{
private enum State { Wait, Started, Processing }
private static readonly string[] excludedSerializedNames = new string[]{ "propToIgnore1", "propToIgnore2" };
public override void OnInspectorGUI()
{
// Combining Editor.DrawPropertiesExcluding and Editor.DoDrawDefaultInspector
SerializedProperty iterator = serializedObject.GetIterator();
@ahmed-shariff
ahmed-shariff / SimpleTypeValueDrawer.cs
Last active October 12, 2024 02:48
When I need a dict like field in a script in any of packages ,I use a struct with two fields. This is a simple drawer for that.
using UnityEditor;
using UnityEngine;
namespace ubco.ovilab.ViconUnityStream.Editor
{
[CanEditMultipleObjects]
[CustomPropertyDrawer(typeof(S), true)]
public class SimpleTypeValueDrawer: PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
@ahmed-shariff
ahmed-shariff / HCI-analysis-R-block.R
Last active September 8, 2025 05:46
A simple script I use for analyzing user study data in R
data <- error_data
# outliersValue <- boxplot.stats(data$errors)$out
# data <- data[!data$time %in% outliersValue, ]
data <- summarize(group_by(data, technique, size, ppid), errors=mean(errors), .groups="drop")
mutate(
summarise(
group_by(data, technique, size),
p_value = shapiro.test(errors)$p.value),
normality = ifelse(p_value > 0.05, "Normal", "Not Normal"))
@ahmed-shariff
ahmed-shariff / HotSwapColor.cs
Last active September 4, 2024 20:39
HotSwapColor
// Copied from @GAmuzak
public class ComponentWithSwapColorBehaviour: MonoBehaviour
{
// Based on the render pipeline, this may be different.
// For URP this should be "_BaseColor", with SRP or sprites it should be "_Color"
private static readonly int ShaderProp = Shader.PropertyToID("_BaseColor");
[SerializeField] private Renderer targetRenderer;
private MaterialPropertyBlock materialPropertyBlock;
@ahmed-shariff
ahmed-shariff / symlinkToSamples.ps1
Created April 27, 2024 00:34
ps script to symlink Samples~ folder to Samples to allow editing
# To modify the sampels, create a symlink of the Samples~ directory
New-Item -ItemType SymbolicLink -Path ../Samples -Target ../Samples~
local Players = game:GetService("Players")
local projectileBase = script.Parent.projectile
local prompt = script.Parent.ProximityPrompt
prompt.Triggered:Connect(function (player)
shootProjectile(30, 0.95, 2, 10)
end)
-- example call: shootProjectile(30, 0.95, 2, 10)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
@ahmed-shariff
ahmed-shariff / main.tex
Last active February 22, 2024 06:45
Generate bib file from master file locally, use local bib on overleaf
% Close to the end of main tex file, have this:
% from https://tex.stackexchange.com/questions/596258/automatic-detection-of-overleaf-for-fallback-images/598669#598669
\ifnum\pdfstrcmp{\jobname}{output}=0
\bibliography{bibliography.bib}
\else
% wherever the master bib file is
\bibliography{\string~/Documents/org/bibliography/references.bib}
\fi
@ahmed-shariff
ahmed-shariff / org-agenda-bulk-custom-functions.el
Created May 19, 2022 21:24 — forked from dive/org-agenda-bulk-custom-functions.el
org-mode: org-agenda-bulk-custom-functions
(defun dive/org-mark-as-reviewed ()
"Mark current selected items as REVIEWED."
(org-set-property "REVIEWED" (org-time-stamp '(16) nil)))
(add-to-list 'org-agenda-bulk-custom-functions
'(?R dive/org-mark-as-reviewed))
@ahmed-shariff
ahmed-shariff / DisableTouchConversionToMouse.cs
Created March 14, 2022 14:35 — forked from vbfox/DisableTouchConversionToMouse.cs
Globally disable the conversion of touch events to mouse events in Windows 7
namespace BlackFox
{
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security;
/// <summary>
/// As long as this object exists all mouse events created from a touch event for legacy support will be disabled.
/// </summary>