Skip to content

Instantly share code, notes, and snippets.

View vapor-install-output.txt
~/src/vapor-toolbox$ make install
swiftc ./scripts/build.swift
scripts/build.swift:48:10: warning: 'launchPath' is deprecated: renamed to 'executableURL'
task.launchPath = "/usr/bin/env"
^
scripts/build.swift:48:10: note: use 'executableURL' instead
task.launchPath = "/usr/bin/env"
^~~~~~~~~~
executableURL
scripts/build.swift:50:10: warning: 'launch()' is deprecated: renamed to 'run'
View haskell-methods.md

Methods in Haskell

One of the things I really miss from C# when using Haskell is the dot-syntax for properties and methods. I like dot-syntax for methods for a few reasons

  • Explorability of the language. You type xyz. and the IDE shows you what operations are available on xyz via IntelliSense.
  • Namespace management
    • You can have a method move on one class and another (unrelated) method move on another class and there's no name clash.
    • Haskell folks will point to type classes for this sort of thing. However, that only makes sense if the move is semantically the same for both classes.
    • When all you have is Haskell modules for namespace management, you end up in import qualified land which gets messy fast.
View point-methods.hs
{-# LANGUAGE OverloadedRecordDot, OverloadedRecordUpdate, DuplicateRecordFields #-}
----------------------------------------------------------------------
data Point = Point { x :: Double, y :: Double, distance :: Point -> Double }
instance Show Point where
show p = "Point { x = " ++ show p.x ++ ", y = " ++ show p.y ++ " }"
point_distance :: Point -> Point -> Double
point_distance a b = sqrt ((b.x - a.x)^2 + (b.y - a.y)^2)
----------------------------------------------------------------------
View 2021-04-24.md

Regarding your comment:

Btw, if you have stored LinkId for child comments - yes, I know it is redundant and comes from the parent, but it would have given you a simple non hierarchical filter criteria for all link comments, thus the technique with simple Include would have worked.

Excerpt of the Comment class for reference:

    public class Comment
    {
        public int? LinkId { get; set; }
View giraffe-input-tag-helper.fs
let input_helper (type_obj : System.Type) (property_name : string) (value_str : string) (name_str : string) (attrs_a : XmlAttribute list)=
let mutable type_value = ""
let mutable ls : XmlAttribute list = []
let properties = type_obj.GetProperties()
let property_info = properties.First(fun info -> info.Name = property_name)
View csharp-html-generation-libraries.md
@dharmatech
dharmatech / YouTube-JRE-to-CSV.ps1
Last active Apr 9, 2020
PowerShell script that downloads information from all JRE episodes on YouTube. Store in a CSV file. Example of data imported into coda.io: https://coda.io/@eduardo-cavazos/jre-video-list
View YouTube-JRE-to-CSV.ps1
$api_key = (Get-Content C:\Users\dharm\Dropbox\Documents\youtube-api-key)
function get-channel-uploads ($channel_id)
{
$result = Invoke-RestMethod `
"https://www.googleapis.com/youtube/v3/channels?id=$channel_id&key=$api_key&part=contentDetails"
$result.items[0].contentDetails.relatedPlaylists.uploads
}
View symbolism-linux.md
View WpfExtensionMethods.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace WpfExtensionMethods
View pinter-16-A-4-P2-P3
Z3xZ3 : { (0, 0) (0, 1) (0, 2) (1, 0) (1, 1) (1, 2) (2, 0) (2, 1) (2, 2) }
Z3xZ3 operation table:
|(0, 0) (0, 1) (0, 2) (1, 0) (1, 1) (1, 2) (2, 0) (2, 1) (2, 2)
----------------------------------------------------------------------
(0, 0)|(0, 0) (0, 1) (0, 2) (1, 0) (1, 1) (1, 2) (2, 0) (2, 1) (2, 2)
(0, 1)|(0, 1) (0, 2) (0, 0) (1, 1) (1, 2) (1, 0) (2, 1) (2, 2) (2, 0)
(0, 2)|(0, 2) (0, 0) (0, 1) (1, 2) (1, 0) (1, 1) (2, 2) (2, 0) (2, 1)