Skip to content

Instantly share code, notes, and snippets.

@devjev
devjev / tree_trait.rs
Created January 5, 2021 07:17
A good tree node trait
trait TreeNode<T> {
type RefType: AsRef<Self> + Deref<Target = Self>;
fn value(&self) -> T;
fn children(&self) -> &[Self::RefType];
}
@devjev
devjev / dependency-roulette-1.txt
Created January 1, 2021 12:21
Dependency Roulette #1
$ yarn add screenres
yarn add v1.22.10
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
error ...\node_modules\screenres: Command failed.
Exit code: 1
Command: node-gyp rebuild
@devjev
devjev / minimal-safe-bash.sh
Created December 15, 2020 12:15
Minimal safe bash template
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
@devjev
devjev / clear_terminal.rs
Created October 7, 2020 06:47
Clear Terminal in Rust
fn clear_terminal() {
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
}
@devjev
devjev / guid.vbs
Created June 28, 2020 07:56
Create GUIDs in Excel
Private Type GUID_TYPE
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Declare PtrSafe Function CoCreateGuid Lib "ole32.dll" (Guid As GUID_TYPE) As LongPtr
Private Declare PtrSafe Function StringFromGUID2 Lib "ole32.dll" (Guid As GUID_TYPE, ByVal lpStrGuid As LongPtr, ByVal cbMax As Long) As LongPtr
@devjev
devjev / build.fsx
Last active July 4, 2019 22:02
Fake build script which copies the build results to a build/* folder
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.IO.FileSystemOperators
open Fake.Core.TargetOperators
// Params =====================================================================
@devjev
devjev / GetAssemblyPath.cs
Created September 13, 2016 07:46
How to get the directory the running assembly is in
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
@devjev
devjev / gist:7325149
Last active December 27, 2015 12:19
Show the last 5 commits in an abbreviated form
git log –pretty=oneline –-abbrev-commit | head –n 5