Skip to content

Instantly share code, notes, and snippets.

View jacobsalmela's full-sized avatar
:octocat:
To all that makes us unique

Jacob Salmela jacobsalmela

:octocat:
To all that makes us unique
View GitHub Profile
@LSinev
LSinev / pdfa_pdfx_test.tex
Last active September 5, 2022 00:16
PDF/A-1b and PDF/X-1a testing template. With different options set at start. Seems like PDF/A-1b is still not working with xelatex (because of font info). Inserting RGB images inside CMYK files (and in reverse order too) also breaks compliance :(
% Úτƒ-8 encoded
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Variables initiating %%%
\newcounter{colourmode}
\newcounter{pdftype}
\newcounter{iccinsert}
%% Control of colour mode and pdf type
\setcounter{colourmode}{1} % 0 --- undefined; 1 --- cmyk (always for pdf/x); 2 --- rgb
\setcounter{pdftype}{2} % 0 --- undefined; 1 --- pdf/x; 2 --- pdf/a
@ekalinin
ekalinin / linux.sh
Created January 9, 2017 06:17 — forked from marcan/linux.sh
Linux kernel initialization, translated to bash
#!/boot/bzImage
# Linux kernel userspace initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <marcan@marcan.st>
# Based on Linux 4.10-rc2.
# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
@leiless
leiless / check_in_container.sh
Last active February 19, 2023 13:14
Check if the script is running in the Docker/Podman/K8S
#!/bin/bash
# If you using sh, please remove the `-o pipefail`
set -eufo pipefail
#set -x
check_in_container() {
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ] && [ -z ${KUBERNETES_SERVICE_HOST+x} ]; then
echo "[ERR] This script should be run inside a container environment!"
exit 1
package main
import (
"context"
"fmt"
"net"
"os/exec"
"strconv"
"strings"
"sync"
#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root
@hivefans
hivefans / shell_output.go
Last active September 15, 2023 05:59
get the realtime output for a shell command in golang|-|{"files":{"shell_output.go":{"env":"plain"}},"tag":"bigdata"}
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"strings"
)
type Calculator struct {
ui.Node
Display string
}
func NewCalculator() *Calculator {
c := &Calculator{}
c.Build(c)
return c
}
@RickyCook
RickyCook / Command.md
Last active November 7, 2023 06:55
Using socat to forward new ports via STDIO in a running Docker container

What?... Why?

Imagine you're messing around in a container, and you install some stuff, add some config, and now it's time to load up your client and check it out! Oh wait, you forgot to forward ports when you created the container! Fear not, all is not lost, for in the world of pipes, and streams, there is always a way to do something disgusting.

The Dockerfile

Example Dockerfile included will install Nginx, and socat in a container, and make Nginx run in foreground mode. To build, and run:

@marcellodesales
marcellodesales / formatted.sh
Last active November 14, 2023 19:22
One-liner REST server using netcat - nc
rm -f out
mkfifo out
trap "rm -f out" EXIT
while true
do
cat out | nc -w1 -l 1500 > >( # parse the netcat output, to build the answer redirected to the pipe "out".
export REQUEST=
while read line
do
line=$(echo "$line" | tr -d '[\r\n]')
@sivel
sivel / inventory2json.py
Last active December 19, 2023 01:54
Ansible inventory to dynamic inventory JSON output, accepts all inventory input formats
import sys
import json
from ansible.parsing.dataloader import DataLoader
try:
from ansible.inventory.manager import InventoryManager
A24 = True
except ImportError:
from ansible.vars import VariableManager