Skip to content

Instantly share code, notes, and snippets.

View SamMousa's full-sized avatar
🎯
Focusing

Sam Mousa SamMousa

🎯
Focusing
  • Collecthor
  • Netherlands
  • 12:32 (UTC +01:00)
  • LinkedIn in/sam-mousa
View GitHub Profile
@SamMousa
SamMousa / SafeUnserialize.php
Created August 8, 2023 08:54
Unserialize without worrying about uninitialized properties
<?php
declare(strict_types=1);
trait SafeUnserialize
{
public function __wakeup(): void
{
$rc = new \ReflectionClass(self::class);
/** @var array<string, \ReflectionParameter> $constructorParameters */
@SamMousa
SamMousa / Proxy.lua
Created August 23, 2022 12:37
Lua profiling proxy
local proxy = {
__metatable = false,
__newindex = function ()
error("Can't write to proxy table!")
end,
__index = function(table, key)
@SamMousa
SamMousa / Profile.lua
Created August 21, 2022 18:25
LUA profiling in wow
local prefix = 'profileTest'
local value = math.random()
local function testFunction(a, b)
return a + b
end
local function differences(t, start)
@SamMousa
SamMousa / amd-style-loader.lua
Created July 6, 2021 12:19
AMD Style module loader for LUA
--[[ BEGIN LIBRARY CODE ]]--
local libraries = {}
local queue = {}
local function assertString(param)
if type(param) ~= 'string' then
error(string.format("Expected string got %s", type(param)))
@SamMousa
SamMousa / macro.lua
Created February 1, 2021 11:27
WoW Classic macro for flying to BB after worldbuff in SW
/run flyticker = C_Timer.NewTicker(5, function() for i=1,40 do local n,_,_,_,_,_,_,_,_ = UnitBuff("player", i); if n == "Rallying Cry of the Dragonslayer" then print("Flying"); TakeTaxiNode(9); flyticker:Cancel(); return; end; end; print("W8"); end, 999)
@SamMousa
SamMousa / vm.service
Created September 14, 2020 16:07
Virtualbox on ZFS in SystemD, proper shutdown and process management
# Inspired by https://blogging.dragon.org.uk/start-stop-virtualbox-with-systemd/
[Unit]
Description=Virtual Box Guest %I
After=network.target virtualbox.service zfs-volume-wait.service
Before=runlevel2.target shutdown.target
[Service]
User=root
Group=root
@SamMousa
SamMousa / promiseworker.html
Created August 31, 2020 11:52
Execute work in web workers return result as promise
<!DOCTYPE html>
<html lang="en">
<template id="worker">
<script>
if (typeof self.document === 'undefined') {
self.addEventListener('message', async e => {
let id = e.data.id;
let data = e.data.data;
let result = await handleMessage(data);
self.postMessage({id, result});
@SamMousa
SamMousa / config.json
Created February 26, 2020 09:34 — forked from twalker/config.json
inline-styles using phantomjs
{
"ignoreSslErrors": true,
"localToRemoteUrlAccessEnabled": true,
"webSecurityEnabled": false
}
@SamMousa
SamMousa / config.json
Created February 26, 2020 09:34 — forked from twalker/config.json
inline-styles using phantomjs
{
"ignoreSslErrors": true,
"localToRemoteUrlAccessEnabled": true,
"webSecurityEnabled": false
}
@SamMousa
SamMousa / sample.json
Created November 28, 2019 11:09
sample survey
{
pages: [
{
name: "page1",
elements: [
{
type: "comment",
name: "question1"
},
{