Skip to content

Instantly share code, notes, and snippets.

@hansschmucker
hansschmucker / c#.cmd
Last active August 29, 2015 14:06
Compiles C# code piped to it and runs it immediately without a temporary EXE. Prefix "@" if you want to describe a whole class, not just the content of main.
@PowerShell -command "$src=''+$input; if ( $src -match '^[\s]*@([\s\S]*)$' ){ $src=$matches[1]; }else{ $src='using System; public class App { public static void Main() { '+$src+' } } '; } $opt = New-Object System.CodeDom.Compiler.CompilerParameters; $opt.GenerateInMemory = $true; $cr = [System.CodeDom.Compiler.CodeDomProvider]::CreateProvider('CSharp').CompileAssemblyFromSource($opt, $src); if($cr.CompiledAssembly) {$obj = $cr.CompiledAssembly.CreateInstance('App'); $obj.GetType().GetMethod('Main').Invoke($obj, $null);}else{ $cr.errors; }"
@hansschmucker
hansschmucker / c#.ps1
Created September 4, 2014 08:58
Source for a minimal C# compiler for use in batch files see https://gist.github.com/hansschmucker/820d3bdeca34c665b77a
$opt = New-Object System.CodeDom.Compiler.CompilerParameters;
$opt.GenerateInMemory = $true;
$cr = [System.CodeDom.Compiler.CodeDomProvider]::CreateProvider("CSharp").CompileAssemblyFromSource($opt, "public class App { public static void Main() { "+ $input+" } }");
if($cr.CompiledAssembly){
$obj = $cr.CompiledAssembly.CreateInstance("App");
$obj.GetType().GetMethod("Main").Invoke($obj, $null);
}else{
$cr.errors;
}
@hansschmucker
hansschmucker / resolution.cmd
Created September 7, 2014 11:34
Sets the display resolution from commandline using https://gist.github.com/hansschmucker/820d3bdeca34c665b77a
@ECHO OFF
SETLOCAL
SET RES_X=%1
SET RES_Y=%2
echo @^
using System.Runtime.InteropServices;^
[StructLayout(LayoutKind.Sequential)]^
public struct DispSet {^
[MarshalAs(UnmanagedType.ByValArray,SizeConst=106)]^
byte[] padding0;^
@hansschmucker
hansschmucker / swrplayer.user.js
Created December 11, 2014 10:52
Replace SWR error message at http://mp3-live.swr.de/ with player links.
// ==UserScript==
// @name SWR Radio M3U
// @namespace de.schmucker-partner.swr.m3u
// @include http://mp3-live.swr.de/
// @version 1
// @grant none
// ==/UserScript==
var urls = [
'http://mp3-live.swr.de/swr1bw_m.m3u',
'http://mp3-live.swr.de/swr1rp_m.m3u',
#navigator-toolbox{
background:transparent;
}
#navigator-toolbox > *{
background:#999;
}
#navigator-toolbox {
position: relative;
MSCnWsJcDLqH_SUNGLqGlFRPcloRLRwYiGwENOLqeMaRd6viqHoS0YmoHXW06soHGW0esoRaR1FcJge4KtgpL3VENOL6ynE9oZimhF9oWCaLW0KtI6BfFtJL6Dp0clgGuE0EmeAYRjwie8WR1jTJoyLB9xSiGwENDLaMW0osoVaR1j6K6FkEtNpRKBNXphLBtgpyMRLtiavV0zro9XRwxi2iFNKLabW0MtouBJRwYi2bFNALaOW0_so6BoE0qlgWhF9xhKgmFVANPqAanVU9xeKgWBVANTqAa1UB0uroHaSjUCauSQDXaMTjfKgmLVANJL6R1Urr6i30eroHnSQbiaFW0jHJa3V06roZZR0jeJaxTB0opCoNV1DGqdRNwKi2iF9gc6ym0cleQKB0EomH16q2m1DnpWS1jhpZPNUqBXRPqmGeFNALaFW0cso6BkENaJanTB0qpCoHTV1MroagW1jGqHbTwn6hzUP8qmhF1iseAJRwSiGqENXJa4SLgaVUP8koaIVrtiqVXR06roalWPGmq5MNvpAaqTTla2UB0MrouYPNOqNVR7ziekQFUPclm008pmq1ncJaFTDcatU7rapVjvaGWPgkGp0smCoBQFUNGqgqZTFQDpazVjwaOXA9YdagU71qG1FQr7CoVeB0YvA6Cm0zmGM1oqq1YVPsnCqaSUBVPSmmP1Cte4KVr2qegcB0jdp5MFQwmKgG7FQP_mmA1IpWS1ksecI1GlaVTbdKoqZRFUrlabVt2Ka-VNTr6yUVbsqmdVNDrmuVdyRqlJ1InCqlQtNqg6Bx0snmP1xsexa1DJp2vVRj6ieYMFQrmKgG7FQPclmwF9ofaDUbpaGWPcmm60aomK16sqRcNrL6hf0Cl210AnCqGI1qqmX1irme1it6yh0ukW90soCqdWNkL6yt08p2j1DHpdbV0D3pNQtRrmw1DfpAa0UB0YvA6y_U76ieYcRPmn6Bv1D2pBbV0D8oFINFpNJNOpVKNXpdLFQjYaQTTbKoakTDhaSU