Skip to content

Instantly share code, notes, and snippets.

@SkyWriter
SkyWriter / default.nix
Created February 10, 2024 21:19 — forked from danbst/default.nix
Proof-of-Concept running PostgreSQL tests inside Nix package build
with import <nixpkgs> { };
runCommand "some-test" {
buildInputs = [ postgresql ];
preCheck = ''
set -e
export PGDATA=$TMP/db
export PGHOST=$TMP/socketdir
mkdir $PGDATA $PGHOST
pg_ctl initdb
echo "unix_socket_directories = '$PGHOST'" >> $PGDATA/postgresql.conf
@SkyWriter
SkyWriter / README.md
Created December 17, 2023 14:28 — forked from baetheus/README.md
SmartOS Single IP with NAT using VLAN

WARNING

These intructions might work, but they need a bit of attention. I've been reading through ipf and smf documentation and have found a few ways to improve this process. When I have time I'll add that information here, until then, be sure to look into the ipf settings if you're having issues with routing. Good luck!

Foreword

This is a modified version of sjorge's instructions for Single IP with NAT. Those instructions can be found here: https://docu.blackdot.be/snipets/solaris/smartos-nat

The primary difference is that this version does not rely on etherstubs for internal switching, but instead uses a vlan configuration. The benefits of this method over using etherstubs are:

  1. Project Fifo (project-fifo.net) can create vms and zones with vlans, but does not currently have etherstub support.
  2. Vlan switching is supposedly more efficient than creating an etherstub to handle switching. I have not tested this statement.
@SkyWriter
SkyWriter / pad_packed_demo.py
Created January 14, 2023 19:30 — forked from HarshTrivedi/pad_packed_demo.py
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
#
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
@SkyWriter
SkyWriter / sidekiq_monitoring
Created February 28, 2020 12:02 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
# ffmpeg -i steep_turn_corrected.MOV -acodec copy -vcodec copy steep_turn_corrected.mp4
# exiftool -ProjectionType="equirectangular" photo.jpg
ffmpeg -i hatcher_birthday1.MOV -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate0.ts
ffmpeg -i hatcher_birthday2.MOV -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i "concat:intermediate0.ts|intermediate1.ts" -c copy -bsf:a aac_adtstoasc hatcher_birthday.mp4
@SkyWriter
SkyWriter / tmux-migrate-options.py
Created May 23, 2019 10:23 — forked from tbutts/tmux-migrate-options.py
For tmux configs: Merge deprecated/removed -fg, -bg, and -attr options into the -style option
#!/usr/bin/env python
# vim: set fileencoding=utf-8
#
# USAGE:
# Back up your tmux old config, run the script and redirect stdout to your conf
# file. Example:
#
# $ cp ~/.tmux.conf ~/.tmux.conf.orig
# $ python ./tmux-migrate-options.py ~/.tmux.conf.orig > ~/.tmux.conf
#
@SkyWriter
SkyWriter / nes.py
Created May 19, 2019 08:11 — forked from karpathy/nes.py
Natural Evolution Strategies (NES) toy example that optimizes a quadratic function
"""
A bare bones examples of optimizing a black-box function (f) using
Natural Evolution Strategies (NES), where the parameter distribution is a
gaussian of fixed standard deviation.
"""
import numpy as np
np.random.seed(0)
# the function we want to optimize
@SkyWriter
SkyWriter / PDFUtil.java
Created October 18, 2017 14:29 — forked from jribble/PDFUtil.java
Flatten PDF documents using PDFBox
package pdfutil;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSStream;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDResources;
@SkyWriter
SkyWriter / JSON.hs
Created April 21, 2017 17:39 — forked from jferris/JSON.hs
Test.Hspec.JSON
module Test.Hspec.JSON
( shouldBeJson
) where
import Control.Monad (when)
import Control.Monad.State (StateT, get, modify, runStateT)
import Control.Monad.Writer (Writer, execWriter, tell)
import Data.ByteString.Lazy (ByteString)
import Data.Function (on)
import Data.Monoid ((<>))
@SkyWriter
SkyWriter / Example.hs
Created April 21, 2017 17:39 — forked from jferris/Example.hs
Arrows
{-# LANGUAGE Arrows #-}
import Control.Arrow
double :: Int -> Int
double x = x * 2
triple :: Int -> Int
triple x = x * 3