Skip to content

Instantly share code, notes, and snippets.

View mrkmg's full-sized avatar

Kevin mrkmg

View GitHub Profile
@mrkmg
mrkmg / TimeSpanExtensions.cs
Last active October 24, 2024 21:24
C# .NET TimeSpan Rounding and Display
using System;
namespace Utils {
public static class TimeSpanExtensions
{
public static TimeSpan Round(this TimeSpan span, TimeSpanRoundingType type, MidpointRounding mode = MidpointRounding.ToEven) =>
type switch
{
TimeSpanRoundingType.QuarterMinute => TimeSpan.FromSeconds(Math.Round(span.TotalSeconds / 15, 0, mode) * 15),
@mrkmg
mrkmg / albert-virtualbox.patch
Last active September 29, 2017 13:07
Albert AUR virtualbox patch
--- albert/no-virtualbox.patch 1969-12-31 19:00:00.000000000 -0500
+++ albert-patched/no-virtualbox.patch 2017-09-29 08:53:13.278139849 -0400
@@ -0,0 +1,10 @@
+--- CMakeLists.txt 2017-09-29 08:52:01.594975848 -0400
++++ CMakeLists.txt.patched 2017-09-29 08:52:32.801569554 -0400
+@@ -22,7 +22,6 @@
+ add_subdirectory(ssh)
+ add_subdirectory(system)
+ add_subdirectory(terminal)
+-add_subdirectory(virtualbox)
@mrkmg
mrkmg / StreamBeans-test1.js
Created June 19, 2017 14:45
Stream Beans Performance Testing
const Benchmark = require('benchmark');
const {PassThrough} = require("stream");
const createStreamBeans = require("streambeans").createStreamBeans;
const suite = new Benchmark.Suite();
const inStreamBeans = new PassThrough();
const outStreamBeans = new PassThrough();
const inStreamNoBeans = new PassThrough();
@mrkmg
mrkmg / borg-completion.zsh
Last active October 9, 2017 07:24
borg backup https://github.com/borgbackup ZSH autocompleter
_borg() {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
{-h,--help}'[Show Help]'\
{-v,--version}'[Show Version]'\
':command:->command'\
'*::options:->options'
// ==UserScript==
// @name New Coffee-Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description shows how to use coffeescript compiler
// @author You
// @require http://coffeescript.org/extras/coffee-script.js
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @match https://speed.cd/browse.php*
// ==/UserScript==
var Promise = require("bluebird");
function doSomething()
{
return Promise
.try(function ()
{
return task1();
})
.then(function (result)
@mrkmg
mrkmg / TurbineMonitor.lua
Created March 10, 2015 12:54
BigReactors - Turbine Monitor
-- TurbineMonitor
-- Made By: MrKMG <mrkmg.com>
--
-- This program will keep your turbines up to speed and turn
-- the coil on and off as needed.
--
-- To Use:
--
-- Attach as many Turbines and Monitors as you would like via
-- wired modems. Monitors will all display the same information
@mrkmg
mrkmg / blade_stolz_assets.php
Last active August 29, 2015 14:10
Adds @asset, @assetjs, @assetcss to blade templates
<?php
// Adds @asset tag to blade templates;
// USAGE: @asset('path/to/file.css|js')
Blade::extend(function($view, \Illuminate\View\Compilers\BladeCompiler $compiler)
{
$pattern = $compiler->createMatcher('asset');
return preg_replace($pattern, '<?php Assets::add$2; ?>', $view);
});
@mrkmg
mrkmg / Part1.js
Last active December 20, 2015 01:49
Creating Life - A study into HTML5 Canvas, Webworkers, and Life Simulation - Code Examples
//** Webworker.js
// Assuming we have an array of arrays, each containing an RGB value.
var colormap = [[255,255,0],[24,50,25],...,[45,64,25],[0,255,0]];
// First create a variable of a transferrable datatype
var bytes= new Uint8Array(pond.total*4);
// Loop through the array and set the colors
for(var i=0;i<colormap.length;i++){
@mrkmg
mrkmg / niceness_lower.php
Last active December 17, 2015 01:59
PHP5 snippit to lower threads niceness and then kill the thread when finished.
<?php
proc_nice(19); //Lowers niceness
set_time_limit(0); //Removes timelimit of script
/****
...
Do some very intensive task you do not want to bog down your server
...
****/