Skip to content

Instantly share code, notes, and snippets.

View skateman's full-sized avatar

Halász Dávid skateman

View GitHub Profile
@skateman
skateman / post-checkout
Created June 24, 2023 14:30
Git hook that detects Gemfile.lock changes
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m' # No Color
MESSAGE="${RED}Changes detected in the Gemfile.lock, consider rebuilding your container image.${NC}"
if [[ $3 == 1 ]]; then
git diff --quiet $1 $2 -- Gemfile.lock || echo -e $MESSAGE
fi;
@skateman
skateman / pc.sh
Created January 29, 2022 14:01
podman-compose shorthand with support for podman-attach
#!/bin/bash
case $1 in
attach)
podman attach $(podman-compose ps | grep _$2_ | cut -d " " -f 1)
;;
*)
podman-compose $@
;;
esac
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
from subprocess import call
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)
while True:
i = GPIO.input(11)
@skateman
skateman / config.ru
Created December 15, 2018 19:28
Cockpit reverse-proxy written in Ruby
require 'surro-gate'
require 'websocket/driver'
require 'rack/reverse_proxy'
require 'permessage_deflate'
class WSRack
attr_reader :env, :url
def initialize(env, sock)
@env = env
path = File.join(ManageIQ::UI::Classic.root, 'app', 'assets', 'images', '100', '*.png')
pngs = Dir.glob(path).map { |f| File.basename(f, '.png') }
Rails.application.eager_load!
models = ApplicationRecord.descendants.reject { |m| m.decorate && (m.decorate.fonticon || m.decorate.fileicon) }.reject do |m|
ret = nil
# Some records aren't that easy to create
begin
record = m.new
ret = record.decorate && (record.decorate.fonticon || record.decorate.fileicon)
$('#submissionInstructionsHeader').remove();
$('#FwkErrorBeanId').remove();
$('#PreHeaderLayout').remove();
$('#DefaultFormName > table').remove();
$('#LLAOutput').remove();
$('#ConfirmationPgStackLayout tbody').children[1].remove();
#!/bin/env ruby
# Script to approve a GitHub PR from the command line
#
# Usage: ./approve.rb <repo> <PR>
# For auth configuration see: https://github.com/octokit/octokit.rb#using-a-netrc-file
require 'octokit'
require 'netrc'
@skateman
skateman / agents.rb
Last active February 10, 2017 09:49
List of Czechoslovak agents operating between 1975-1989 in Western-Slovakia
require 'json'
require 'nokogiri'
require 'open-uri'
BASE = 'http://www.upn.gov.sk'.freeze
url = "#{BASE}/utvary-stb-a-ps-na-slovensku/zoznam-osob.php?pismeno=".freeze
agents = []
# Separate page for each letter
package semaphore
import "sync"
type Semaphore struct {
Channel chan uint
Mutex sync.Mutex
}
func New(size uint) *Semaphore {
@skateman
skateman / gifcast
Last active December 13, 2017 13:43
#!/bin/sh
# gifcast - easily create gif screencasts from a selected area
#
# The first run lets you select a rectangle and starts recording while the second run stops the recording.
# Tested on Fedora 24 with GNOME
# Dependencies: xrectsel, byzanz, convert (ImageMagick)
FILE="/run/user/${UID}/$(basename $0).pid"