Skip to content

Instantly share code, notes, and snippets.

@kizzx2
kizzx2 / docker-compose.yml
Last active April 18, 2024 10:47
Restart a docker container periodically with docker-compose
version: '3'
services:
app:
image: nginx:alpine
ports: ["80:80"]
restart: unless-stopped
restarter:
image: docker:cli
volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
@kizzx2
kizzx2 / tmux-sync.sh
Last active April 11, 2024 14:33
Run multiple commands, and open them all in synchronized tmux panes
#!/bin/sh
#
# The MIT License (MIT)
#
# Copyright (c) 2013 Chris Yuen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@kizzx2
kizzx2 / with-env.ps1
Last active December 3, 2023 23:06
Run command with environment variables in PowerShell
$ori = @{}
Try {
$i = 0
# Loading .env files
if(Test-Path $args[0]) {
foreach($line in (Get-Content $args[0])) {
if($line -Match '^\s*$' -Or $line -Match '^#') {
continue
}
@kizzx2
kizzx2 / scan.bash
Last active November 14, 2023 03:17
Bash one line port scanner using nc
# Creates 993 nc processes. Returns in about 1 minute max
ip=127.0.0.1
b(){ for i in {0..992};do nc $ip -w1 -vz $((i*66+1))-$((i*66+66>65535?65535:i*66+66)) 2>&1|egrep 'open|succeed'&done;wait;} 2>/dev/null;b
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialicons/v140/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
{
"name": "Ref",
"timestamp": "2022-10-19T11:12:47.433Z",
"version": {
"major": 1,
"minor": 0,
"patch": 0
},
"tags": {},
"tokens": [
@kizzx2
kizzx2 / hammerspoon-move-resize.lua
Last active December 19, 2022 06:47
Hammerspoon script to move/resize window under cursor
-- Inspired by Linux alt-drag or Better Touch Tools move/resize functionality
function get_window_under_mouse()
-- Invoke `hs.application` because `hs.window.orderedWindows()` doesn't do it
-- and breaks itself
local _ = hs.application
local my_pos = hs.geometry.new(hs.mouse.getAbsolutePosition())
local my_screen = hs.mouse.getCurrentScreen()
@kizzx2
kizzx2 / fun.cpp
Created January 11, 2012 14:29
Illustrative C++ Lua binding example/tutorial
// fun.cpp
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <iostream>
@kizzx2
kizzx2 / commitlint.vim
Created March 7, 2018 08:17
ALE Linter for commitlint
function! ale_linters#gitcommit#commitlint#Handle(buffer, lines) abort
" Matches patterns line the following:
let l:pattern = '^\(✖\|⚠\)\s\+\(.*\) \(\[.*\]\)$'
let l:output = []
let l:line = getline(1)
if l:line[0] != '#'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': 1,
@kizzx2
kizzx2 / fun.cpp
Last active March 29, 2022 04:12
Illustrative C++ Lua binding example/tutorial
// fun.cpp
// This is for Lua 5.2, for Lua 5.1, see https://gist.github.com/kizzx2/1594905
#include <lua.hpp>
#include <iostream>
#include <sstream>
class Foo
{