Skip to content

Instantly share code, notes, and snippets.

View mkropat's full-sized avatar
📚
Learning

Michael Kropat mkropat

📚
Learning
View GitHub Profile
@mkropat
mkropat / appscp.ps1
Last active August 29, 2015 14:07
appscp.ps1 boxstarter script
# Run from Command Prompt:
# START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/mkropat/e93b7bdaa04c2d56879b/raw/9eff96cf4aad061f60de314b9d973d3add278002/appscp.ps1
Set-WindowsExplorerOptions -EnableShowFileExtensions
cinst 7zip.install
cinst GoogleChrome
cinst linqpad4.install
cinst mysql
@mkropat
mkropat / mkgitconfig
Last active November 23, 2023 20:05
Sensible Git defaults
git config --global --replace-all --type=bool push.autoSetupRemote true
git config --global --type=bool rebase.autoStash true
git config --global --type=bool rebase.updateRefs true
git config --global core.autocrlf input
git config --global core.commentChar auto
git config --global init.defaultBranch main
git config --global pull.ff only
git config --global oh-my-zsh.hide-info 1
git config --global alias.ca 'commit --amend --no-edit'
@mkropat
mkropat / ui-router-logging.js
Last active July 31, 2016 19:38
Automatic trace logging of Angular.js events and ui-router state transitions
angular.module('your-module').config(['$provide', function ($provide) {
$provide.decorator('$rootScope', ['$delegate', function ($delegate) {
wrapMethod($delegate, '$broadcast', function (method, args) {
if (isNonSystemEvent(args[0]))
logCall('$broadcast', args);
return method.apply(this, args);
});
wrapMethod($delegate, '$emit', function (method, args) {
@mkropat
mkropat / delayer.js
Last active August 29, 2015 14:11
Sketch of a function to add artificial delays to XHRs
function wrapInDelay(obj, methodName, delay) {
initialize();
wrapMethod(obj, methodName, function (method, args) {
window._delayerWantsDelay = delay;
var result = method.apply(this, args);
delete window._delayerWantsDelay;
return result;
});
<?php
header('Debug-Trace-'.substr(microtime(),0,8).': ' . json_encode(debug_backtrace()));
// Then in your browser just run
//
// console.log(JSON.stringify(<PASTE TRACE HERE>, null, 4))
--pager=less -RS
@mkropat
mkropat / NanoLog.cs
Last active July 5, 2016 13:42
C# logging nano-framework
public static class NanoLog
{
public static void Write(params object[] objs)
{
var logDir = System.Environment.GetEnvironmentVariable("SystemDrive") + @"\NanoLog";
if (!System.IO.Directory.Exists(logDir))
System.IO.Directory.CreateDirectory(logDir);
var logName = typeof(NanoLog).Assembly.GetName().Name + ".debug.log";
var logPath = System.IO.Path.Combine(logDir, logName);
var timestamp = System.DateTime.Now.ToString("HH:mm:ss.fff");
@mkropat
mkropat / RegistryKeyValueStore.cs
Last active December 18, 2023 17:57
Simple Windows Registry interface
public interface IKeyValueStore
{
T Read<T>(string key);
void Write<T>(string key, T value);
}
public class RegistryKeyValueStore : IKeyValueStore
{
readonly RegistryHive _hive;
readonly string _regPath;
@mkropat
mkropat / delete-temp-aspnet.ps1
Created January 14, 2015 22:15
Delete all files in 'Temporary ASP.NET Files' at boot
# delete-temp-aspnet.ps1
#
# Delete all files in 'Temporary ASP.NET Files' at boot
param(
[switch] $Clean,
[switch] $Register
)
if ($Register) {
$setProxy = {
param($proxy)
Set-Location 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings'
Set-ItemProperty . ProxyServer $proxy
Set-ItemProperty . ProxyOverride '<local>'
Set-ItemProperty . ProxyEnable 1
}
# You can run $setProxy as another user like so:
#