Skip to content

Instantly share code, notes, and snippets.

@yacn
yacn / patch_etc.rb
Last active February 24, 2023 18:44
Patch for Ruby's Etc module to avoid using C-extensions on modern hosts in GCE with oslogin enabled. Provided as-is, without warranty, express or implied.
# monkey patch Etc module to work around the segfault that occurs using when
# oslogin is enabled on newer systems (Debian 11+, Ubuntu 20.04+)
# https://github.com/chef/chef/issues/12993
module PatchedEtc
def _getent(db, key, regex, schema, struct_klass, error_word = db)
info = `getent #{db} #{key}`.chomp
raise(ArgumentError, "can't find #{error_word} for #{key}") unless $?.success?
fn_schema = schema.map { |k, v| v.class == Class ? [k, _to_class_fn(v)] : [k, v] }.to_h
matches = info.match(regex)
@yacn
yacn / howto.md
Last active October 31, 2021 05:13
merging two files from an iphone.

Merging two videos from an iPhone 7

Step 1. Make sure videos are completely the same spec-wise (same resolution/aspect ratio/time base/etc)

Example 1

  • Two videos: a.mov, b.mov
    • a.mov: 838x838
    • b.mov: 724x724
@yacn
yacn / rtorrent_fast_resume.py
Last active November 11, 2020 04:45
Converting rtorrent_fast_resume.pl to Python 3
#!/usr/bin/env python3
"""
og perl source:
https://github.com/rakshasa/rtorrent/blob/79765768ff3d93a511ceb90df24a8dbb0a62e4f5/doc/rtorrent_fast_resume.pl
"""
"""
Usage:
rtorrent_fast_resume.py [base-directory] < plain.torrent > with_fast_resume.torrent
@yacn
yacn / read-deluge-state.py
Last active May 15, 2021 10:18
Script showing how to read deluge's torrent state. only tested on 1.3.15
#!/usr/bin/env python3
import argparse
import collections
import io
import os
import pickle
import sys
def existing_file(p):
@yacn
yacn / install-or-update-zoom.sh
Last active October 21, 2020 23:57
Install/Update script for Zoom on Solus (or any linux that can use their "Other Linux" gcc 4.7+ package)
#!/usr/bin/env bash
set -e
function log() { echo "$(date +"%Y-%m-%d %H:%M:%S")" "$@"; }
pkg_url="https://zoom.us/client/latest/zoom_x86_64.tar.xz"
arch_pkg_url="https://zoom.us/client/latest/zoom_x86_64.pkg.tar.xz"
zoom_pkg="zoom_x86_64.tar.xz"
etag="zoom-etag.txt"
@yacn
yacn / iterm2 calls
Created August 14, 2019 16:32
iterm2 callls
Script → iTerm2 8/14, 9:30:40.918 AM:
<ITMClientOriginatedMessage 0x7fa05b978e50>: {
id: 0
notification_request {
session: "all"
subscribe: true
notification_type: NOTIFY_ON_VARIABLE_CHANGE
variable_monitor_request {
name: "effectiveTheme"
scope: APP
@yacn
yacn / librdkafka.rb
Created July 17, 2018 18:43
librdkafka.rb 0.9.2.x formula
class Librdkafka < Formula
desc "The Apache Kafka C/C++ library"
homepage "https://github.com/edenhill/librdkafka"
url "https://github.com/edenhill/librdkafka/archive/v0.9.2.tar.gz"
sha256 "c243b66956ebb196510ee0efda67825467e31b93639d5f24eb082b5d83f56824"
head "https://github.com/edenhill/librdkafka.git"
bottle do
cellar :any
@yacn
yacn / client-actions.py
Created June 24, 2018 15:02
Folding@home client, controller, viewer solus packaging
# file: client/actions.py
#!/usr/bin/python
# Created For Solus Operating System
from pisi.actionsapi import get, pisitools, shelltools
NoStrip = ["/usr"]
IgnoreAutodep = True
@yacn
yacn / dts-to-flac.sh
Created May 22, 2018 02:03
extract a DTS track from an MKV, convert it to FLAC, remux into new MKV w/ additional FLAC track, and set FLAC as default audio track
#!/bin/bash
for ((i=1; i<=13; i++)) do
if [[ "$i" -ge 10 ]]; then
name=$(ls The\ Expanse\ -\ S02E$i*.mkv)
else
name=$(ls The\ Expanse\ -\ S02E0$i*.mkv)
fi
# extract out dts track (id: 1 all files)
@yacn
yacn / gist:31f43eb48249817c32a7c4c0fc6211e6
Created April 27, 2018 04:00
Disable natural scrolling from command line
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false