Skip to content

Instantly share code, notes, and snippets.

View antranigv's full-sized avatar
🦇
I'm your worst nightmare...

Antranig Vartanian antranigv

🦇
I'm your worst nightmare...
View GitHub Profile
#!/bin/sh
# Usage: sh generate_bhyve_cpu_pinning.sh <host_ncpu> <nsock> <thrcc> <needncpu> <lastcpuid>
HOST_NCPU=$1
NSOCK=$2
THR=$3
GUEST_NCPU=$4
LAST_ID=$5
if [ "$#" -ne 5 ]; then
@antranigv
antranigv / AdiumMusicPresence.applescript
Created April 24, 2025 22:27
Adium Music Status that works with Music.app written in AppleScript
property lastTrack : "" -- Last known track (name & artist)
property lastState : "stopped" -- Last known playback state
property lastRunning : false -- Last known running state of Apple Music
on clearAdiumStatus()
tell application "Adium"
if it is running then
set status message of every account to ""
end if
@antranigv
antranigv / getpwd.c
Last active May 26, 2025 13:29
Get current working directory of a process in FreeBSD in C using libprocstat [no error handling]
// cc getpwd.c -l procstat -o getpwd
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/un.h>
#include <sys/user.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <libprocstat.h>
[global]
# adjust this to your network/netmask
remote announce = 172.16.100.0/24
security = user
encrypt passwords = yes
ea support = No
kernel share modes = No
mangled names = no
path = /usr/local/timemachine/%U
@antranigv
antranigv / gist:5acb4fffb1c8d52c8b8d8013ddecd4f7
Created July 24, 2023 22:30
Devuan Linux Jail on FreeBSD 13.2
root@srv0:/etc/jail.conf.d # cat linux0.conf
# vim: set syntax=sh:
exec.clean;
allow.raw_sockets;
mount.devfs;
linux0 {
$id = "2";
devfs_ruleset = 10;
$bridge = "bridge10";
@antranigv
antranigv / jailua.lua
Created March 16, 2023 03:11
FreeBSD jailua for Jail management
#!/usr/libexec/flua
local ucl = require('ucl')
local jail = require('jail')
function usage()
print(arg[0] .. " [ list | create jail.ucl | remove jail.ucl [jname] ]")
end
if #arg < 1 then
usage()
#!/bin/sh
add::fds()
{
COMMAND="fds,$1:$COMMAND"
}
run::fds()
{
procstat --libxo=xml -w 5 -f "$1" &
#!/bin/sh
#
# PROVIDE: khosenk
# REQUIRE: networking
# KEYWORD:
. /etc/rc.subr
name="khosenk"
rcvar="khosenk_enable"
use_synth :piano
use_bpm 94
define :intro do
play :C5
sleep 0.5
play :E5
sleep 0.5
play :A5
sleep 0.5
# cat /etc/jail.conf
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
allow.raw_sockets;
allow.mount.tmpfs;
mount.devfs;
base {