Skip to content

Instantly share code, notes, and snippets.

View Xenthys's full-sized avatar
💻
Site Reliability Engineer

Dylan Ysmal Xenthys

💻
Site Reliability Engineer
View GitHub Profile
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@habnabit
habnabit / chatserver.py
Created September 29, 2012 20:10
one expression chatserver
main = lambda port: (lambda dt: (lambda mm: (lambda n: (map(lambda r: (lambda
rr: setattr(n, *rr) if (type(rr) is tuple and len(rr) == 2) else None)(r()),
[lambda: map(setattr, *zip(*[(n, m, __import__(m)) for m in mm.m.decode('ba'
'se64').split()])), lambda: map(n.s['signal.signal'], (n.s['signal.SIGINT'],
n.s['signal.SIGTERM']), [lambda s, f: (n.s['sys.exit']() if n.f else [n.sa(
mm.l[0], n.o)] and n.u('f', True) or n.fc(n.l))] * 2), lambda: setattr(mm,
'l', mm.l.decode('base64').split('~~~')), lambda: ('sw', n.s['types.Functio'
'nType'] (compile("try:\n\tv = n.select.select(n.so, n.w(), [])\nexcept n.s"
"elect.error, e:\n\tif e[0] != n.errno.EINTR: raise\nelse:\n\tn.u('sr', v)",
'', 'exec'), dict(n=n, OSError=OSError))),lambda: ('l', n.s['socket.socket']
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active April 30, 2024 23:36
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@taniarascia
taniarascia / index.html
Last active April 3, 2024 21:05
HTML Skeleton file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="author" content="">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
@joepie91
joepie91 / monolithic-vs-modular.md
Last active August 2, 2023 08:17
Monolithic vs. modular - what's the difference?

When you're developing in Node.js, you're likely to run into these terms - "monolithic" and "modular". They're usually used to describe the different types of frameworks and libraries; not just HTTP frameworks, but modules in general.

At a glance

  • Monolithic: "Batteries-included" and typically tightly coupled, it tries to include all the stuff that's needed for common usecases. An example of a monolithic web framework would be Sails.js.
  • Modular: "Minimal" and loosely coupled. Only includes the bare minimum of functionality and structure, and the rest is a plugin. Fundamentally, it generally only has a single 'responsibility'. An example of a modular web framework would be Express.

Coupled?

In software development, the terms "tightly coupled" and "loosely coupled" are used to indicate how much components rely on each other; or more specifically, how many assumptions they make about each other. This directly translates to how easy it is to repla

@Polsaker
Polsaker / img2irc.py
Last active April 13, 2022 21:36
Makes beautiful ART from regular, boring images.
#!/usr/bin/env python3
# MIT License.
# Copyright (c) 2016 Ramiro Bou (Polsaker)
# 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
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@Zoddo
Zoddo / gist:6407aabed53f03ef3ecfa04bbbd062d8
Last active October 2, 2016 02:16
AntiNoisyBot commands
All commands must be sent in the control-channel, prefixed with "!" or in another channel, prefixed with "AntiNoisyBot: ".
ping [<string>]
Reply "pong <string>"
monitor #<channel> [report_only] Restrict to flag "a"
Adds the channel to the list of monitored channel. If report_only is used, the bot will only
report detections on the control-channel.
@azlux
azlux / Warning_IPTABLES.md
Last active March 7, 2022 11:08
Sécurité avec iptables et l'option RELATED

Problème d'ouvertue de port non désirée sur une configuration IPTABLES

Un problème de contournement des règles iptables fixées par utilisateur peut survenir avec l’utilisation de règles iptables RELATED,ESTABLISH trop générique et le chargement de helper de service non présent ou non utilisé sur la machine (exemple FTP actif, SIP, IRC …).

True fact: Mon server MariaDB s'est fait attaqué comme ça alors que le port dans l'iptable n'était pas ouvert.


Menu

  1. Rappel
@Zoddo
Zoddo / 1_pf_identd_proxy.php
Last active October 29, 2016 20:22
A script to proxy identd requests to hosts NAT'd with PF (Packet Filter) on FreeBSD (for pfSense for example)
<?php
const MAX_PORT = 65535;
const REGEX_V4 = '#^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})$#';
const REGEX_V6 = '#^([0-9a-f:])\[(\d{1,5})\]$#';
// Listen TCP port 113
$srv = socket_create_listen(113);
if (!$srv) {
echo "Unable to bind the server on port 113: " . socket_strerror(socket_last_error()) . "\n";
@smoser
smoser / README.md
Last active March 29, 2024 07:19
set up a ssh tunnel only user for ssh proxy jump

Set up a ssh tunnel only user

In order to give someone access to hosts that are available only by ssh "bouncing" (ProxyJump), add a user for this specific purpose.

We have an internal openstack where instances get IPs on per-tenant networks. Each tenant has a 'bastion' host that has a "public" ip (floating ip). You can access other instances by bouncing through the bastion. From time to time I want to let someone else into an instance. This could be done either with:

a.) just give them shell access to the bastion and let them hop through. Sharing an unrestricted shell account on my bastion is less than ideal. b.) assign a floating/"public" IP to the instance so they could go directly in. Floating IPs are limited, so this is less than ideal.

So instead, I have set up a single user as described here that can only be used for ProxyJump. It allows others proxied access to my instances but without granting them full shell access.