Skip to content

Instantly share code, notes, and snippets.

<#
Google Photos stores files by the last modified date
This is unfortunate because the resulting timeline is inaccurate
Wrote this script to correct this by recursing through a directory and setting each file's last modified date to its creation date
Released under MIT License
Copyright (c) 2020 Matthew Dean
#>
$files = Get-ChildItem -recurse -force -Path C:\Users\Matthew\Downloads\ExampleDir | Where-Object {! $_.PSIsContainer}
-- compatible with R6 and R15
local function placeCharacterOnSpawnLocation(character, spawnLocation)
local topCenterOfSpawn = spawnLocation.CFrame + Vector3.new(0, spawnLocation.Size.Y / 2, 0)
local hipHeight = character.Humanoid.RigType == Enum.HumanoidRigType.R15 and character.Humanoid.HipHeight or 2
local distanceFromBottomOfCharacterToMidTorso = hipHeight + character.Torso.Size.Y / 2
character.Torso.CFrame = topCenterOfSpawn + Vector3.new(0, distanceFromBottomOfCharacterToMidTorso, 0)
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character.Head.ChildAdded:connect(function(sound)
if sound:IsA("Sound") then
if sound.SoundId == "rbxasset://sounds/uuhhh.mp3" then
sound.SoundId = "http://www.roblox.com/asset/?id=143531018"
elseif sound.SoundId == "rbxasset://sounds/splat.wav" then
sound.Volume = 0
end
end
@matthewdean
matthewdean / HasMember.lua
Last active August 29, 2015 14:08
A function for determining if an object has a given member. Works even for RobloxLocked objects, except it gives false positives for their children being properties
function HasMember(instance, member)
assert(pcall(game.IsA, instance, ''))
assert(type(member) == "string"))
local success, result = pcall(function() return instance[member] end)
if not success then
return not result:match('not a valid member')
end
print(game:FindService("Workspace"))
--> Workspace

Instance.new("Model", game)
print(game:FindService("Model"))
--> nil

So the method returns nil if there is no service by that name.

-- emulates Instance:GetFullName()
function getFullName(instance)
local names = {}
repeat
table.insert(names, 1, instance.Name)
instance = instance.Parent
until not instance or instance:IsA("ServiceProvider")
return table.concat(names, ".")
end
var memoryStream = (MemoryStream) System.Windows.Clipboard.GetData("application/x-roblox-studio");
var streamReader = new StreamReader(memoryStream);
string xml = streamReader.ReadToEnd();
MessageBox.Show(xml);

I spent many hours today seeing if browsers could copy arbitrary content to the clipboard but with the MIME type application/x-roblox-studio (normally it's just text/plain) but then I found this page:

http://www.w3.org/TR/clipboard-apis/#mandatory-data-types

@matthewdean
matthewdean / dummy.lua
Created March 15, 2014 22:05
A failed experiment to make all Lua code run w/o doing anything, fails because of block consstructs
local obj = {}
local function test() return obj end
setmetatable(obj, {__index=test, __call=test})
_ENV = obj
game:Destroy()
print(Game)
(function() end)()()
while testlol do -- inifnite loop here because testlol is always truthy :/
end
@matthewdean
matthewdean / require.lua
Last active December 25, 2015 00:39
Better than using _G or shared for storing the function because this way the script can start running and will only yield at require calls. TODO: run code in a sandbox so access to Game can be prevented
local function require(url)
local source = Game:GetService('HttpService'):GetAsync(url)
return loadstring(source)()
end
local bindableFunction = Instance.new('BindableFunction')
bindableFunction.Name = 'Require'
bindableFunction.OnInvoke = require
bindableFunction.Parent = Game:GetService('ServerStorage')
@matthewdean
matthewdean / roblox-server-error-hook.lua
Last active December 23, 2015 15:49
Hooks into ROBLOX's Remote Error Monitoring Script to get the results of the ScriptContext.Error event. Can neither obtain a reference to the script nor the stack trace. No longer useful because ScriptContext.Error has been unlocked.
local function onError(errorMessage)
print(errorMessage)
end
local Players = Game:GetService("Players")
local reportedErrors = {}
Players.DescendantAdded:connect(function(instance)
if instance.Name == "AdminStatsFrame" then
instance.Visible = false