Skip to content

Instantly share code, notes, and snippets.

@antoni
antoni / insert_image_on_pdf.rb
Created June 5, 2024 19:58 — forked from aashish/insert_image_on_pdf.rb
Insert image on a existing PDF having content with hexapdf gem
require 'hexapdf'
doc = HexaPDF::Document.open("/home/xxxx/Downloads/OoPdfFormExample.pdf")
page = doc.pages[0]
canvas = page.canvas(type: :overlay)
canvas.translate(0, 20) do
canvas.fill_color(0.3, 0.7, 0.7)
canvas.rectangle(50, 0, 80, 80, radius: 80)
@antoni
antoni / remove-all-from-docker.sh
Created June 22, 2022 10:21 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@antoni
antoni / getScrollableParent.js
Created June 8, 2022 21:31 — forked from twxia/getScrollableParent.js
Get Scrollable Parent
function getScrollParent(node) {
const isElement = node instanceof HTMLElement;
const overflowY = isElement && window.getComputedStyle(node).overflowY;
const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';
if (!node) {
return null;
} else if (isScrollable && node.scrollHeight >= node.clientHeight) {
return node;
}
@antoni
antoni / sbt-centos.md
Created May 27, 2022 10:22 — forked from diegopacheco/sbt-centos.md
Install Scala SBT on Amazon Linux | CentOS

Setup proxy

export https_proxy="https://my-proxy.com:443"
export http_proxy="https://my-proxy.com:80"

sudo vim /etc/yum.conf

add proxy on first line proxy=https://my-proxy.com:80

[main]
// Intended to be run on https://google.pl
function executeSearchTypingScript() {
const googleDomain = 'google.pl';
if (window.location.href.indexOf('google.pl') === -1) {
throw new Error(`This script should be run on ${googleDomain}`);
}
const searchInputField = document.querySelector('[aria-label=Szukaj]');
### Keybase proof
I hereby claim:
* I am antoni on github.
* I am antoni (https://keybase.io/antoni) on keybase.
* I have a public key ASAPlJzPyid_8vQoMmG2Dj5nzdugiKAYEtNIAJFGIA0AFgo
To claim this, I am signing this object:
@antoni
antoni / keybase.md
Created March 18, 2019 09:36 — forked from webframp/keybase.md
Signing git commits on github using keybase.io gpg key

Probably one of the easiest things you'll ever do with gpg

Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH

First get the public key

keybase pgp export | gpg --import

Next get the private key

@antoni
antoni / sudo-keepalive-example.sh
Created January 6, 2019 13:14 — forked from cowboy/sudo-keepalive-example.sh
Bash: Sudo keep-alive (good for long-running scripts that need sudo internally but shouldn't be run with sudo)
#!/bin/bash
# Might as well ask for password up-front, right?
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Example: do stuff over the next 30+ mins that requires sudo here or there.
function wait() {
#!/usr/bin/env bash
: ' Usage:
bash <(wget --quiet --output-document=- https://gist.githubusercontent.com/antoni/0baa816895d7155c7f41e155e2ee7f70/raw)
'
# Replaces $1 with $2 in the origin named 'origin' of Git repo
# Should be executed from inside of the repository folder
function replace_in_origin() {
### Keybase proof
I hereby claim:
* I am antoni on github.
* I am antoni (https://keybase.io/antoni) on keybase.
* I have a public key ASBjyuQy5Z1RKEScj1d1U_KBa_wNzjunfSWleyf_ITIoLAo
To claim this, I am signing this object: