tag:blogger.com,1999:blog-25043534552407141562024-03-12T22:47:40.148-07:00Software crisisJack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.comBlogger23125tag:blogger.com,1999:blog-2504353455240714156.post-69836258838110932312020-08-23T02:13:00.006-07:002024-03-06T02:32:08.800-08:00Dell Inspiron 13 7373. P83G FixMy Dell PC would not start. The fix is a hard reset. Which means removing the PSU. Opening the case. Powering down for 20 seconds by pressing the power on. Removing the battery and replacing it.
<b>Symptom</b>: The battery appears drained. Plugging in PSU, then pressing ON switch the keys backlight for 1 second then it's dead again.
<b>Fix</b>: is to do a '<i>hard reset'</i>.
<p>Get your safety gear, which means earth your body with a wrist attachment. At the very least replace any nylon clothing you're wearing with cotton. If you use reading glasses make sure you have them at hand.
Remove 10 screws at the rear. The single screw in the center is slightly different to the other 9 screws around the edges. The center screw was hidden under a sticker which reads "WARRANTY VOID IF TAMPERED WITH OR REMOVED". There are no screws under the plastic 'feet'.
Use thin piece of card or plasic to slowly lever out the back case. I used an old thin card train ticket did it for me. I began this at the back right (near the power button). A guitar plectrum also works but a credit card is too thick. Work along the back first, then the sides.
Drain the power by holding the power button down for 15 to 20 seconds.
Unscrew the battery. Unscrew 4 screws holding the battery in place, which is labelled "Type F62G0 11.4V"
The fix did not work.
<h4>Dell Inspiron 13 7000 P83G Will Not Wake After Sleep</h4>
<p>I have a model laptop listed about. I have tried the most recent BIOS update, defaulting the BIOS settings, Checking all the power settings, Installing the newest update of Intel Management Interface Engine, Disabling the Intel Management Interface, and disabling Fast Startup in settings. Turned on Wake from USB, and disabled USB Selective Sleep settings. The PC still will not wake up after entering sleep mode and must be forced shutdown and turned back on. </p>
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-76055862599003128132020-07-19T11:32:00.001-07:002020-07-19T11:32:18.114-07:00GIMP keyboard shortcuts<p>In this list you can see most important hotkeys for the GIMP under Linux (most of them
work on Windows as well). All keys can be individually assigned: File / Preferences / Interface / Hotkeys.</p>
<table class="borders-1">
<tbody><tr><th colspan="2">Help</th></tr>
<tr class="line0"><td>Help</td><td>F1</td></tr>
<tr class="line1"><td>Context Help</td><td>Shift+F1</td></tr>
<tr><th colspan="2">Toolbox</th></tr>
<tr class="line0"><td>Rect Select</td><td>R </td></tr>
<tr class="line1"><td>Ellipse Select</td><td>E </td></tr>
<tr class="line0"><td>Free Select</td><td>F </td></tr>
<tr class="line1"><td>Fuzzy Select</td><td>U </td></tr>
<tr class="line0"><td>Select By Color</td><td>Shift+O </td></tr>
<tr class="line1"><td>Scissors</td><td>I </td></tr>
<tr class="line0"><td>Paths</td><td>B </td></tr>
<tr class="line1"><td>Color Picker</td><td>O </td></tr>
<tr class="line0"><td>Move</td><td>M </td></tr>
<tr class="line1"><td>Crop and Resize</td><td>Shift+C </td></tr>
<tr class="line0"><td>Rotate</td><td>Shift+R </td></tr>
<tr class="line1"><td>Scale</td><td>Shift+T </td></tr>
<tr class="line0"><td>Shear</td><td>Shift+S </td></tr>
<tr class="line1"><td>Perspective</td><td>Shift+P </td></tr>
<tr class="line0"><td>Flip</td><td>Shift+F </td></tr>
<tr class="line1"><td>Text</td><td>T </td></tr>
<tr class="line0"><td>Bucket Fill</td><td>Shift+B </td></tr>
<tr class="line1"><td>Blend</td><td>L </td></tr>
<tr class="line0"><td>Pencil</td><td>N </td></tr>
<tr class="line1"><td>Paintbrush</td><td>P </td></tr>
<tr class="line0"><td>Eraser</td><td>Shift+E </td></tr>
<tr class="line1"><td>Airbrush</td><td>A </td></tr>
<tr class="line0"><td>Ink</td><td>K </td></tr>
<tr class="line1"><td>Clone</td><td>C </td></tr>
<tr class="line0"><td>Convolve</td><td>V </td></tr>
<tr class="line1"><td>Smudge</td><td>S </td></tr>
<tr class="line0"><td>Dodge/Burn</td><td>Shift+D </td></tr>
<tr class="line1"><td>Swap Colors</td><td>X </td></tr>
<tr class="line0"><td>Default Colors</td><td>D </td></tr>
<tr><th colspan="2">File</th></tr>
<tr class="line0"><td>New image</td><td>Ctrl+N </td></tr>
<tr class="line1"><td>Open image</td><td>Ctrl+O </td></tr>
<tr class="line0"><td>Open image as new layer</td><td>Ctrl+Alt+O </td></tr>
<tr class="line1"><td>Duplicate image</td><td>Ctrl+D </td></tr>
<tr class="line0"><td>Open recent image 01</td><td>Ctrl+1 </td></tr>
<tr class="line1"><td>Open recent image 02</td><td>Ctrl+2 </td></tr>
<tr class="line0"><td>Open recent image 03</td><td>Ctrl+3 </td></tr>
<tr class="line1"><td>Open recent image 04</td><td>Ctrl+4 </td></tr>
<tr class="line0"><td>Open recent image 05</td><td>Ctrl+5 </td></tr>
<tr class="line1"><td>Open recent image 06</td><td>Ctrl+6 </td></tr>
<tr class="line0"><td>Open recent image 07</td><td>Ctrl+7 </td></tr>
<tr class="line1"><td>Open recent image 08</td><td>Ctrl+8 </td></tr>
<tr class="line0"><td>Open recent image 09</td><td>Ctrl+9 </td></tr>
<tr class="line1"><td>Open recent image 10</td><td>Ctrl+0 </td></tr>
<tr class="line0"><td>Save image</td><td>Ctrl+S </td></tr>
<tr class="line1"><td>Save under a new name</td><td>Shift+Ctrl+S </td></tr>
<tr class="line0"><td>Quit</td><td>Ctrl+Q </td></tr>
<tr><th colspan="2">Dialogs</th></tr>
<tr class="line0"><td>Layers</td><td>Ctrl+L </td></tr>
<tr class="line1"><td>Brushes</td><td>Shift+Ctrl+B </td></tr>
<tr class="line0"><td>Patterns</td><td>Shift+Ctrl+P </td></tr>
<tr class="line1"><td>Gradients</td><td>Ctrl+G </td></tr>
<tr class="line0"><td>Tool-Options</td><td>Shift+Ctrl+T </td></tr>
<tr class="line1"><td>Palettes</td><td>Ctrl+P </td></tr>
<tr class="line0"><td>Info window</td><td>Shift+Ctrl+I </td></tr>
<tr class="line1"><td>Navigation window</td><td>Shift+Ctrl+N </td></tr>
<tr class="line0"><td>Close the window</td><td>Alt+F4</td></tr>
<tr class="line1"><td>Jump to next widget</td><td>Tab</td></tr>
<tr class="line0"><td>Jump to previous widget</td><td>Shift+Tab</td></tr>
<tr class="line1"><td>Set the new value</td><td>Enter</td></tr>
<tr class="line0"><td>Activate current button or list</td><td>Space</td></tr>
<tr class="line1"><td>In a multi-tab dialog, switch tabs</td><td>Ctrl+Alt+PgUp</td></tr>
<tr class="line0"><td>Open Location</td><td>Shift+L </td></tr>
<tr class="line1"><td>Up-Folder</td><td>Alt+ up</td></tr>
<tr class="line0"><td>Down-Folder</td><td>Alt+ down</td></tr>
<tr class="line1"><td>Home-Folder</td><td>Alt+Home</td></tr>
<tr class="line0"><td>Close Dialog</td><td>Esc</td></tr>
<tr><th colspan="2">View</th></tr>
<tr class="line0"><td>Main Menu</td><td>F10</td></tr>
<tr class="line1"><td>Drop-down Menu</td><td>Shift+F10</td></tr>
<tr class="line0"><td>Toggle fullscreen</td><td>F11</td></tr>
<tr class="line1"><td>Toggle quickmask</td><td>Shift+Q </td></tr>
<tr class="line0"><td>Close document window</td><td>Ctrl+W </td></tr>
<tr class="line1"><td>Zoom in</td><td>+ or Ctrl+Mousewheel </td></tr>
<tr class="line0"><td>Zoom out</td><td>- or Ctrl+Mousewheel</td></tr>
<tr class="line1"><td>Zoom 1:1</td><td>1 </td></tr>
<tr class="line0"><td>Shrink wrap</td><td>Ctrl+E </td></tr>
<tr class="line1"><td>Fit image in window</td><td>Shift+Ctrl+E </td></tr>
<tr class="line0"><td>Toggle rulers</td><td>Shift+Ctrl+R </td></tr>
<tr class="line1"><td>Toggle guides</td><td>Shift+Ctrl+T </td></tr>
<tr><th colspan="2">Edit</th></tr>
<tr class="line0"><td>Undo</td><td>Ctrl+Z </td></tr>
<tr class="line1"><td>Redo</td><td>Ctrl+Y </td></tr>
<tr class="line0"><td>Copy selection</td><td>Ctrl+C </td></tr>
<tr class="line1"><td>Cut selection</td><td>Ctrl+X </td></tr>
<tr class="line0"><td>Copy visible</td><td>Ctrl+Shift+C </td></tr>
<tr class="line1"><td>Paste as new image</td><td>Ctrl+Shift+V </td></tr>
<tr class="line0"><td>Paste clipboard</td><td>Ctrl+V </td></tr>
<tr class="line1"><td>Clears selection</td><td>Ctrl+K </td></tr>
<tr class="line0"><td>Named copy selection</td><td>Shift+Ctrl+C </td></tr>
<tr class="line1"><td>Named cut selection</td><td>Shift+Ctrl+X </td></tr>
<tr class="line0"><td>Named paste clipboard</td><td>Shift+Ctrl+V </td></tr>
<tr class="line1"><td>Fill with FG Color</td><td>Ctrl+, </td></tr>
<tr class="line0"><td>Fill with BG Color</td><td>Ctrl+. </td></tr>
<tr class="line1"><td>Fill with Pattern</td><td>Ctrl+: </td></tr>
<tr><th colspan="2">Layers</th></tr>
<tr class="line0"><td>Select the layer above</td><td>PgUp</td></tr>
<tr class="line1"><td>Select the layer below</td><td>PgDn</td></tr>
<tr class="line0"><td>Select the first layer</td><td>Home</td></tr>
<tr class="line1"><td>Select the last layer</td><td>End</td></tr>
<tr class="line0"><td>Merge visible layers</td><td>Ctrl+M </td></tr>
<tr class="line1"><td>Anchar layer</td><td>Ctrl+H </td></tr>
<tr><th colspan="2">Selections</th></tr>
<tr class="line0"><td>Toggle selections</td><td>Ctrl+T </td></tr>
<tr class="line1"><td>Select all</td><td>Ctrl+A </td></tr>
<tr class="line0"><td>Select none</td><td>Shift+Ctrl+A </td></tr>
<tr class="line1"><td>Invert selection</td><td>Ctrl+I </td></tr>
<tr class="line0"><td>Float selection</td><td>Shift+Ctrl+L </td></tr>
<tr class="line1"><td>Path to selection</td><td>Shift+V </td></tr>
<tr><th colspan="2">Plug-ins</th></tr>
<tr class="line0"><td>Repeat last plug-in</td><td>Ctrl+F </td></tr>
<tr class="line1"><td>Reshow last plug-in</td><td>Shift+Ctrl+F </td></tr>
</tbody></table>
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-73019902410577131562020-02-23T09:13:00.001-08:002020-02-23T09:15:24.569-08:00Dell Inspiron - Locked out due to BitLocker<p>I recently made some tiny changes to my Dell Inspiron BIOS. Silly me. Computer would not reboot. It demanded I enter a 48-digit BitLocker key. It was news to me I'd encrypted the drive with BitLocker. It's not something I'd naturally do because I'd expect to turn the laptop into a dual boot Windows/Linux, and I'm not sure Linux can understand BitLocker. Given I don't remember switching BitLocker on, I guess I must've bought it with BitLocker already installed.</p>
<p>It seems changing the BIOS activates the security system. The solution to the issue is:</p>
<ol>
<li>You're looking at a blue screen demanding you enter your BitLocker key:</li>
<li>Click “Skip this drive”</li>
<li>Click “Troubleshoot”</li>
<li>Click “Advanced Options”</li>
<li>Click “UEFI Firmware Settings”</li>
<li>Click “Restart” – You will restart and enter the BIOS for your computer. The BIOS interface is different for every computer. In my case, it looked nothing like in the above video, and doing subsequent steps in the above video did not work. Doing the following DID work:</li>
<li>Click “Restore Settings” button on the bottom of the Dell BIOS screen. Also see here if this setting is not evident.</li>
<li>Click Restore “Factory Defaults”</li>
<li>Save settings and the computer will reboot. In my case, BitLocker prompt screen is now gone and Windows boots normally.</li>
</ol>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-91412136983120989552019-03-12T04:24:00.001-07:002019-03-12T04:35:53.686-07:00[ReactiveUI] Bind enum to Radio button list using a ListBox<p>This is an incomplete blog. The code is broke. It's the code I wrote out to ask a technical question. As often I figured it out when I wrote it all out clearly! I've yet to put the corrected code in here! I found it in an editor tab. Rather than toss it away I'll put the working version here. Because the errors I got when it was broke are nested exceptions, which are themselves cryptic.</p>
<p>When your radio buttons depend on something like a enum or a class.</p>
<p>I have a ListBox of RadioButtons and want the Selected RadioButton to bubble up such that the ListBox SelectedItem is the one clicked. Can't see what I'm doing wrong.</p>
<p>View:</p>
<pre>
<ListBox x:Name="lstRecordTypes">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<RadioButton
Content="{Binding Display}"
ToolTip="{Binding Display}"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsSelected}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="5"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</pre>
<pre>
public MyView()
{
InitializeComponent();
this.WhenActivated(disposables => this.BindControls(disposables));
}
private void BindControls(CompositeDisposable disposableRegistration)
{
this.WhenAnyValue(v => v.ViewModel).BindTo(this, v => v.DataContext).AddTo(disposableRegistration);
this.OneWayBind(ViewModel, vm => vm.RecordTypes, v => v.lstRecordTypes.ItemsSource)
.DisposeWith(disposableRegistration);
this.Bind(ViewModel, vm => vm.SelectedRecordType, v => v.lstRecordTypes.SelectedItem)
.DisposeWith(disposableRegistration);
this.BindCommand(ViewModel, vm => vm.SetRecordIndex,
v => v.lstRecordTypes,
nameof(lstRecordTypes.SelectionChanged));
}
</pre>
<p>ViewModel:</p>
<pre>
private IReactiveList<MyRecordEnumLookup> _recordTypes;
public IReactiveList<MyRecordEnumLookup> RecordTypes
{
get { return _recordTypes; }
set { this.RaiseAndSetIfChanged(ref _recordTypes, value); }
}
private MyRecordEnum _selectedRadioRecordType;
public MyRecordEnum SelectedRadioRecordType
{
get { return _selectedRadioRecordType; }
set { this.RaiseAndSetIfChanged(ref _selectedRadioRecordType, value); }
}
public void LoadRecordTypes()
{
// Convert a list of enums into a ReactiveList
var list = ((IList<MyRecordEnum>)Enum.GetValues(typeof(MyRecordEnum)))
.Where( e => e != MyRecordEnum.Undefined)
.Select(e => new MyRecordEnumLookup(x));
RecordTypes = new ReactiveList<MyRecordEnumLookup>();
RecordTypes.AddRange(list);
}
public Int32 _selectedRecordTypeInt { get; set; } // Valid range = 1..5; 0 = Undefined
public MyRecordEnum SelectedRecordType // Defaults to Undefined
{
get { return (MyRecordEnum)this._selectedRecordTypeInt; }
set { this._selectedRecordTypeInt = (Int32)value; }
}
</pre>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-32430273812978437162019-03-12T03:37:00.003-07:002019-03-12T04:33:04.106-07:00[ReactiveUI] Test command<p>Testing ReactiveUI Commands is almost screaming <a href="http://steveliles.github.io/unit_testing_code_written_in_tell_don_t_ask_style.html">Tell don't Ask</a> at you.</p>
<p>I suppose may want to set a state on completion of the method invoked when executing the Command. e.g. <code>DoExitViewModel()</code>, in the example. But only do this when the view needs to know a result. In this example you would've Disposed() any ViewModel dependencies; so the View can now close itself.</p>
<p>Do not set a property in the ViewModel just so that you test whether production code successfully completed. Use <i>Tell Don't Ask</i> instead.</p>
<p>Commands can rarely send data from the View to ViewModel. When a ViewModel needs to know under what state a Command was invokde, one would normally set a property before invoking a Command. In contrast, when the view needs to know a result, I'll always try to return that result to the view from the method executing in the ViewModel.</p>
<pre>
public partial class MyView : Window, IViewFor<MyViewModel>
{
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(MyViewModel)
, typeof(MyView));
public MyViewModel ViewModel
{
get { return (MyViewModel)this.GetValue(ViewModelProperty); }
set { this.SetValue(ViewModelProperty, value); }
}
object IViewFor.ViewModel
{
get { return this.ViewModel; }
set { this.ViewModel = (MyViewModel)value; }
}
public partial class MyView()
{
InitializeComponent();
this.WhenActivated(disposables => this.BindControls(disposables));
}
private void BindControls(CompositeDisposable disposableRegistration)
{
this.WhenAnyValue(v => v.ViewModel)
.BindTo(this, v => v.DataContext)
.AddTo(disposableRegistration);
this.BindCommand(this.ViewModel, vm => vm.ExitView,
v => v.btnExit)
.AddTo(disposableRegistration);
this.ViewModel.ExitView.Subscribe(success => { if (success) this.Close(); });
this.WhenAnyObservable(v => v.ViewModel.BarcodeScanned)
.Subscribe(authenticationType => this.ShowAuthentication(authenticationType));
}
}
public class MyViewModel
{
public ReactiveCommand<Unit, bool> ExitView { get; private set; } // Output to view
public ReactiveCommand<Unit, CRUDResult> AddTemplate { get; private set; } // Output
public ReactiveCommand<string, AuthenticationTypes?> BarcodeScanned { get; } // Input from view + Output
public ReactiveCommand<Unit, Unit> Boring { get; } // No input/output from/to view
public IObservable<bool> CanAddTemplate { get; private set; }
public MyViewModel()
{
this.CanAddTemplate = (this).WhenAnyValue(vm => vm.PageState, (EditState status) => status == EditState.Browse);
this.AddTemplate = ReactiveCommand.Create(() => this.DoAddTemplate(), this.CanAddTemplate);
this.BarcodeScanned = ReactiveCommand.Create<string, AuthenticationTypes?>(barcode => this.DoBarcodeScanned(barcode));
this.ExitView = ReactiveCommand.CreateFromTask(async () => await Task.Run(() => this.DoExitViewModel()));
}
public bool DoExitViewModel()
{
// Dispose the ViewModel
return true;
}
private CRUDResult DoAddTemplate()
{
// Do whatever you do
this.PageState = EditState.Add;
return new CRUDResult(null);
}
private AuthenticationTypes? DoBarcodeScanned(string barcode)
{
return null;
}
}
public class MyViewModelTests
{
[Test]
public void Add_Button_Test()
{
// Arrange
var vm = new MyViewModel();
vm.Setup(0);
EditState expectedStatus = EditState.Add;
CRUDResult resultPage = new CRUDResult(null);
// Act
vm.AddTemplate.Subscribe(tf => resultPage = tf);
vm.AddTemplate.Execute().Subscribe();
// Assert
Assert.AreEqual(expectedStatus, vm.PageState);
Assert.AreEqual(null, resultPage.Message);
}
}
</pre>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-30901986509319906302019-03-12T03:23:00.002-07:002019-03-12T03:33:13.341-07:00Wpf custom dictionary. Notes<p>Wpf uses #LID to indicate the language or dialect of the dictionary which it will pick up from the current localization.</p>
e.g. <pre>
#LID 2057 = UK location</pre>
<p>Must include </p><ol><li>the System namespace in xaml,</li><li>SpellCheck.IsEnabled="True" in the control,</li><li>location of the dictionary.</li></ol>
<p>Best set build action of the dictionary to embedded resource.</p>
<pre>
<Window ...
xmlns:sys="clr-namespace:System;assembly=System">
<!-- Must include System namespace in xaml -->
<TextBox SpellCheck.IsEnabled="True">
<SpellCheck.CustomDictionaries>
<!-- List of dictionaries to use -->
<!-- hard-coded -->
<sys:Uri>c:\pathToDictionary\uk.lex</sys:Uri>
<!-- OR: Embedded resource -->
<sys:Uri>pack://application:,,,/<b>MyWpfProject</b>;component/<b>uk.lex</b></sys:Uri>
<!-- Must set uk.lex Build Action = Embedded Resource -->
</SpellCheck.CustomDictionaries>
</TextBox>
</pre>
<p><b>MyWpfProject</b> - being the name of the application, in this example.</p>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-45893365097497645022019-02-26T09:19:00.000-08:002019-03-12T04:33:32.020-07:00[ReactiveUI] Bind a list of enums to WPF combo<p>Originally posted by: Mitkins, at: Oct 12 '17 at 0:22, at stackoverflow. I edited it to correct minor typos in the original. And to make one of two alterations.</p>
<style>
pre { color: gray; }
i { color: purple; font-style: normal; }
b { color: blue; font-weight: normal; }
</style>
<p>I am trying to find a simple example where the enums are shown as is. All examples I have seen tries to add nice looking display strings but I don't want that complexity. Note: EffectStyle is just an enum.</p>
<pre><b>public enum</b> <i>EffectStyle</i> { <i>Undefined</i> = 0, <i>Yes</i> = 1, <i>No</i> = 2 }</pre>
<p>Basically I have a class that holds all the properties that I bind, by first setting the DataContext to this class, and then specifying the binding like this in the xaml file:</p>
<pre><ComboBox ItemsSource="{Binding Path=EffectStyle}"/></pre>
<p>But this doesn't show the enum values in the ComboBox as items.</p>
<hr/>
<div id="answer-46699505" class="answer" data-answerid="46699505">
<p>Using <code>ReactiveUI</code>, I've created the following alternate solution. It's not an elegant all-in-one solution, but I think at the very least it's readable. </p>
<p>In my case, binding a list of <code>enum</code> to a control is a rare case, so I don't need to scale the solution across the code base. However, the code can be made more generic by changing <code>EffectStyleLookup.Item</code> into an <code>Object</code>. I tested it with my code, no other modifications are necessary. Which means the one helper class could be applied to any <code>enum</code> list. Though that would reduce its readability - <code>ReactiveList<EnumLookupHelper></code> doesn't have a great ring to it.</p>
<p>Using the following helper class:</p>
<pre><code><b>public</b> <b>class</b> <i>EffectStyleLookup</i>
{
<b>public</b> <i>EffectStyle</i> <i>Item</i> { <b>get</b>; <b>set</b>; }
<b>public</b> <b>string</b> <i>Display</i> { <b>get</b> { <b>return</b> Item.<i>ToString</i>();} }
<b>public</b> <i>EffectStyleLookup</i>(){ }
<b>public</b> <i>EffectStyleLookup</i>(<i>EffectStyle</i> item)
{
<b>this</b>.Item = item;
}
}</code></pre>
<p>Yes. I prefer using constructors. All things considered, you write less code.</p>
<p>In the ViewModel, convert the list of enums and expose it as a property:</p>
<pre><code><b>public</b> <i>MyViewModel</i> : <i>ReactiveObject</i>
{
<b>private</b> <i>ReactiveList</i><<i>EffectStyleLookup</i>> _effectStyles;
<b>public</b> <i>ReactiveList</i><<i>EffectStyleLookup</i>> <i>EffectStyles</i>
{
<b>get</b> { <b>return</b> _effectStyles; }
<b>set</b> { <b>this</b>.<i>RaiseAndSetIfChanged</i>(<b>ref</b> _effectStyles, value); }
}
<span class="com">// See below for more on this</span>
<b>private</b> <i>EffectStyle</i> _selectedEffectStyle;
<b>public</b> <i>EffectStyle</i> <i>SelectedEffectStyle</i>
{
<b>get</b> { <b>return</b> _selectedEffectStyle; }
<b>set</b> { <b>this</b>.<i>RaiseAndSetIfChanged</i>(<b>ref</b> _selectedEffectStyle, value); }
}
<b>public</b> <i>MyViewModel</i>()
{
<b>this</b>.<i>LoadEffectStyleCombo</i>();
}
<b>private void</b> <i>LoadEffectStyleCombo</i>()<span class="pln">
</span>{
<span class="com">// Convert a list of enums into a ReactiveList</span>
<b>var</b> xs = ((<i>IList</i><<i>EffectStyle</i>>)<i>Enum</i>.<i>GetValues</i>(<b>typeof</b>(<i>EffectStyle</i>)))
.<i>Select</i>( x => <b>new</b> <i>EffectStyleLookup</i>(x) );
<i>EffectStyles</i> = <b>new</b> <i>ReactiveList</i><<i>EffectStyleLookup</i>>();
<i>EffectStyles</i>.<i>AddRange</i>(xs);
}
}</code></pre>
<p>In the <code>ComboBox</code>, utilise the <code>SelectedValuePath</code> property, to bind to the original <code>enum</code> value:</p>
<pre><code><<b>ComboBox</b> <i>x:Name</i>="cboEffectStyle" <i>DisplayMemberPath</i>="Display" <i>SelectedValuePath</i>="Item" /></code></pre>
<p>In the View, this allows us to bind the original <code>enum</code> to the <code>SelectedEffectStyle</code> in the ViewModel, but display the <code>ToString()</code> value in the <code>ComboBox</code>:</p>
<pre><code>
<b>public</b> <i>MyView</i>()
{
<i>InitializeComponent</i>();
<b>this</b>.<i>WhenActivated</i>(disposables => <b>this</b>.<i>BindControls</i>(disposables));
}
<b>private</b> <b>void</b> <i>BindControls</i>(<i>CompositeDisposable</i> disposableRegistration)
{
<b>this</b>.<i>OneWayBind</i>(<i>ViewModel</i>, vm => vm.<i>EffectStyles</i>, v => v.<i>cboEffectStyle</i>.<i>ItemsSource</i>).<i>DisposeWith</i>(disposableRegistration);
<b>this</b>.<i>Bind</i>(<i>ViewModel</i>, vm => vm.<i>SelectedEffectStyle</i>, v => v.<i>cboEffectStyle</i>.<i>SelectedValue</i>).<i>DisposeWith</i>(disposableRegistration);
}
</code></pre>
</div>
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-45489602257135189862018-06-28T04:51:00.002-07:002019-03-12T04:33:54.341-07:00[ReactiveUI] Auto Complete Incremental Search?<p>A Winforms UserControl had an incremental search TextBox and a list. A detail view is set from the selected value in the list. This works when I click on a particular list item.</p>
<p>I want to get the last string value from the incremental AutoCompleteSearch TextBox too. To fire a command and also set the user in the Detail view. But:</p>
<pre style="color:red"> Couldn't find a Command Binder for System.Windows.Forms.AutoCompleteStringCollection </pre>
<p>listUsers is the compound UserControl with a property SearchAutoCompleteCustomSource:</p>
<pre>
public AutoCompleteStringCollection SearchAutoCompleteCustomSource
{
get { return tbAutoCompleteSearch.AutoCompleteCustomSource; }
set { tbAutoCompleteSearch.AutoCompleteCustomSource = value; }
}
</pre>
<p>MyView:</p>
<pre>
this.BindCommand(this.ViewModel, vm => vm.UserToFind,
v => v.listUsers.SearchAutoCompleteCustomSource);
</pre>
<p>MyViewModel:</p>
<pre>
private readonly ReactiveCommand<string, bool> userToFind;
public ReactiveCommand<string, bool> UserToFind => this.userToFind;
public MyViewModel()
{
this.userToFind = ReactiveCommand.Create<string, bool>(userName => this.SetUserSelected(userName));
}
private bool SetUserSelected(string userName)
{
User user = userManager.GetUserByName(userName);
bool userFound = (user != null);
if (userFound)
{
SetDetailView(user);
}
return userFound;
}
</pre>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-63120229286348535422017-05-13T10:43:00.001-07:002019-03-07T07:59:13.865-08:00Epub3 conversion notes.<p>(1) I found this list of <i><a style="color:blue;" href="http://sketchytech.blogspot.com/2014/03/epub2-to-epub3-lessons-learnt-in.html">epub2 to epub3 conversion notes</a></i></p>
<p>Notes below are mine, with typical error messages returned by epubcheck validation.</p>
<p>(2) <span style="color:red;">'Exactly one manifest item must declare the 'nav' property (number of 'nav' items: 0).'</span></p>
<p>For Epub 3, this means you need a table of contents in an xhtml file. An ebook often comes with an html "table of contents".</p>
<p>You should convert it to the required format. See the example below.</p>
<p>Your <b>table of contents</b> should look something like this:</p>
<pre><span style="color:green;"> <nav epub:type="toc" id="toc">
<ol id="nav"></span>
<li><a href="chapter01.xhtml#myId">Some entry</a></li>
<li><a href="chapter02.xhtml#myOtherId">Some other entry</a></li>
...<span style="color:green;">
</ol>
</nav></span></pre>
<p>The <nav> tag is a special epub tag, so the html tag, it sits in, needs another namespace to tell it what a <nav> is:</p>
<pre>
<html xmlns="http://www.w3.org/1999/xhtml"
<span style="color:green;">xmlns:epub="http://www.idpf.org/2007/ops"</span>
xml:lang="en"></pre>
<p>Last: The <ol> tags inside your <nav> entry must not be nested (in more <ul>, or <ol> lists. One flat list only. You must use an <ol> list. <ul> not allowed.</p>
<p>So give this ol a style in your stylesheet. To knock out the numbers:</p>
<pre style="color:green;"> ol#nav { list-style-type: none; }</pre>
<p>In an example where "p2.xhtml" has a table of contents, .opf entry changes from: </p>
<pre>
<item id="toc" media-type="application/xhtml+xml"
href="toc.xhtml" /></pre>
<p>to:</p>
<pre>
<item id="toc" media-type="application/xhtml+xml"
href="toc.xhtml" <span style="color:green;">properties="nav"</span>/></pre>
<p>[ PS: if you also have an svg file, add properties="svg" to that in the .opf too! ]</p>
<p>Pesky epub3!</p>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-47924292683601415342017-04-24T09:30:00.000-07:002017-04-24T09:30:13.748-07:00Locating an element to test with FlaUI<p>The WinForms application I'm trying to test is legacy in more ways than I'd like.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil6lxXrJEII4WfE6xh5pW3vJx0zlLa7gef3HgzayWCCdRqSCBeJ6Gj8DKy6NHhcmm-kG8OyT4JPNdjY3ugbha3XsBb6sDN1syDwxuwhjFFX_ioshaU94bN0DRVdFtt3ihI-K_Bi4lnZqE/s1600/FormSplashScreen-2.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil6lxXrJEII4WfE6xh5pW3vJx0zlLa7gef3HgzayWCCdRqSCBeJ6Gj8DKy6NHhcmm-kG8OyT4JPNdjY3ugbha3XsBb6sDN1syDwxuwhjFFX_ioshaU94bN0DRVdFtt3ihI-K_Bi4lnZqE/s1600/FormSplashScreen-2.png" /></a>
<p>Here is FlaUI Inpect looking at a login form I want to test. I need access to 4 items. Each has an AutomationId. The ids are: <b>textUser, textPINCode, buttonHalt, buttonLogin</b></p>
<p>These 4 controls are custom controls derived from Krypton controls. I think the Krypton controls derive from Windows Forms 2.0</p>
<p>Suppose I have a handle on the top level window ("FormSplashScreen"). What is the XPath to get one of the 4 I want (say textUser)?</p>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com3tag:blogger.com,1999:blog-2504353455240714156.post-45465476754813754752017-04-06T05:20:00.002-07:002017-04-06T05:53:53.190-07:00AOP - Aspect Oriented Programming<p><a href="https://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-oriented programming</a> was first described 20 years ago due to work of a team led by legendary programmer <a href="https://en.wikipedia.org/wiki/Gregor_Kiczales">Gregor Kiczales</a> [who also co-authored the book "<a href="https://en.wikipedia.org/wiki/The_Art_of_the_Metaobject_Protocol">The Art of the Metaobject Protocol</a>" ]
<h3>What is it?</h3>
<p>AOP aims to eliminate the noise of cross-cutting concerns, CCC, by putting them all in one place while still allowing the code previously "tangled" up with CCC to work just as before. The business logic is clearer, easier to read and maintain.
<h3>AOP concepts</h3>
<ul>
<li><b>cross-cutting concern</b>, CCC: Is code which applies all over the place and often relates to getting an application to work rather than to any business concern. It <u>cuts across</u> an application. e.g. <i><b>authentication</b>, logging, exception handling, caching data, wrapping a transaction around something, auditing, ...</i></li>
<li><b>join point</b> - a place in code where it can be 'cut', joined to, or intercepted. e.g. <i>just before I call svc.SaveName()</i></li>
<li><b>Pointcut</b> - a set of join points. e.g. <i>just before any SaveName() method in project UI is called</i>.</li>
<li><b>advice</b> - some code to be applied by AOP</li>
<li><b>aspect</b> - a combination of Pointcuts with advice</li>
<li><b>tangling</b> - when CCC(s) are mixed with business or core logic like spaghetti such that the core logic is confusing to read.</li>
<li><b>scattering</b> - having CCCs in multiple methods and classes</li>
<li><b>weaving</b> - how AOP applies aspects to core logic.</li>
</ul>
<h3>Potential applications for ApoG</h3>
<ul>
<li>Authentication and Authorization : by putting this all together in one place the problem of security is not confused with other business logic.</li>
<li>Data caching</li>
<li>Exception handling - hopefully including all unhandled exceptions. ApoG currently has 991 exceptions.</li>
<li>Logging - There are over 2000 of these</li>
<li>Transaction wrap-around e.g. to save a unit of work. ApoG currently does not have <a href="https://en.wikipedia.org/wiki/Database_transaction">unit of work</a> transactions but these will be needed in future.</li>
<li>Auditing? - i.e. The process of saving PDF files and entries to the database can be put in one place.</li>
</ul>
<h3>Advantages</h3>
<ul>
<li>Cleaner code</li>
<li>DRY - It applies <b><a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">Don't repeat yourself</a></b>. It reduces code duplication</li>
<li>SRP - It applies the <b><a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle</a></b>. Ensures a method or class does only one job.</li>
<li><b><a href="https://en.wikipedia.org/wiki/Readability">Readability</a></b> is improved - because one can read the core logic without being distracted by the CCCs</li>
<li><b><a href="https://en.wikipedia.org/wiki/Software_maintenance">Maintenance</a></b> is easier - because code relating to a CCC is in only one place it is easier to update. Because core logic is cleaner and uncluttered by tangential concerns it is easier to change just the core logic without interfering with anything else.</li>
<li><b>Money is no object</b> because every AOP tool but one is free. Dozens of AOP tools have been written.</li>
</ul>
<h3>Disadvantages</h3>
<ul><li>????</li>
</ul>
<h3>Software</h3>
<p><a href="http://nugetmusthaves.com/Tag/aop">Top 20 AOP tools</a>
<p><b><a href="http://www.lightinject.net/interception/">Interception</a></b>, <a href="http://seesharper.github.io/LightInject/">code</a>.
<b>License</b>: MIT OSS
<p><b>NConcern</b>: Is a relative newcomer. <b>License</b>: OSS
<p><b><a href="https://www.postsharp.net/">PostSharp</a></b>: This has been the main .net AOP package since it arrived on the scene.
<b>License</b>: Commercial software. Licenses are up to £449 per developer for a lifetime license. Limited licences are less. Not so expensive. Consider: If AOP improves productivity by 5%, the saving is at least £2500 per year, when one considers the average annual cost of a programmer is certainly over £50k/year.
<b>PostSharp Express</b> is free but limited.
<h3>Training:</h3>
<ul>
<li>Videos: <a href="https://app.pluralsight.com/library/courses/aop/table-of-contents">AOP in .net, by Pluralsight</a>.</li>
<li>Book: <a href="https://www.manning.com/books/aop-in-net">AOP in .net by Matthew D. Groves</a>. This mostly uses PostSharp and Castle DynamicProxy examples.</li>
</ul>
<h3>More articles:</h3>
<p><a href="https://msdn.microsoft.com/en-us/magazine/dn574804.aspx">AOP with the RealProxy Class</a> |
<a href="http://jeffbelback.me/posts/2015/06/01/principles-of-aop/">Principles of AOP, from 2015</a>
<h3><a href="https://github.com/adleatherwood/AopExamples">Examples</a></h3>
<p>Also see book listed above: <a href="https://www.manning.com/books/aop-in-net">AOP in .net</a>. Although it may look like many AOP packages are not well documented, they often use similar implementation patterns. Like dependency injection, once one understands the principle, changing tools is relatively easy.
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-38331869260928540892017-02-13T04:42:00.004-08:002017-02-13T04:42:45.247-08:00Indris links<a href="http://docs.idris-lang.org/en/latest/reference/repl.html">Idris REPL</a>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-76254692154154644162017-02-09T11:44:00.003-08:002017-02-13T05:08:13.987-08:00F-sharp books.
<table id="f-sharp-books">
<colgroup>
<col style="width: 18%; background-color:lemon" />
<col style="width: 10%;" />
<col style="width: 18%; background-color:lemon" />
<col style="width: 18%;" />
<col style="width: 10%; background-color:lemon" />
<col style="width: 10%;" />
<col style="width: 18%; background-color:lemon" />
</colgroup>
<tr><th>Title</th><th>Level</th><th>Authors</th><th>Publisher</th><th>Date</th><th>Pages</th><th>Comment</th></tr>
<tr><td>Learn F# (MEAP)</td><td rowspan="4">Intro</td><td>Isaac Abraham</td><td>Manning</td><td>Apr-2017</td><td>400</td><td></td></tr>
<tr><td>Real-World Functional Programming with examples in F# and C#</td><td>Tomas Petricek with Jon Skeet</td><td>Manning</td><td>Dec-2009</td><td>560</td><td></td></tr>
<tr><td>Beginning F# 4.0</td><td>Robert Pickering, Kit Eason</td><td>Apress</td><td>2016</td><td>309</td><td></td></tr>
<tr><td>Friendly F# (Fun with game programming)</td><td>Costantini, Giulia & Maggiore, Giuseppe</td><td>O'Reilly</td><td>Aug-2011</td><td>191</td><td></td></tr>
<tr><td>F# Succinctly</td><td rowspan="6">Free</td><td>Robert Pickering</td><td>Syncfu-sion</td><td>2012</td><td>96</td><td>Free</td></tr>
<tr><td>Analyzing and Visualizing Data with F#</td><td>Tomas Petricek</td><td>O'Reilly</td><td>Oct-2015</td><td>47</td><td>Free, from publisher</td></tr>
<tr><td>FSharp Specification 4.0</td><td>Fsharp Foundation</td><td>Fsharp Founda-tion</td><td></td><td>365</td><td>Free, Not really a book but can be published as such</td></tr>
<tr><td>F# Web Programming</td><td>Community for F#</td><td>GitBook</td><td></td><td></td><td>Free. Not really a book because it's just a set of hints!</td></tr>
<tr><td>F# Survival Guide</td><td>John Puopolo, Sandy Squires</td><td>CTO Corner</td><td>2012</td><td>171</td><td>Free.</td></tr>
<tr><td>Suave Music Store example</td><td></td><td></td><td></td><td>77</td><td></td></tr>
<tr><td>The Book of F#</td><td rowspan="5">Interm-ediate</td><td>Dave Fancher</td><td>No Starch Press</td><td>Mar-2014</td><td>312</td><td></td></tr>
<tr><td>Professional F# 2.0</td><td>Ted Neward Aaron, C. Erickson, Talbott Crowell, Richard Minerich</td><td>Wrox</td><td>2011</td><td>434</td><td></td></tr>
<tr><td>Programming F-sharp 3.0, 2e</td><td>Chris Smith</td><td>O'Reilly</td><td>Oct-2012</td><td>476</td><td></td></tr>
<tr><td>Testing with F#</td><td>Mikael Lundin</td><td>Packt</td><td>Feb-2015</td><td>286</td><td></td></tr>
<tr><td>F# for Developers</td><td>Tao Liu</td><td>Micro-soft</td><td>2013</td><td>619</td><td></td></tr>
<tr><td>Windows Phone 7.5 Application Development with F#</td><td rowspan="3">Web / mobile</td><td>Lohith G.N.</td><td>Packt</td><td>Apr-2013</td><td>138</td><td></td></tr>
<tr><td>Building Web, Cloud, and Mobile Solutions with F#</td><td>Daniel Mohl</td><td>O'Reilly</td><td>Nov-2012</td><td>176</td><td></td></tr>
<tr><td>F# Applied, A practical guide to Web dev in F# using Suave</td><td>Tamizhvendan S</td><td></td><td>2016</td><td>96</td><td><a href="http://products.tamizhvendan.in/fsharp-applied/">link</a></td></tr>
<tr><td>Expert F# 4.0</td><td rowspan="7">Expert</td><td>Don Syme, Adam Granicz & Antonio Cisternino</td><td>Apress</td><td>2015</td><td>582</td><td>4 editions of this book</td></tr>
<tr><td>F# High Performance</td><td>Eriawan Kusumawardhono</td><td>Packt</td><td>Jan-2017</td><td>338</td><td></td></tr>
<tr><td>Mastering F#</td><td>Alfonso García-Caro Núñez, Suhaib Fahad</td><td>Packt</td><td>Nov-2016</td><td>264</td><td></td></tr>
<tr><td>F# 4.0 Design Patterns</td><td>Gene Belitski</td><td>Packt</td><td>Nov-2016</td><td>318</td><td></td></tr>
<tr><td>F# for Quantitative Finance</td><td>Johan Astborg</td><td>Packt</td><td>Dec-2013</td><td>286</td><td></td></tr>
<tr><td>F# 4.0 Programming Cookbook</td><td>Kevin Ashton</td><td>Packt</td><td>Aug-2017</td><td>371</td><td></td></tr>
<tr><td>F# Deep Dives</td><td>Edited by Tomas Petricek, Phillip Trelford</td><td>Manning</td><td>Dec-2014</td><td>372</td><td></td></tr>
<tr><td>F# for Machine Learning Essentials</td><td rowspan="2">Machine Learning</td><td>Sudipta Mukherjee</td><td>Packt</td><td>Feb-2016</td><td>194</td><td></td></tr>
<tr><td>Machine Learning Projects for .NET Developers</td><td>Mathias Brandewinder</td><td>Apress</td><td>2015</td><td>300</td><td></td></tr>
<tr><td>Learning F# Functional Data Structures and Algorithms</td><td rowspan="5">Compu-ter sciency</td><td>Adnan Masood</td><td>Packt</td><td>Jun-2015</td><td>206</td><td></td></tr>
<tr><td>Fsharp for Scientists</td><td>Jon D Harrop</td><td>Wiley</td><td>2008</td><td>334</td><td></td></tr>
<tr><td>F# for Technical Computing</td><td>Jon D Harrop</td><td>Flying frog</td><td>2010</td><td>279</td><td></td></tr>
<tr><td>Programming Language Concepts</td><td>Peter Sestoft</td><td>Springer</td><td>2012</td><td>278</td><td></td></tr>
<tr><td>Functional Programming Using F#</td><td>Michael R. Hansen, Hans Rischel </td><td>CUP</td><td>May-2013</td><td>372</td><td></td></tr>
</table>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-34486289650092913472017-02-09T11:21:00.001-08:002017-02-09T13:13:19.569-08:00Of interest. Maybe watch/read<ul><li>Beginners<ul>
<li><a href="http://www.pirrmann.net/some-advice-to-f-beginners/">Some advice to F# beginners</a></li>
<li><a href="http://biarity.me/2016/11/30/An-unassuming-F-study-plan/">An unassuming F# study plan – Biarity</a></li>
<li><a href="https://swlaschin.gitbooks.io/fsadvent-2016/content/frontmatter/Topics.html">F# Advent Calendar 2016 eBook</a></li>
<li><a href="https://www.gitbook.com/book/swlaschin/fsadvent-2016/details">F# Advent Calendar 2016 Pdf</a></li>
</ul></li>
<li>Books<ul>
<li><a href="https://www.manning.com/books/functional-concurrency-in-dotnet">New MEAP! Functional Concurrency in .NET by Riccardo Terrell (due Fall 2017)</a></li>
<li><a href="https://www.packtpub.com/application-development/f-40-design-patterns">New book: F# 4.0 Design Patterns by Gene Belitski</a></li>
<li><a href="https://www.packtpub.com/application-development/mastering-f">New book: Mastering F# by Alfonso García-Caro Núñez, Suhaib Fahad</a></li>
<li><a href="http://mattwarren.org/2016/12/12/Research-papers-in-the-.NET-source/">Research papers in the .NET source</a></li>
<li><a href="http://www.javatpoint.com/fsharp-interview-questions">F# Interview Questions</a></li>
</ul></li>
<li>Techniques<ul>
<li><a href="https://jbrestan.github.io/FSharpingROP/#/Railway">Oriented Programming(Functional approach to error handling) – Honza Brestan</a></li>
<li><a href="http://blog.ploeh.dk/2017/02/02/dependency-rejection/">Dependency rejection by Mark Seemann</a></li>
<li><a href="http://blog.ploeh.dk/2017/01/03/decoupling-application-errors-from-domain-models/">Decoupling application errors from domain models by Mark Seemann</a></li>
<li><a href="http://www.jason-down.com/2017/01/10/f-pattern-matching-part-1/">F# Pattern Matching – Part 1 – Introduction</a></li>
<li><a href="https://gist.github.com/isaksky/f8c4881bf93c7e57115439af07722ecc">Working with SQL syntax trees in F# – Isak Sky</a></li>
<li><a href="https://www.infoq.com/news/2016/12/fsharp-scripting-fake-paket">Scripting in F# Using Fake and Paket</a></li>
<li><a href="http://mattwarren.org/2016/12/14/Why-is-Reflection-slow/">Why is reflection slow?</a></li>
<li><a href="https://github.com/forki/paketintro">paketintro – Intro to Paket</a></li>
<li><a href="https://github.com/Microsoft/fsharplu">F# helpers for ... lots of stuff</a></li>
</ul></li>
<li>Testing<ul>
<li><a href="http://www.prigrammer.com/?p=398">F# Unit Testing Simplified – Expecto with Visual Studio Code</a></li>
<li><a href="https://jeremybytes.blogspot.co.uk/2016/11/mixed-feelings-about-fsunit.html">Mixed Feelings About FsUnit – Jeremy Bytes</a></li>
<li><a href="https://jeremybytes.blogspot.co.uk/2016/11/simple-mocking-in-fsunit-i-like-this.html">Simple Mocking in FsUnit (I Like This) – Jeremy Bytes</a></li>
<li><a href="https://www.infoq.com/presentations/mock-fsharp-tdd">Look, No Mocks! Functional TDD with F#</a></li>
</ul></li>
<li>Type Providers<ul>
<li><a href="https://www.youtube.com/watch?v=RK3IGYNZDPA">F# Type Providers by Chris Gardner</a></li>
<li><a href="https://medium.com/@nevoroman/the-magic-of-type-providers-7f6825acd54">The magic of type providers – Roman Nevolin</a></li>
</ul></li>
<li>Xamarin / XAML<ul>
<li><a href="https://visualstudiomagazine.com/articles/2017/01/01/build-xamarin-apps.aspx">You, Too, Can Build Xamarin Apps with F#</a></li>
<li><a href="https://github.com/nosami/fsharpforms">fsharpforms – Xamarin Studio Forms template</a></li>
<li><a href="http://www.trelford.com/blog/post/XamarinForms.aspx">X-Platform Development With Xamarin.Forms And F# – Phillip Trelford</a></li>
<li><a href="https://blog.xamarin.com/bringing-platform-specific-functionality-to-xamarin-forms-apps/">Prebuilt platform specific in Xamarin Forms takes advantage of native Libraries functionality unique to each platform</a></li>
<li><a href="https://www.nuget.org/packages/FsXaml.Wpf/">FsXaml for WPF 3.1.2</a></li>
</ul></li>
<li>Suave<ul>
<li><a href="http://www.codechannels.com/video/microsoft/dotnet/asp-net-monsters-85-suave-web-services/">ASP.NET Monsters #85: Suave Web Services</a></li>
<li><a href="https://github.com/SuaveIO/suave/releases/tag/v2.0.0">Suave: v2.0.0 – Easy living</a></li>
<li><a href="https://github.com/fable-compiler/fable-suave-scaffold">Working sample of a Suave + Fable + Elmish project with hot reloading</a></li>
</ul></li>
<li>Application examples<ul>
<li><a href="https://blogs.msdn.microsoft.com/dotnet/2016/12/13/project-springfield-a-cloud-service-built-entirely-in-f/">Project Springfield: a Cloud Service Built Entirely in F#</a></li>
<li><a href="http://kunjan.in/2016/12/epic-adventure-using-fsharp/">Epic Adventure using F#</a></li>
<li><a href="http://evelinag.com/eliza/#/">Build your own chatbot therapist in F# – Evelina Gabasova</a></li>
<li><a href="http://markheath.net/post/asterisk-fsharp">Asterisk Game in F# and WPF</a></li>
<li><a href="http://dougbruce.blogspot.co.uk/2016/12/build-yourself-robo-advisor-in-f-part-i.html">Build Yourself a Robo-Advisor in F#. Part I : Domain Modelling – Doug Bruce</a></li>
</ul></li>
<li>Lux - a strongly typed (Hindley-Milner) Lisp for JVM<ul>
<li><a href="http://luxlang.blogspot.co.uk/">Blog</a></li>
<li><a href="https://www.youtube.com/channel/UCtnwGRJTT4UFqcclbE8BrEQ">YouTube</a></li>
<li><a href="https://github.com/LuxLang">Github</a></li>
<li><a href="https://www.gitbook.com/book/luxlang/the-lux-programming-language/details">GitBook</a></li>
</ul></li>
<li>Design<ul>
<li><a href="https://www.infoq.com/presentations/refactoring-functional">Refactoring to Functional</a></li>
<li><a href="https://www.infoq.com/presentations/solid-oop-fp">SOLID: The Next Step Is Functional</a></li>
<li><a href="https://www.infoq.com/presentations/fp-design-patterns">Functional Programming Design Patterns</a></li>
<li><a href="https://www.infoq.com/news/2014/05/functional-patterns-ddd">Functional Patterns in Domain-Driven Design</a></li>
<li><a href="https://www.infoq.com/news/2014/03/ddd-functional-language">Domain-Driven Design Using a Functional Language</a></li>
<li><a href="https://www.infoq.com/presentations/Type-Functional-Design">A Type Driven Approach to Functional Design</a></li>
<li><a href="https://www.infoq.com/news/2014/03/ddd-cqrs-fsharp">DDD and CQRS Using the Functional Language F#</a></li>
<li><a href="https://www.infoq.com/presentations/functional-domain-models">Developing Functional Domain Models with Event Sourcing</a></li>
<li><a href="https://www.infoq.com/news/2016/09/fsharp-dotnet-fringe">Don Syme Presents F# Design Principles at .Net Fringe</a></li>
<li><a href="http://www.oreilly.com/pub/e/3340">Domain Modelling with the F# Type System, by: Scott Wlaschin</a></li>
</ul></li>
<li>InfoQ<ul>
<li><a href="https://www.infoq.com/interviews/weirich-haskell-dependent-types">Stephanie Weirich on Dependent Typing, Extending Haskell, Type System Research</a></li>
<li><a href="https://www.infoq.com/presentations/molog">Molog: Typed Functional Logic Programming in Haskell</a></li>
<li><a href="https://www.infoq.com/news/2014/07/rest-haskell">rest: Open Source REST Framework For Haskell</a></li>
<li><a href="https://www.infoq.com/presentations/scala-idris">Scala vs Idris: Dependent Types, Now and in the Future</a></li>
<li><a href="https://www.infoq.com/interviews/sabin-types">Miles Sabin on Dependent Types with Scala, Shapeless, Scala Macros</a></li>
<li><a href="https://www.infoq.com/articles/no-more-mvc-frameworks">Why I No Longer Use MVC Frameworks</a></li>
<li><a href="https://www.infoq.com/articles/apple-swift">Swift Programming Language</a></li>
<li><a href="https://www.infoq.com/presentations/elm-functional-reactive-programming">Elm: Finding the Functional in Reactive Programming</a></li>
<li><a href="https://www.infoq.com/presentations/reactive-sytems-pharmaceutical-industry">Reactive Systems: From Drug Development to Functional Programming</a></li>
<li><a href="https://www.infoq.com/articles/sam-lessons-learned-front-end-reactive-architectures">">The SAM Pattern: Lessons Learned Building Functional Reactive Front-End Architectures</a></li>
<li><a href="https://www.infoq.com/presentations/reactive-services-fp">Building Reactive Services using Functional Programming</a></li>
<li><a href="https://www.infoq.com/interviews/byrd-relational-programming-minikanren">William Byrd on Logic and Relational Programming, miniKanren</a></li>
<li></li>
<li><a href="https://www.infoq.com/news/2017/01/fsharp-4-1">F# 4.1 Brings Improvements and Interoperation with C# 7</a></li>
<li><a href="https://www.infoq.com/news/2016/05/fsharp-azure-storage">Exploring Azure with F# Azure Storage Type Provider</a></li>
<li><a href="https://www.infoq.com/interviews/brandewinder-fsharp-data-science">Mathias Brandewinder on F# for Data Science</a></li>
<li><a href="https://www.infoq.com/news/2015/04/FSharp-4">Introducing F# 4.0</a></li>
<li><a href="https://www.infoq.com/news/2014/07/fsharp-native-moible-development">F# Native App Development on iOS and Android</a></li>
<li><a href="https://www.infoq.com/articles/WebSharper">F# mobile development with WebSharper</a></li>
<li><a href="https://www.infoq.com/articles/fsharp-community-survey-2016">F# in Numbers: A Look at the Annual F# Survey Results</a></li>
<li><a href="https://www.infoq.com/news/2016/12/fsharp-scripting-fake-paket">Scripting in F# Using Fake and Paket</a></li>
<li><a href="https://www.infoq.com/presentations/F-sharp-patterns">Unfrying Your Brain with F#</a></li>
<li><a href="https://www.infoq.com/news/2015/09/ionide-fsharp-ide">Ionide is a New Atom-based F# IDE Written in F#</a></li>
<li><a href="https://www.infoq.com/news/2012/03/LINQ-FSharp">LINQ for F#</a></li>
</ul></li>
</ul>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-70887851040215995922016-10-28T05:32:00.001-07:002016-10-28T06:22:18.403-07:00VS code, asp.net core. Microsoft on all 3 platforms.<style type="text/css">
code { color: blue; }
tt { color: green; }
.cmdline { padding: 0.2em; background-color: black; color: white; font-family: monospace; white-space: pre; }
.cmd { padding: 0.1em 0.2em 0.1em 0.2em; background-color: black; color: yellow; }
.cmd2 { padding: 0.2em 0.3em 0.2em 0.3em; background-color: black; color: yellow; }
</style>
<p>Microsoft are writing tools to develop and publish their applications on all 3 platforms. asp.net core is a slimmed down open source asp.net with web forms mercifully removed. Visual Studio code is a lightweight (by Microsoft standards), programming editor. It's cross platform (iOS, Linux, Win) and not too fat. The setup file I downloaded was 32Mb, taking 133.6Mb of disk space. It installed seriously fast (compared with other dev software from Microsoft).</p>
<p>I suppose this is a virtue of giving geeks more control over the development side. They will actually write tools for authoring software on any and every platform. There is presumably a Chrome version in the works too? Any application written should be portable across platforms with ease. It's a completely different philosophy from what we've been used to.</p>
<p>This blog is just a log of Shawn Wildermuth's long (> 9 hours) Pluralsight course "<a href="http://pluralsight.com/">Building a Web App with ASP.NET Core, MVC 6, EF Core, and Angular</a>", as I acquaint myself with the latest version. So much of it is command line driven, I feel I should write it down to remind myself what to do next time.</p>
<p>Entering <span class="cmd2">code .</span> from the command line executes VScode at lightning speed. e.g.</p>
<div class="cmdline">F:\code\CSharp\HelloWorld><span class="cmd">code . </span>
</div>
<p>It loads with the project in that folder "HelloWorld", but without intellisense or coloration because each individual language must have support added separately. To add C# support, <code>Ctrl+Shift+X</code> shows a list of extensions, from which I selected C#. <tt>Add</tt>ed it, <tt>enable</tt>d it, the code editor restarts in less than a second.
VSCode does not create projects like full Visual Studio.
We need to use nodejs and npm for that. My copies of these two were quite old.</p>
<div class="cmdline">F:\code\CSharp\HelloWorld><span class="cmd">node --version</span>
v4.4.3
F:\code\CSharp\HelloWorld><span class="cmd">npm --version</span>
2.15.1
</div>
<p>So I installed a new nodejs from nodejs.org, which seemed to take forever! Snooze. Waking up several minutes later I do:</p>
<div class="cmdline">F:\code\CSharp\HelloWorld><span class="cmd">node --version</span>
v6.9.1
F:\code\CSharp\HelloWorld><span class="cmd">npm --version</span>
3.10.8
</div>
<p>Now, I'm happier creating a new project from the command line using yoeman, after first installing yoeman (with the global option), the asp.net generator is also installed</p>
<div class="cmdline">F:\code\CSharp\HelloWorld><span class="cmd">npm install yo -g</span>
F:\code\CSharp\HelloWorld><span class="cmd">npm install generator-aspnet -g</span>
</div>
<p>Now I will generate an asp.net application. First moving up a level out of my current project.</p>
<div class="cmdline">F:\code\CSharp\HelloWorld><span class="cmd">cd..</span>
F:\code\CSharp><span class="cmd">yo aspnet</span>
</div>
<p>We see a command line menu system:</p>
<div class="cmdline">? What type of application do you want to create? (Use arrow keys)
> Empty Web Application
Empty Web Application (F#)
Console Application
Console Application (F#)
<span class="cmd"> Web Application </span>
Web Application Basic [without Membership and Authorization]
Web Application Basic [without Membership and Authorization] (F#)
(Move up and down to reveal more choices)
</div>
<p>Pick "Web Application". If the command arrows are not working just enter the number for that choice ( 5 )
Select the Bootstrap option and call it FunWithYo</p>
<p>navigate to it.
<div class="cmdline">F:\code\CSharp><span class="cmd">cd FunWithYo </span>
F:\code\CSharp\FunWithYo><span class="cmd">dir </span>
</div>
<p>Attempting to run it at this stage shows it's still missing asp.net. So we must restore it, before running it.</p>
<div class="cmdline">F:\code\CSharp\FunWithYo><span class="cmd">dotnet restore </span>
F:\code\CSharp\FunWithYo><span class="cmd">dotnet run </span>
</div>
<p>The whole can be seen in a browser on port 5000
<code>localhost:5000</code></p>
<p>My frist asp.net core MVC application up.
<code>Ctrl+c</code> (from the command line, where it is running) stops it.</p>
<p>Once the new project is complete, <span class="cmd2">code .</span>, opens VS code with the current project loaded. We need to answer <tt>Yes</tt> to the question <br /><tt>Required assets to build and debug are missing from your project.</tt> <code>Add</code> them?</p>
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-51837860816819374972016-03-16T17:28:00.000-07:002016-03-16T18:24:17.360-07:00Programming Languages and programming<p>There are probably five main styles of programming, which may overlap, and often relate to particular languages. We have imperative, declarative, object oriented, functional and logic programming styles. These are more commonly called <a href="https://en.wikipedia.org/wiki/Programming_paradigm">programming paradigms</a> than styles. The list below has each style with an iconic sibling language to implement it.</p>
<ul>
<li>imperative - C, or BASIC</li>
<li>declarative - SQL</li>
<li>object oriented - Smalltalk</li>
<li>functional - Haskell</li>
<li>logic - Prolog</li>
</ul>
<p><a href="https://en.wikipedia.org/wiki/Imperative_programming">Imperative programming</a> begins with the 3 rules of coding: sequence (code executes left to right, top to bottom), selection (if, case) and iteration (loops), and may develop to <a href="https://en.wikipedia.org/wiki/Structured_programming">structured programming</a>. There's something very low level and intuitive about imperative programming but the best programming is rarely done in this style. With imperative programming, our code explains how a problem is solved - the solution can often be understood by tracing through the steps in the code. Imperative code often has a closer relationship to machine code than other styles.</p>
<p>With <a href="https://en.wikipedia.org/wiki/Declarative_programming">declarative programming</a>, one declares a statement or code block to solve a problem. Declarative features are generally higher level. We see declarative features in SQL, many functional and logic programming languages.</p>
<p><a href="https://en.wikipedia.org/wiki/Object-oriented_programming">Object oriented (OO) programming</a> began in the late 1960s, cumulating in Smalltalk (<a href="https://en.wikipedia.org/wiki/Alan_Kay">Alan Kay</a>: 1970 to 1980) and <a href="https://en.wikipedia.org/wiki/Software_design_pattern">design patterns</a> (1990s through to the noughties). 1980s onward saw several post-Smalltalk languages implementing OO features: C++, Java, C#, Javascript. These four now dominate the world of code. Yet your OO-purest is a Smalltalk coder at heart!</p>
<p><a href="https://en.wikipedia.org/wiki/Functional_programming">Functional programming</a> (FP) began in academia. Elements of <a href="https://en.wikipedia.org/wiki/Lisp_(programming_language)">LISP</a> (Designed by John McCarthy, 1958) are functional, <a href="https://en.wikipedia.org/wiki/Robin_Milner">Robin Milner</a> created ML in 1975. 1980s saw a commercial FP language: <a href="https://en.wikipedia.org/wiki/Miranda_(programming_language)">Miranda</a> (David Turner). Haskell began in 1987, mostly as a copy of Miranda, ever refining itself, yet staying lean and clean. Modern functional programming stresses, functions as "first class" elements of the language, declarative programming, prefers immutable data. Other commercial FP languages are: OCaml, F#, Scala, Clojure, ...</p>
<p><a href="https://en.wikipedia.org/wiki/Logic_programming">Logic programming</a> languages began in earnest in the early 1970s with Prolog. Coding styles are very declarative and applications often have an AI basis, data analysis or both.</p>
<p>All these styles mix, to some extent, in actual languages in use. Yet a language is classified with the style which is most important to it. For example we call <a href="https://en.wikipedia.org/wiki/Scala_(programming_language)">Scala</a> a functional programing language, even though it is very OO too. Javascript has always had functional features but does not have immutable data. There's even a style called <i>functional Javascript</i>. Yet Javascript will always be an OO language first.</p>
<p>I began this in response to a question : <i>what programming language should one learn <u>first</u>?</i> It's not really a sensible question. You should learn each of the programming language styles, and sub-styles. [e.g. sub-styles: <i>structured programming</i> as a sub-style of imperative programming, <i>design patterns</i> as a sub-style of object-oriented programming, They are not really <i>sub-</i>, but more like meta-, or <i>supra-styles</i>]. We can also recognize certain idioms that span all styles: <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a>, <a href="https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a>, ... A lot of <a href="https://en.wikipedia.org/wiki/Best_coding_practices">good coding practices</a> seem orthogonal to implementing specific use cases. You could begin with imperative programming (first six books in list below), and apply the wisdom in the books to your code. Object-oriented languages dominate business, so read books 7 to 12, but only 12 is specific only to OO (in a sense). Finally, you need at least some functional programming and the last two are good starters.</p>
<h3>Beginner programmer reading list.</h3>
<p>TBH, A beginner can begin with any programming, or programming language book. Yet you won't really have graduated from beginner until you've read most of the 14 books below. Read and apply the lessons of all 14 and you're past beginner/junior programmer level.</p>
<ol>
<li><a href="http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670/">Code Complete: A Practical Handbook of Software Construction, 2nd Edition</a>, by Steve McConnell</li>
<li><a href="http://www.amazon.com/gp/product/0596802293">The Art of Readable Code</a>, by Dustin Boswell and Trevor Foucher</li>
<li><a href="http://www.amazon.com/Programming-Pearls-2nd-Edition-Bentley/dp/0201657880/">Programming Pearls (2nd Edition)</a>, by by Jon Bentley</li>
<li><a href="http://www.amazon.com/Things-Every-Programmer-Should-Know/dp/0596809484">97 Things Every Programmer Should Know</a>, by by Kevlin Henney</li>
<li><a href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882/">Clean Code: A Handbook of Agile Software Craftsmanship</a>, by Robert C. Martin</li>
<li><a href="http://www.amazon.com/Test-Driven-Development-By-Example/dp/0321146530/">Test Driven Development: By Example</a>, by Kent Beck</li>
<li><a href="http://www.amazon.com/Agile-Principles-Patterns-Practices-C/dp/0131857258/">Agile Principles, Patterns, and Practices in C#</a>, by Robert C. Martin and Micah Martin</li>
<li><a href="http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672/">Refactoring: Improving the Design of Existing Code</a>, by by Martin Fowler</li>
<li><a href="http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052/">Working Effectively with Legacy Code</a>, by by Michael Feathers</li>
<li><a href="http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627/">Growing Object-Oriented Software, Guided by Tests</a>, by Steve Freeman and Nat Pryce</li>
<li><a href="http://www.amazon.com/Agile-Java-Crafting-Test-Driven-Development/dp/0131482394/">Agile Java: Crafting Code with Test-Driven Development</a>, by Jeff Langr</li>
<li><a href="http://www.amazon.com/Object-Design-Roles-Responsibilities-Collaborations/dp/0201379430/">Object Design: Roles, Responsibilities, and Collaborations</a>, by Rebecca Wirfs-Brock and Alan McKean</li>
<li><a href="http://www.amazon.com/Programming-Haskell-Graham-Hutton/dp/0521692695">Programming in Haskell</a>, by Graham Hutton</li>
<li><a href="http://www.amazon.com/Joy-Clojure-Michael-Fogus/dp/1617291412/">The Joy of Clojure, 2nd Edition</a>, by Michael Fogus and Chris Houser</li>
</ol>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-61690530871351062922015-11-24T06:17:00.001-08:002015-11-24T06:17:39.990-08:00The crossword that counts itself<p>I love puzzles. This is <a href="http://www.theguardian.com/science/2015/nov/23/can-you-solve-it-the-crossword-that-counts-itself">described by Alex Bellos at the Guardian</a>.</p>
<p>It helps to write a spreadsheet to solve this.</p>
<ol>
<li>Set the column widths to be about the same as the height, making them look square.</li>
<li>Draw out the puzzle by highlighting a phrase (there are 12 "phrases"), and formatting: format cells, borders, click outline, OK.</li>
<li>Repeat for each of the other 11 phrases, highlight, Ctrl-Y (repeats the last format command for a new area)</li>
<li>Count the lengths of the rectangles (these are "phrase length"), subtract (3 or 2) to get "word length"</li>
<li>The area inside the blue box is named "puzzle"</li>
<li>The formula (row 20) for "actual" is: = SUMPRODUCT( LEN(puzzle) - LEN( SUBSTITUTE(puzzle,"e","") ))</li>
<li>This formula is copied for the 11 rows below and the letter edited, each time.</li>
<li>The formula for "= target" is: =IF( E20 = F20, "Y", "N")</li>
<li>When they all show "Y", the puzzle is solved.</li>
<li>The sum in cell e32 just tallies the 12 "actual" numbers. It must eventually show 68 when the puzzle is solved</li>
<li>The working between p18 : ae32 allows one to count the number of times each number word is used and tally them (must be = 68 too)</li>
<li>The cells bordered in red are named: number</li>
<li>The "word cells" formula is just: = number * R19</li>
<li>This formula is copied down and across (to the 3 combos). The "3 combos" show the 3 possible combinations of possible words.</li>
<li>The "# letters" fomula is just the length of the number. e.g.: = LEN( AD20 )</li>
</ol>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiXhUJqgSv09m54YFi35hS5n0DJ_kKsFLshJjHZ7uq6La9cEdKU8Q7zonhdpIOffPXgN-ta6eJHoN55xaEU8iZa8sXrQ0q3RW-e-dZzTTXdmhwfxcRxevWaSV_MPJZE_XRaao7GdTEyOg/s1600/words-counts-itself-xl.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiXhUJqgSv09m54YFi35hS5n0DJ_kKsFLshJjHZ7uq6La9cEdKU8Q7zonhdpIOffPXgN-ta6eJHoN55xaEU8iZa8sXrQ0q3RW-e-dZzTTXdmhwfxcRxevWaSV_MPJZE_XRaao7GdTEyOg/s1600/words-counts-itself-xl.png" /></a>
<p>This is not so easy to solve using purely coded program, because the rules to narrow down the combinations are not so clear. After you've figured out what constraints must be met it, no doubt, becomes much easier to program.</p>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-57423240481279040342015-11-10T06:25:00.001-08:002015-11-10T06:25:33.891-08:00Code spippets - Fsharp<div class="grid_5 omega clipper-description">
<h2><a href="http://www.gistboxapp.com/clipper-tutorial/">GistBox Clipper</a></h2>
<p>
Clipper is the companion Chrome extension to GistBox. It allows users to create Gists from:
</p>
<ul>
<li>Example code blocks</li>
<li>Highlighted text</li>
<li>Any page on the web</li>
</ul>
<a href="#" class="btn btn-large btn-cta get-clipper" data-item-url="https://chrome.google.com/webstore/detail/cejmhmbmafamjegaebkjhnckhepgmido">Install Chrome
Extension</a>
</div>
http://www.gistboxapp.com/clipper-tutorial/
<dl class="snippet">
<dt>Enter keyboard data, via console, with validation.<dt>
<dd>
/// Read a valid age (between 0 and 150) from key input
let readage (person: string) =
let mutable continueLooping = true
let mutable age = 0
while continueLooping do
Console.WriteLine("Enter {0}'s age (between 0 and 150): ", person)
let canparse, keyin = Int32.TryParse(Console.ReadLine())
age <- keyin
if canparse && age >= 0 && age < 151 then continueLooping <- false
age
</dd>
<dt><dt>
<dd></dd>
<dt><dt>
<dd></dd>
</dl>
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-70971939413429461112015-11-10T05:56:00.002-08:002015-11-10T06:16:22.995-08:00Code snippets - css<dl class="snippet">
<dt>Lists, without indents, with buttons, and over-handing firstline<dt>
<dd>
ul {
list-style: disc outside none;
margin-left: 0;
padding-left: 1em;
}
ul.circle { list-style-type: circle; } /* for lists within lists */
li {
padding-left: 0.5em;
}
</dd>
<dt>pre :- with CR wrapping a line<dt>
<dd>
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</dd>
</dl>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-24861274568783863832015-06-25T02:33:00.001-07:002015-06-25T03:20:30.320-07:00Snippet: Searching web pages.<p>The idea's from <a href="http://www.amazon.com/Professional-F-2-0-Ted-Neward/dp/047052801X/">Professional F# 2.0</a>, Chapter 17 (by Ted Neward, Aaron C. Erickson, Talbott Crowell, Richard Minerich). Because there are 4 of them I'll call them the fgang of four, or FoF.
When searching a dropdown list via a form, a web page form may return a value or nothing at all. F# handles nothing at all with <code>None</code>.
Suppose our database data contained:</p>
<pre>
type VacationLocation =
{ Name: string; Pop: int; Density: int; Nightlife: int }
let destinations =
[ { Name = "New York"; Pop = 9000000; Density = 27000; Nightlife = 9 }
{ Name = "Munich"; Pop = 1300000; Density = 4300; Nightlife = 7 }
{ Name = "Tokyo"; Pop = 13000000; Density = 15000; Nightlife = 3 }
{ Name = "Rome"; Pop = 2700000; Density = 5500; Nightlife = 5 } ]
</pre>
<p>Our web page filters user selections by city name, population, population density, and night life. A user will often ignore a selection. So each selection will be an option.
A first iteration of F# can handle it likewise, using the identity function <code>id</code>:</p>
<pre>
let getVacationPipeline nightlifeMin sizeMin densityMax searchName =
match nightlifeMin with
| Some(n) -> List.filter (fun x -> x.Nightlife >= n)
| None -> id
>> match sizeMin with
| Some(s) -> List.filter (fun x -> x.Pop / x.Density >= s)
| None -> id
>> match densityMax with
| Some(d) -> List.filter (fun x -> x.Density <= d)
| None -> id
>> match searchName with
| Some(sn) -> List.filter (fun x -> x.Name.Contains(sn))
| None -> id
</pre>
<p>This function is applied to the data like so:
<pre>
let applyVacationPipeline data filterPipeline =
data
|> filterPipeline
|> List.map (fun x -> x.Name)
</pre>
<p>with <code>filterPipeline</code> a general function to be applied for the <i>where</i> clause. The last line is the <i>select</i> clause.</p>
<pre>
let myPipeline = getVacationPipeline (Some 5) (Some 200) (Some 8000) None
applyVacationPipeline destinations myPipeline
</pre>
<p>
This <code>match ... with ... some ... None -> id</code> is repetitive, so we abstract it out as a <code>getFilter</code> function. It becomes:</p>
</p>
<pre>
let getVacationPipeline2 nightlifeMin sizeMin densityMax searchName =
let getFilter filter some =
match some with
| Some(v) -> List.filter (filter v)
| None -> id
getFilter (fun nlMax x -> x.Nightlife >= nlMax) nightlifeMin
>> getFilter (fun sMax x -> x.Pop / x.Density >= sMax) sizeMin
>> getFilter (fun dMin x -> x.Density < dMin) densityMax
>> getFilter (fun sName x -> x.Name.Contains(sName)) searchName
</pre>
<p>We can invoke it like so:</p>
<pre>
let myPipeline2 = getVacationPipeline2 (Some 5) (Some 200) (Some 8000) None
applyVacationPipeline destinations myPipeline2
</pre>
<p>The FoF is more detailed, beginning with an imperative version (??). I suspect every C# programmer gave up such imperative code long ago for Linq.</p>
<p>F# automatically handles missing data. Because we can compose our queries, each may be simply tested too.</p>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-51238994567235682472015-01-05T05:50:00.002-08:002018-10-13T02:13:31.610-07:00Russian propaganda (cyber-warfare?) example on twitter<p>Russia has been accused of funding and propagandising anti-fracking campaigns in the West<sup><a href="#1">1</a>, <a href="#2">2</a></sup>. Natural gas is a famous Russian export but many energy exports (gas, oil, coal, nuclear power) are important to the Russian economy. The recent fall in the price of oil even precipitated an economic crisis there.
Preventing fracking in Europe is a good way to keep natural gas prices high. They've already had a lot of success in that area.</p>
<p>Given they have the 'resources' in place, it seems obvious to turn against nuclear power too. One such example is their recent twitter campaign, using the hashtags <a href="https://twitter.com/hashtag/FukushimaAgain?src=hash">#FukushimaAgain</a> <a href="https://twitter.com/hashtag/Chernobyl2015?src=hash">#Chernobyl2015</a>. It's already been noted that the '<i>accident</i>' to the reactor in the Ukraine was an incident not an accident<sup><a href="#4">4</a></sup>. Russian media sources are systematically misreporting the events in Ukraine, and at Ukraine nuclear reactors too<sup><a href="#5">5</a></sup>.</p>
<p>These are just the first 10 accounts I looked at tweeting those hashtags. I've no idea how many more there are of them.<ul>
<li><a href="https://twitter.com/search?q=%40BethMcguire23">@BethMcguire23</a></li>
<li><a href="https://twitter.com/search?q=%40Georg_Simon_">@Georg_Simon_</a></li>
<li><a href="https://twitter.com/search?q=%40th0dear">@th0dear</a></li>
<li><a href="https://twitter.com/search?q=%40EttyFowler">@EttyFowler</a></li>
<li><a href="https://twitter.com/search?q=%40izchetham">@izchetham</a></li>
<li><a href="https://twitter.com/search?q=%40KrisWalker54">@KrisWalker54</a></li>
<li><a href="https://twitter.com/search?q=%40Will_Cook_">@Will_Cook_</a></li>
<li><a href="https://twitter.com/search?q=%40RickIrwin_">@RickIrwin_</a></li>
<li><a href="https://twitter.com/search?q=%40FaigaPierce">@FaigaPierce</a></li>
<li><a href="https://twitter.com/search?q=%40Lou_Hensley_">@Lou_Hensley_</a></li>
</ul></p>
<p>These accounts don't, at first, look fake. A detailed investigation shows otherwise: they are hijacked or fake:</p>
<ul>
<li>most of the accounts only began tweeting within the last few weeks</li>
<li>the accounts have a few hundred tweets each, often made very recently</li>
<li>they rarely, if ever, tweet to anyone else</li>
<li>they don't engage anyone in a conversation</li>
<li>many of the innocent looking tweets are garbage:<ul>
<li>common quotes from famous people e.g.:<blockquote class="twitter-tweet" lang="en"><p>Intense love does not measure, it just gives. – Mother Teresa</p>— Beth Mcguire (@BethMcguire23) <a href="https://twitter.com/BethMcguire23/status/550195581369331712">December 31, 2014</a></blockquote></li>
<li>'witty', or 'pseudo-intellectual' observations. e.g.:<blockquote class="twitter-tweet" lang="en"><p>Those who are easily shocked should be shocked more often</p>— Beth Mcguire (@BethMcguire23) <a href="https://twitter.com/BethMcguire23/status/550195449236160513">December 31, 2014</a></blockquote></li>
</ul></li>
<li>here's an example of a tweet that belongs to a conversation. A message to a friend. Who might that be?: <blockquote class="twitter-tweet" lang="en"><p>So call your shawty you tell him you found a new man</p>— Beth Mcguire (@BethMcguire23) <a href="https://twitter.com/BethMcguire23/status/550194262327840768">December 31, 2014</a></blockquote></li>
<li>tweets are often made with very short time intervals between them - indicating the person has nothing better to do than, essentially, repeat the same tweet. More like it's a bot using random time intervals.</li>
<li>tweets are likely to be gender neutral, geographically neutral. The bot doesn't know whether it's pretending to be male/female or whatever. The more specific the tweet, the more trouble a programmer must endure to fake it.</li>
</ul>
<p>For more on fake twitter accounts see: <sup><a href="#6">6</a></sup></p>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
<h4>References</h4>
<ol>
<li id="1"><a href="http://www.frontpagemag.com/2014/dgreenfield/nato-chief-putin-behind-anti-fracking-campaigns/">NATO Chief: Putin Behind Anti-Fracking Campaigns</a></li>
<li id="2"><a href="http://foreignpolicy.com/2014/06/20/russias-quiet-war-against-european-fracking/">Russia’s Quiet War Against European Fracking</a></li>
<li id="3"><a href="http://www.theguardian.com/world/2005/may/13/russia.nickpatonwalsh">Russia says 'spies' work in foreign NGOs</a></li>
<li id="4"><a href="http://ansnuclearcafe.org/2014/12/04/reporting-an-incident-as-an-accident/">Reporting an Incident as an Accident</a></li>
<li id="5"><a href="http://atomicpowerreview.blogspot.com.au/2015/01/ukraine-nuclear-plants-resources-and.html?m=1">Ukraine Nuclear Plants - Resources and Information</a></li>
<li id="6"><a href="http://chrismakara.com/social-media/11-easy-ways-to-spot-a-fake-twitter-account/">11 Easy Ways To Spot a Fake Twitter Account</a></li>
</ol>Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-67911641688228216102014-06-26T04:32:00.002-07:002014-06-28T01:20:45.856-07:00Today I discovered Elm<p>Web pages are broke. They always were, from the inception of html, to all the fixes: css, JavaScript, DHTML, Ajax. Now we have an explosion of fixes: sass, lass, Jade, JRX, an explosion of MVM and, even MVVM frameworks. An army of languages to write JavaScript with. Are we doomed to ever more complexity; cludge piled upon fix glued together by compromise?</p>
<p>Is there a light at the end of the tunnel? Today I discovered Elm. Video presentations:</p>
<ul>
<li><a href="http://www.infoq.com/presentations/Elm">What is the point of Elm?</a></li>
<li><a href="http://www.infoq.com/presentations/elm-reactive-programming">Functional Reactive Programming in Elm (@ StrangeLoop 2013)</a></li>
<li><a href="http://www.infoq.com/interviews/czaplicki-frp-elm">Q&A, Evan Czaplicki on FRP in the Browser with Elm, Time Travelling Debugger</a></li>
</ul>
<p>Some links</p>
<ul>
<li><a href="http://elm-lang.org/">elm: a functional reactive language for the web (Elm website)</a></li>
<li><a href="http://scrambledeggsontoast.github.io/2014/05/09/writing-2048-elm/">Writing a 2048 clone in elm</a></li>
<li><a href="http://elm-lang.org/edit/examples/Intermediate/Form.elm">Elm form with submit</a></li>
</ul>
<p>Academic (papers)</p>
<ul>
<li><a href="http://www.testblogpleaseignore.com/wp-content/uploads/2012/03/thesis.pdf">Elm: Concurrent FRP for Functional GUIs</a></li>
<li><a href="http://people.seas.harvard.edu/~chong/pubs/pldi13-elm.pdf">Elm: Asynchronous Functional Reactive Programming for GUIs</a></li>
<li><a href="http://haskell.cs.yale.edu/wp-content/uploads/2011/02/icfp97.pdf">Functional Reactive Animation (Conal Elliott, Paul Hudak)</a></li>
<li><a href="http://haskell.cs.yale.edu/wp-content/uploads/2011/02/workshop-02.pdf">Functional Reactive Programming, Continued (Henrik Nilsson, Antony Courtney, John Peterson)</a></li>
<li><a href="http://people.cs.uchicago.edu/~jhr/papers/cml.html">Concurrent ML</a></li>
</ul>
<p>And a Haskell page to remember.</p>
<ul>
<li><a href="http://www.haskell.org/haskellwiki/Functional_Reactive_Programming">Functional Reactive Programming (Haskell)</a></li>
<li><a href="http://www.haskell.org/haskellwiki/Typeclassopedia">Haskell Typeclassopedia</a></li>
</ul>
<p>F# computation expressions</p>
<ul>
<li><a href="http://fsharpforfunandprofit.com/posts/computation-expressions-intro/">Computation expressions: Introduction</a></li>
</ul>
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0tag:blogger.com,1999:blog-2504353455240714156.post-25792652169673393692014-06-25T08:25:00.001-07:002014-06-28T01:05:58.143-07:00Links 4 me.<p>In honour of the software crisis, still bedevilling us nearly 50 years later.</p>
<a href="http://www.infoq.com/presentations/tdd-original">TDD: Where Did It All Go Wrong?</a> |
<a href="http://codebork.com/2014/03/23/introducing-bob.html">BobTheBuilder - Test Data Builder for C#</a>
<p>And a book I mean to read:</p>
<ul>
<li><a href="https://leanpub.com/software-architecture-for-developers">Software Architecture for Developers</a></li>
</ul>
Jack Eddyfierhttp://www.blogger.com/profile/00546379110958307956noreply@blogger.com0