Skip to content

Instantly share code, notes, and snippets.

@h0nza
h0nza / pagination_controller.js
Created December 30, 2021 17:08 — forked from dhh/pagination_controller.js
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>
@h0nza
h0nza / README-python-service-on-systemd-activated-socket.md
Created December 29, 2021 12:00 — forked from kylemanna/README-python-service-on-systemd-activated-socket.md
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at ~/tmp/foo/serve.py.

@h0nza
h0nza / initial-bash-history-on-wedos-vm.txt
Created September 23, 2021 21:47 — forked from jhrcz/initial-bash-history-on-wedos-vm.txt
initial-bash-history-on-wedos-vm
vim /etc/ssh/sshd_config
vi /etc/ssh/sshd_config
getenforce
vim /etc/selinux/config
vi /etc/selinux/config
sed '/^SELINUX=/ s/=.*/=disabled/' /etc/selinux/config
sed -i '/^SELINUX=/ s/=.*/=disabled/' /etc/selinux/config
yum updae
yum update
.%%...%%..%%%%%%..%%%%%....%%%%....%%%%..
@h0nza
h0nza / sussh
Created May 27, 2021 10:03 — forked from grugnog/sussh
Simple expect script to get an interactive root shell using a password from the Lastpass "lpass" tool. Assumes a ssh public key authentication. This allows usage of long, secure passwords to sudo whilst avoiding copy-paste (risky) and passing credentials as command line options (insecure).
#!/usr/bin/expect
set timeout 600
set lpass [lindex $argv 0]
set arguments [lrange $argv 1 end]
if {$lpass eq "" || $arguments eq ""} {
puts "sussh: Login to interactive root shell using sudo password from lpass."
puts "The credential is sent via expect, not via any command line option.\n"
puts "Usage: sussh <lpass-key> <ssh-args ...>"
puts " lpass-key: Suffix of a lpass record with the prefix 'ssh-'"
puts " ssh-args: username, hostname, port, alias or other ssh options\n"
@h0nza
h0nza / c2md.xsl
Created May 27, 2021 10:01 — forked from grugnog/c2md.xsl
Converts Confluence multi-page XML export into a Markdown Git repository retaining most formatting, links and version history
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ac="http://www.atlassian.com/schema/confluence/4/ac/"
xmlns:ri="http://www.atlassian.com/schema/confluence/4/ri/"
xmlns:acxhtml="http://www.atlassian.com/schema/confluence/4/"
xmlns:lookup="http://www.fundi.com.au/">
<!--
Original sources/credit:
@h0nza
h0nza / nix-pwsh-cheatsheet.md
Created April 18, 2020 18:23 — forked from jpierson/nix-pwsh-cheatsheet.md
Unix/Linux to Powershell Command Cheatsheet

Unix/Linux to Powershell Command Cheatsheet

This guide aims to document useful commands that I commonly see used in Linux and Unix environments to their closest equivalent in Powershell.

Command: wc

Use: Counts some aspect of the input stream and returns a summarized value as output.

Windows to UNIX Command Cheat Sheet

Windows PowerShell has several transition aliases that allow UNIX and CMD users to use familiar command names in Windows PowerShell. The most common aliases are shown in the table below, along with the Windows PowerShell command behind the alias and the standard Windows PowerShell alias if one exists.

CMD Command UNIX Command PowerShell Command PowerShell Alias
dir ls Get-ChildItem gci
@h0nza
h0nza / openssl.MD
Created April 14, 2020 22:23 — forked from jchandra74/openssl.MD
HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

Overview

My main development workstation is a Windows 10 machine, so we'll approach this from that viewpoint.

Recently, Google Chrome started giving me a warning when I open a site that uses https and self-signed certificate on my local development machine due to some SSL certificate issues like the one below:

Self-Signed SSL Issue in Chrome

@h0nza
h0nza / select2-cascade.js
Created January 9, 2020 13:55 — forked from ajaxray/ select2-cascade.js
Making Select2 (4.x) list boxes cascading / dependent. Options of a select2 list box will be loaded/refreshed by ajax based on selection of another select2 list box.
/**
* A Javascript module to loadeding/refreshing options of a select2 list box using ajax based on selection of another select2 list box.
*
* @url : https://gist.github.com/ajaxray/187e7c9a00666a7ffff52a8a69b8bf31
* @auther : Anis Uddin Ahmad <anis.programmer@gmail.com>
*
* Live demo - https://codepen.io/ajaxray/full/oBPbQe/
* w: http://ajaxray.com | t: @ajaxray
*/
var Select2Cascade = ( function(window, $) {
@h0nza
h0nza / private_fork.md
Created December 14, 2019 15:49 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git