Skip to content

Instantly share code, notes, and snippets.

View OmegaExtern's full-sized avatar

OmegaExtern OmegaExtern

View GitHub Profile
@OmegaExtern
OmegaExtern / Singleton Pattern.cs
Created September 13, 2016 18:34
Singleton Pattern in C#.
#region Singleton Pattern
// NOTE: The class is marked as sealed to prevent the inheritance of the class (i.e. use it as base/super class).
internal sealed class Singleton
{
private static readonly object SingletonSyncRoot = new object();
private static volatile Singleton _instanceSingleton;
// NOTE: Default/Parameterless constructor is private to prevent instantiation of the class.
private Singleton()
@OmegaExtern
OmegaExtern / Anti-Anti-AdBlock for plebleaks.com
Created January 26, 2016 16:29
Tampermonkey userscripts :)
// ==UserScript==
// @name Anti-Anti-AdBlock for plebleaks.com
// @namespace http://plebleaks.com/
// @version 0.1
// @description Anti-Anti-AdBlock for plebleaks.com
// @author OmegaExtern
// @match http://plebleaks.com/*
// @grant none
// ==/UserScript==
@OmegaExtern
OmegaExtern / gmod_cvarlist_log_mainmenu.txt
Created December 3, 2015 22:45
Garry's Mod CVars dump (3rd Dec 2015) - run on development branch (2.12.2015.) - in main menu. All names have been lowercased and sorted (in alphabetical order). Total count is 3113.
// Garry's Mod CVars dump (3rd Dec 2015) - run on development branch (2.12.2015.) - in main menu.
// All names have been lowercased and sorted (in alphabetical order). Total count is 3113.
+alt1
+alt2
+attack
+attack2
+attack3
+back
+break
+camdistance
@OmegaExtern
OmegaExtern / gmod_cvarlist_log_insandboxgamemode.txt
Created December 3, 2015 22:44
Garry's Mod CVars dump (3rd Dec 2015) - run on development branch (2.12.2015.) - in default gamemode "Sandbox". All names have been lowercased and sorted (in alphabetical order). Total count is 3480.
// Garry's Mod CVars dump (3rd Dec 2015) - run on development branch (2.12.2015.) - in default gamemode "Sandbox".
// All names have been lowercased and sorted (in alphabetical order). Total count is 3480.
+alt1
+alt2
+attack
+attack2
+attack3
+back
+break
+camdistance
@OmegaExtern
OmegaExtern / SourceScheme.res
Created October 12, 2015 15:05
"DodgerSky" skin for Source engine games. Originally written for Garry's Mod game.
///////////////////////////////////////////////////////////
// <DodgerSky> skin created by OmegaExtern.
// Quick rewrite of the skin I have lost a few days ago.
// Originally written for Garry's Mod game.
//
// Installation:
// Copy this file into the following folder: [Steam installation directory]\steamapps\common\GarrysMod\garrysmod\resource.
///////////////////////////////////////////////////////////
// Tracker scheme resource file
//
@OmegaExtern
OmegaExtern / simple_spawn_protection.lua
Last active October 2, 2015 16:06
Garry's Mod. Simple, yet safe spawn protection system. Scripted for beginner challenges (https://facepunch.com/showthread.php?t=1487912).
-- This code is for begginers; I have intentionally left out lots of things such as auto-refresh compatibility...
if ( !SERVER ) then
-- This script is mean to be executed/opened on the serverside!
ErrorNoHalt( "Not serverside" ) -- Tell an admin it is not run from environment where it is expected as.
return -- Exit/terminate a script.
end
-- ConVars to manage the spawn protection system:
local sv_spawnprotection = CreateConVar( "sv_spawnprotection", "1", { FCVAR_ARCHIVE, FCVAR_NOTIFY }, "Determines whether simple spawn protection is enabled or disabled" )
local sv_spawnprotection_delay = CreateConVar( "sv_spawnprotection_delay", "8", { FCVAR_ARCHIVE, FCVAR_NOTIFY }, "Determines how long should spawn protection last in seconds after a player has spawned" )
@OmegaExtern
OmegaExtern / protect_skybox_area.lua
Last active September 7, 2021 11:52
Garry's Mod. Stop players from going into skybox area/space on gm_flatgrass & gm_construct.
--[[-------------------------------------------------
Author: OmegaExtern <omegaextern@live.com>
License: MIT <https://opensource.org/licenses/MIT>
-----------------------------------------------------
To install, save this file in the following folder (create a folder if it does not exist, it is case-sensitive):
(Steam installation directory)\steamapps\common\GarrysMod\garrysmod\addons\protect-skybox-area\lua\autorun\server
Supported maps:
gm_construct
gm_flatgrass
-- Revision 4. Added parentheses on if-statements.
-- Since I have experienced a strange bug in singleplayer on the serverside (clean Garry's Mod dev-branch install):
-- lua_run type( player.GetAll()[1]:SteamID64() )
-- Above command should return "nil" or throw an error, as function call is given an argument. But it does NOT.
-- I have decided to fix it. Here is my second attempt at it (also updated script style to: C language without semicolon):
if ( BRANCH:upper() != 'DEV' ) then
-- Just because I can. This can be ignored (doesn't throw error).
print( "Warning: dev branch not detected, this may not work as expected." )
end
if ( !game.SinglePlayer() || game.MaxPlayers() < 2 ) then
-- Run this on server, not client-side!
if not SERVER then
error('Run this on the server-side (lua_openscript)!')
end
-- Find all "func_breakable" entities, and store the result into local "func_breakables" variable.
local func_breakables = ents.FindByClass('func_breakable')
if #func_breakables < 1 then
-- Throws an error if none were founded.
error('No "func_breakable" entities were founded.')
end
-- Solution for: http://facepunch.com/showthread.php?t=1462506&p=47602760&viewfull=1#post47602760
local getinfo, getlocal, gsub = debug.getinfo, debug.getlocal, string.gsub
string.Interp = function(str, tbl)
local funcname = getinfo(1.0, "n").name
assert(funcname == "Interp", "nope.")
for argc = 1.0, getinfo(1.0).nparams, 1.0 do
local argname = getlocal(1.0, argc)
-- Hard-coded with <3 by OmegaExtern.
if argc == 1.0 and argname == "str" then
assert(type(str) == "string" and isstring(str), Format("bad argument #%i (%s) to '%s' (string expected, got %s)", argc, argname, funcname, type(str)))