Skip to content

Instantly share code, notes, and snippets.

@StudioLE
StudioLE / NaturalLanguageExtensions.cs
Last active September 5, 2022 11:22
Convert TimeSpan and DateTime to a natural language representations
/// <summary>
/// Convert a <see cref="TimeSpan"/> to a natural language representation.
/// </summary>
/// <example>
/// <code>
/// TimeSpan.FromSeconds(10).ToNaturalLanguage();
/// // 10 seconds
/// </code>
/// </example>
public static string ToNaturalLanguage(this TimeSpan @this)
@StudioLE
StudioLE / git-rewrite-tags-as-commits
Last active September 14, 2021 08:41
Git rewrite tags as commits. Squash everything but preserve tags.
#!/bin/bash
ORIGINAL_BRANCH="main"
NEW_BRANCH="new-history"
START_COMMIT="84eafe059aa3059d2e3db260a2248deae7502c57"
NEW_TAG_PREFIX="v2-"
git checkout -b ${NEW_BRANCH} ${START_COMMIT}
# Loop through every tag on the ORIGINAL_BRANCH
@StudioLE
StudioLE / dotnetlayout.md
Created July 29, 2021 11:46 — forked from davidfowl/dotnetlayout.md
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
git branch -m master main && git fetch origin && git branch -u origin/main main && git remote set-head origin -a
@StudioLE
StudioLE / git-renormalize.sh
Last active June 9, 2020 16:12
Renormalize all line endings
echo "* text=auto" >.gitattributes
git add --renormalize .
git commit -m "Renormalized end-of-line"
@StudioLE
StudioLE / 00-change-motd.sh
Last active June 4, 2020 09:58
Ubuntu Change Message of the Day (MOTD)
#!/bin/bash
# https://raymii.org/s/tutorials/Disable_dynamic_motd_and_motd_news_spam_on_Ubuntu_18.04.html
# Disable Dynamic MOTD
# Change ENABLED=1 to ENABLED=0.
sudo nano /etc/default/motd-news
# Disable a few components
sudo chmod -x /etc/update-motd.d/00-header
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Debug One;Release</Configurations>
</PropertyGroup>
<PropertyGroup>
<!-- Please remove the targets you don't need in order
to exclude Revit versions your add-in won't support
use the list below for matching Revit version with .NET target
2014 | net40
b = brick;
footprint = Rectangle.ByWidthLength(b.Width, b.Length);
surface = Surface.ByPatch(footprint);
base = surface.Thicken(6/5, false);
p1 = [Imperative]
{
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
test = IN[0]
true_list = IN[1]
false_list = IN[2]
@StudioLE
StudioLE / AutoCAD Setup.js
Last active April 10, 2019 09:47
AutoCAD Setup
// Display start tab and not a new drawing on Startup
// https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/How-to-open-AutoCAD-without-opening-Drawing1.html
Command: STARTUP
Value: 2
// Disable drawing thumbnails when hovering a tab
// https://forums.autodesk.com/t5/autocad-forum/how-to-turn-off-file-tab-hover-preview/m-p/6347588#M126228
Command: FILETABPREVIEW
Value: 0