Skip to content

Instantly share code, notes, and snippets.

@ImaginaryDevelopment
ImaginaryDevelopment / vbox_setup_1.sh
Last active April 25, 2019 16:23
virtual box setup part deux
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
#apt edit-sources
echo preprending sources list
# would be nice if we ensure this doesn't run multiple times
echo -e " deb http://deb.debian.org/debian stretch main\n deb-src http://deb.debian.org/debian stretch main\n\ndeb http://deb.debian.org/debian stretch-updates main\ndeb-src http://deb.debian.org/debian stretch-updates main\n\n$(cat /etc/sources.list)" > /etc/sources.list
if [ ! -f /usr/sbin/VBoxService ]; then
#probably have to hand-type this script
echo "set clipboard to bidirectional and insert guest additions cdrom"
su - -c "apt-get install sudo curl openssh-server & adduser bdimpe sudo"
su - -c systemctl enable ssh
echo "now you can ssh into this box at :"
ip addr show | grep inet
sudo -i curl -Lo vbox_setup_1.sh https://gist.github.com/ImaginaryDevelopment/30959f86125160e4859856ccfdf98ca0/raw/e80fe50f7461ba0b9801372a6e0526da5f40372b/vbox_setup_1.sh
sudo -i chmod +x vbox_setup_1.sh
sudo -i ./vbox_setup_1.sh
@ImaginaryDevelopment
ImaginaryDevelopment / M-R.fs
Last active January 4, 2019 21:26
Functional Simple CQRS attempt
// follow Greg Young's simple CQRS pattern - https://www.youtube.com/watch?v=S2KLFlM_Z4I
[<AbstractClass>]
type Event() = class end
type Event<'t>() =
inherit Event()
type Identifier = Guid
type IRepository<'t,'tEvent when 't :> AggregateRoot<'t,'tEvent>> =
abstract member SaveEvents: Identifier -> Event seq -> int -> unit
abstract member GetById : Identifier -> 't option
@ImaginaryDevelopment
ImaginaryDevelopment / Main.cs
Created November 1, 2018 19:10
sample calculator interfacing
void Main()
{
var operators = new IOperator[]{
new AdditionOperator()
};
var calc = new Calculator(operators);
calc.InputNumber("1");
calc.Operator = operators[0];
calc.ApplyOperator().Dump();
@ImaginaryDevelopment
ImaginaryDevelopment / FixArrowSizes.cs
Created October 16, 2018 16:18
Demonstrate making a Wpf Frame control's Arrows enlarging
using System.Windows;
using System.Windows.Controls;
void Main()
{
var w = new Window();
var grid = new Grid();
// Func<FrameworkElement,UIElement> getTemplateChild = x => {
// var flags = BindingFlags.NonPublic | BindingFlags.Instance
// var tcm = x.GetType().GetMember("get_TemplateChild", flags)[0] as MethodInfo;
@ImaginaryDevelopment
ImaginaryDevelopment / helloDiscord.fsx
Created October 15, 2018 15:07
Discord Bot F# interactive attempt
#if INTERACTIVE
#r @"C:\Users\bdimp\AppData\Local\LINQPad\NuGet.FW46\BrokenDiscord\Hopac.0.3.23\lib\net45\Hopac.Core.dll";;
#r @"C:\Users\bdimp\AppData\Local\LINQPad\NuGet.FW46\BrokenDiscord\Hopac.0.3.23\lib\net45\Hopac.dll";;
#r @"C:\Users\bdimp\AppData\Local\LINQPad\NuGet.FW46\BrokenDiscord\BrokenDiscord.1.0.0\lib\net461\BrokenDiscord.dll";;
#r @"C:\ProgramData\LINQPad\Updates50\beta\LINQPad.exe";;
#r @"C:\Users\bdimp\AppData\Local\LINQPad\NuGet.FW46\BrokenDiscord\FSharp.Control.AsyncSeq.2.0.21\lib\net45\FSharp.Control.AsyncSeq.dll"
open LINQPad
open BrokenDiscord.Client
open BrokenDiscord.Events
open BrokenDiscord.Types
@ImaginaryDevelopment
ImaginaryDevelopment / tasks.json
Created May 3, 2017 13:11
some usable variables inside vscode's tasks
// from https://github.com/orta/vscode-jest/blob/master/.vscode/tasks.json
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls a custom npm script that compiles the extension.
namespace Pm.Schema.DataModels.Appointments // Generated by generateMultiple.linq
open System
open System.ComponentModel
open Pm.Schema
open Pm.Schema.BReusable
// typeName:Appointment writeable:false useOptions:false
/// 29 properties
[<AutoOpen>]
module Pm.Schema.BReusable
open System
open System.Collections.Generic
open System.Diagnostics
//consider pulling in useful functions from https://gist.github.com/ruxo/a9244a6dfe5e73337261
// long pipe chains don't allow breakpoints anywhere inside
// does this need anything to prevent the method from being inlined/optimized away?
@ImaginaryDevelopment
ImaginaryDevelopment / .ionide
Created January 5, 2017 15:46
VsCode Fake build system
[Fake]
linuxPrefix = "mono"
command = "build.cmd"
build = "build.fsx"