Skip to content

Instantly share code, notes, and snippets.

@thearchitect
thearchitect / tmux.sh
Created November 2, 2019 13:53 — forked from B-Galati/tmux.sh
tmux script example
#!/bin/bash
tmux has-session -t dev
if [ $? != 0 ]
then
tmux new-session -s dev -n "TEST" -d
tmux split-window -h -t dev:0
tmux split-window -v -t dev:0.1
tmux send-keys -t dev:0.0 'cd ~/foo/bar' C-m
tmux send-keys -t dev:0.1 'autossh -M 0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" test@test -t "cd ~/bar;bash"' C-m

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@thearchitect
thearchitect / create-hotspot.md
Created October 21, 2018 13:09 — forked from gowrav/create-hotspot.md
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlx7cdd9046ee19 con-name AiRpaperHostspot autoconnect yes ssid AiRpaperHostspot
#Connection 'AiRpaperHostspot' (81bd8ff0-1473-4bda-b00d-5759cd1c3a27) successfully added.
nmcli con modify AiRpaperHostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify AiRpaperHostspot wifi-sec.key-mgmt none
@thearchitect
thearchitect / create-hotspot.md
Created October 21, 2018 13:09 — forked from narate/create-hotspot.md
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"
@thearchitect
thearchitect / scan.sh
Created October 21, 2018 13:09 — forked from kirkins/scan.sh
Second version of script to turn nmcli into a json object
#!/usr/bin/env bash
#
# Scan availible wifi networks
# https://unix.stackexchange.com/questions/399222/jq-parse-colon-separated-value-pairs
# TODO see if you can pipe this directly into jq
nmcli_output=$(nmcli --mode multiline dev wifi)
# set all variables from nmcli
network=$(echo "$nmcli_output" | grep SSID: \
@thearchitect
thearchitect / ffmpeg-cheatsheet.md
Created September 11, 2018 06:50 — forked from nickkraakman/ffmpeg-cheatsheet.md
FFmpeg cheat sheet for 360 video

FFmpeg Cheat Sheet for 360º video

Brought to you by Headjack

 
FFmpeg is one of the most powerful tools for video transcoding and manipulation, but it's fairly complex and confusing to use. That's why I decided to create this cheat sheet which shows some of the most often used commands.

 
Let's start with some basics:

  • ffmpeg calls the FFmpeg application in the command line window, could also be the full path to the FFmpeg binary or .exe file
{ config, lib, pkgs, ... }:
let
cfg = {
hostName = "zion";
ceph = {
enable = true;
publicIP = "127.0.0.1";
privateIP = "127.0.0.1";
# nixos-rebuild switch
building Nix...
building the system configuration...
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
# add this to configuration.nix
virtualisation = {
libvirtd = {
package main
import (
"bytes"
"fmt"
"os"
"strings"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
#include <opencv2/opencv.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <sstream>
#include <string>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>