Skip to content

Instantly share code, notes, and snippets.

View Floofies's full-sized avatar
🧩
Looking for a job

Dani Glore Floofies

🧩
Looking for a job
View GitHub Profile
@Floofies
Floofies / bits.js
Last active January 18, 2023 17:30
A collection of small utility functions I have written over the years. Will receive updates.
/* Table Of Contents:
GeneratorFunction
The GeneratorFunction constructor, exposed.
isSetIterator
Returns true if the object is a bultin Set Iterator.
isMapIterator
Returns true if the object is a builtin Map Iterator.
iterableObject
Make a regular Object an iterable.
get
@drmalex07
drmalex07 / README-setup-socket-activated-systemd-service.md
Last active December 26, 2023 05:13
An example inetd-like socket-activated service. #systemd #inetd #systemd.socket

README

This is an example of a socket-activated per-connection service (which is usually referred to as inetd-like service). A thorough explanation can be found at http://0pointer.de/blog/projects/inetd.html.

Define a socket unit

The key point here is to specify Accept=yes, which will make the socket accept connections (behaving like inetd) and pass only the resulting connection socket to the service handler.

@drmalex07
drmalex07 / README-python-service-on-systemd-activated-socket.md
Last active January 13, 2024 12:53
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 /opt/foo/serve.py.

@nimasdj
nimasdj / MimeTypes.php
Last active April 2, 2023 22:21
List of MimeTypes mapped to file extensions
<?php
// I made this array by joining all the following lists + .php extension which is missing in all of them.
// please contribute to this list to make it as accurate and complete as possible.
// https://gist.github.com/plasticbrain/3887245
// http://pastie.org/5668002
// http://pastebin.com/iuTy6K6d
// total: 1223 extensions as of 16 November 2015
$mime_types = array(
'3dm' => array('x-world/x-3dmf'),
'3dmf' => array('x-world/x-3dmf'),
@netgusto
netgusto / pegjs-htmlish.peg
Last active April 26, 2024 08:04
PEG.js grammar for parsing simple HTML-ish balanced markup language - use it on http://pegjs.majda.cz/online
Content = (DocType / Comment / BalancedTag / SelfClosingTag / Text)*
DocType = "<!doctype " doctype:[^>]* ">" {
return {
type: 'DocType',
content: doctype.join('')
};
}
Comment = "<!--" c:(!"-->" c:. {return c})* "-->" {
@Twisol
Twisol / gist:4526419
Last active April 24, 2017 18:54
Proof of concept of a trampoline-based promise resolver. This ensures that all promise chains take up the same base amount of stack space.
function nextTick(f) {
setTimeout(function() {
console.log('tick');
f();
});
}
// Minimal amount of Promise groundwork necessary for a proof of concept.
function Promise(then) {
this.then = then;
@bobspace
bobspace / css_colors.js
Last active May 17, 2024 03:10
All of the CSS Color names in a big javascript object.
// CSS Color Names
// Compiled by @bobspace.
//
// A javascript object containing all of the color names listed in the CSS Spec.
// This used to be a big array, but the hex values are useful too, so now it's an object.
// If you need the names as an array use Object.keys, but you already knew that!
//
// The full list can be found here: https://www.w3schools.com/cssref/css_colors.asp
// Use it as you please, 'cuz you can't, like, own a color, man.