Skip to content

Instantly share code, notes, and snippets.

View palpha's full-sized avatar

Niklas Bergius palpha

View GitHub Profile
@palpha
palpha / gist:d303d4aa1e4a51af5b47
Created September 2, 2015 13:12
Simple inline PowerShell task for MSBuild 14
<UsingTask TaskName="PowerShell" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<ScriptBlock ParameterType="System.String" Required="true" />
<ScriptParams ParameterType="System.String" Required="false" />
</ParameterGroup>
<Task>
<Reference Include="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"/>
<Code Type="Class" Language="cs"><![CDATA[
public class PowerShell : Microsoft.Build.Tasks.Exec {
public string ScriptParams {
@palpha
palpha / on-parentheses-in-fsharp.md
Last active August 20, 2021 05:53
On parentheses in F#

There's a blog post currently making the rounds, about a developer's experience of using F# for anything serious for the first time: http://www.knowing.net/index.php/2014/02/13/notes-on-my-first-real-f-program/

Among other things, it touches the subject of parentheses. This is a subject that seems to be widely misunderstood, and the blog post exhibits one such misunderstanding by calling parentheses in F# optional.

I will try to bring some sanity to the table, but am fully aware that I don't know a fraction of what I would need to know in order to call myself an expert in F#. Comments and corrections are very welcome (bergius on Twitter).

Parentheses in F#

TL;DR: It's all about precedence and associativity. It has nothing to do with differences between methods and functions. It is not the parentheses that are optional, but the spaces between parentheses and other things.

@palpha
palpha / postgresql-random-series.sql
Created January 9, 2014 12:11
PostgreSQL: generate a random series with configurable start, max and step.
with recursive t (n) as (
with base as (
with settings as (
select
10000 as max
, array[1000,2000] as start_range
, array[10,20] as step_range
)
select
(random() * (start_range[2] - start_range[1]) + start_range[1])::int as start