Skip to content

Instantly share code, notes, and snippets.

@detunized
detunized / run.sh
Created September 4, 2017 11:02
Mount a read-only folder inside a Docker container with OverlayFS on top
# On the host to run the container
docker run --privileged -i -t -v ~/host-folder-to-mount:/root/folder-ro:ro ubuntu
# Inside the container
# Need to create the upper and work dirs inside a tmpfs.
# Otherwise OverlayFS complains about AUFS folders.
mkdir -p /tmp/overlay && \
mount -t tmpfs tmpfs /tmp/overlay && \
mkdir -p /tmp/overlay/{upper,work} && \
mkdir -p /root/folder && \
@detunized
detunized / join.sh
Last active June 27, 2025 09:18
Join repos into subfolders with flat history
#!/bin/bash
set -euo pipefail
$REPO_DIR=~/devel
repos="1password bitwarden dashlane lastpass opvault passwordbox roboform stickypassword truekey zoho-vault"
# pull all repos
(
for repo in $repos; do
echo $repo
@detunized
detunized / duplicate-line.lua
Created May 6, 2017 20:02
Duplicate line Far Manager editor macro
-- Copyright (C) 2017 Dmitry Yakimenko (detunized@gmail.com).
-- Licensed under the terms of the MIT license. See LICENCE for details.
-- Duplicate line Far Manager editor macro
Macro {
description = "Duplicate line";
area = "Editor";
key = "CtrlD";
action=function()
@detunized
detunized / sort-libs.rb
Last active March 26, 2025 00:40
Sort static libraries in the topological order
#!/usr/bin/env ruby
# This script sorts static libraries in the topological order suitable for
# passing to ld. No need for --start-group/--end-group anymore. Should speed
# up the linking a bit. When the libraries contain actual circular dependecies
# the script will detect minimal groups of those and surround them with
# --start-group/--end-group.
#
# To run you need Linux (maybe OS X), Ruby 1.9+ and the rgl gem installed:
#
@detunized
detunized / globals.rb
Created January 16, 2012 12:24
List global Ruby variables and their values
global_variables.sort.each do |name|
puts "#{name}: #{eval "#{name}.inspect"}"
end
@detunized
detunized / nunut2xunit.cs
Created March 12, 2019 23:23
Convert NUnit to xUnit
// Copyright (C) 2019 Dmitry Yakimenko (detunized@gmail.com).
// Licensed under the terms of the MIT license. See LICENCE for details.
using System;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@detunized
detunized / gist:1317940
Created October 26, 2011 21:29
Magnifying glass shader
// (c) 2011 detunized (http://detunized.net)
// Paste the shader below into http://www.iquilezles.org/apps/shadertoy/?p=deform
// Click and drag the mouse around
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 resolution;
uniform vec4 mouse;
@detunized
detunized / fetch-github-activity.rb
Created April 18, 2019 11:31
Fetch GitHub activity from your profile page
require "open-uri"
def github_activity username
open("https://github.com/#{username}") { |io| io.read }
.scan(/fill="#(.{6})" data-count="(\d+)"/)
.map { |i| {color: i[0], value: i[1].to_i} }
end
p github_activity "your-username"
@detunized
detunized / enable-exit-pulse-secure.sh
Created April 17, 2019 12:12
Enable exit function in Pulse Secure (when disabled by the admin)
# /bin/bash
cd '/Library/Application Support/Pulse Secure/Pulse'
sudo sed -i '' \
s'/connection-policy-override: "false"/connection-policy-override: "true"/' \
connstore.dat
sudo killall PulseTray 'Pulse Secure' dsAccessService
@detunized
detunized / find-code.cs
Created March 16, 2019 21:02
Find a code pattern in C# files
// Copyright (C) 2019 Dmitry Yakimenko (detunized@gmail.com).
// Licensed under the terms of the MIT license. See LICENCE for details.
using System;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;