Skip to content

Instantly share code, notes, and snippets.

@dcsobral
dcsobral / open.sh
Created August 6, 2020 15:24
"open" for Bash on WSL in Windows
open ()
{
# The first argument to start needs to be empty to avoid issues when paths have spaces
cmd.exe /C start "" "$(wslpath -w "$1")"
}
@dcsobral
dcsobral / README.md
Created April 15, 2020 23:40
Scala Configurable Warnings

Pull request #8373 implementing issue 333 (but please note differences).

Pull request description follows:

This PR adds a -Wconf compiler flag that allows filtering and configuring compiler warnings (silence them, or turn them into errors).

It also integrates the fantastic silencer compiler plugin by @ghik into the compiler, which allows suppressing warnings locally using the @nowarn annotation.

package slamdata
import sjsonnew.IsoString
import sjsonnew.shaded.scalajson.ast.unsafe.JValue
import sjsonnew.support.scalajson.unsafe.{Converter, Parser, PrettyPrinter}
import java.nio.file.Path
final class ManagedVersions private (path: Path) {
@dcsobral
dcsobral / output_log.txt
Created October 1, 2019 18:42
7 Days to Die output log when started with the mod launcher and "save all games local to mod" option checked
Initialize engine version: 2018.2.0f2 (787658998520)
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.1]
Renderer: NVIDIA GeForce GTX 1080 Ti (ID=0x1b06)
Vendor:
VRAM: 11127 MB
Driver: 26.21.14.3630
Begin MonoManager ReloadAssembly
- Completed reload, in 0.110 seconds
@dcsobral
dcsobral / runcached
Created July 18, 2019 15:28 — forked from akorn/runcached
Run speficied (presumably expensive) command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
#!/bin/zsh
#
# Purpose: run speficied command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
# Also cache exit status and stderr.
# License: GPLv3
# Use silly long variable names to avoid clashing with whatever the invoked program might use
RUNCACHED_MAX_AGE=${RUNCACHED_MAX_AGE:-300}
RUNCACHED_IGNORE_ENV=${RUNCACHED_IGNORE_ENV:-0}
RUNCACHED_IGNORE_PWD=${RUNCACHED_IGNORE_PWD:-0}
@dcsobral
dcsobral / realpath.md
Last active May 29, 2019 18:13
Real Path

I'm getting increasingly fascinated by the trouble that is getting the real path to a file in Unixy filesystems. That is, the path to a file that has no symbolic links on any of its components. You don't see what the big deal is? Check https://stackoverflow.com/questions/284662/how-do-you-normalize-a-file-path-in-bash. Now... please note that, as far as pure shell solutions go, none of them are correct.

I've seen plenty of examples of this, and they work fine, for values of fine that do not include nested symlinking. For example, sbt-extras has this:

get_script_path () {
<!-- Multiwall -->
<block id="1857" name="multiWall_Steel_9m">
<property name="Class" value="PlantGrowing" />
<property name="CustomIcon" value="steelBlock" />
<property name="Material" value="Msteel" />
<property name="Texture" value="355,355,355,355,355,355" />
<property class="PlantGrowing">
<property name="FertileLevel" value="0" />
<property name="Next" value="steelBlock" />
<!-- ADMIN ITEMS -->
<item id="3500" name="Admin_nailgun">
<property name="IsDeveloper" value="true"/>
<property name="Meshfile" value="Items/Tools/nailgunPrefab"/>
<property name="CustomIcon" value="nailgun"/>
<property name="CustomIconTint" value="FF0000"/>
<property name="Material" value="metal"/>
<property name="HoldType" value="37"/>
<property name="Stacknumber" value="1"/>
<property name="RepairTools" value="repairKit"/>
import sbt.Keys._
import sbt._
import java.nio.file.Files
object TempDir extends AutoPlugin {
object autoImport {
lazy val tempDir = taskKey[File]("Sets target.temp.directory Java property. Creates the directory if needed.")
}
import autoImport._
// javassist is used by logback, optionally. Like logback, don't pollute upstream dependencies.
"ch.qos.logback" % "logback-classic" % "1.1.1" % "optional",