Skip to content

Instantly share code, notes, and snippets.

View frontdevops's full-sized avatar
:octocat:
Develop 𝔾𝕖𝕖𝕜𝕁𝕆𝔹

Sasha Majorović frontdevops

:octocat:
Develop 𝔾𝕖𝕖𝕜𝕁𝕆𝔹
View GitHub Profile
import builtins
import inspect
from enum import Enum
class VarType(Enum):
DICT = 1
LIST = 2
OBJECT = 3
FUNCTION = 4
#!/usr/bin/env python
import sys
import pathlib
import tomllib
from setuptools import find_packages, setup
WORK_DIR = pathlib.Path(__file__).parent
# Check python version
MINIMAL_PY_VERSION = (3, 10, 8)
static PyObject *
BaseException_add_note(PyObject *self, PyObject *note)
{
if (!PyUnicode_Check(note)) {
PyErr_Format(PyExc_TypeError,
"note must be a str, not '%s'",
Py_TYPE(note)->tp_name);
return NULL;
}
import sys
import builtins
class Exception311(BaseException):
"""
This is a fallback for exception behavior like in python 3.11
"""
__notes__ = []
'use strict';
module.exports = leftPad;
var cache = [
'',
' ',
' ',
' ',
' ',
' ',
#!/usr/bin/env bash
${1:?"Set file for editing or type --help for help"}
if [ "$1" = "--help" ]
then
cat <<EOF
Usage:
edit file.name
@frontdevops
frontdevops / darkthemeswitcher-inline.js
Last active December 20, 2022 12:51
Simple Dark Theme Bookmarklet for web pages
javascript:(d=>{var css=`:root{background-color:#fefefe;filter:invert(100%)}*{background-color:inherit}img:not([src*=".svg"]),video{filter: invert(100%)}`,style,id="dark-theme-snippet",ee=d.getElementById(id);if(null!=ee)ee.parentNode.removeChild(ee);else {style = d.createElement('style');style.type="text/css";style.id=id;if(style.styleSheet)style.styleSheet.cssText=css;else style.appendChild(d.createTextNode(css));(d.head||d.querySelector('head')).appendChild(style)}})(document)
let singleton = Symbol();
let singletonEnforcer = Symbol();
class Singleton {
constructor(enforcer) {
if (enforcer !== singletonEnforcer)
throw "Instantiation failed: use Singleton.getInstance() instead of new.";
// код конструктора
(function(g){
/** @type {SingletonConstructor} */
var instance;
g.Singleton = function() {
if (instance !== void 0) return instance;
return instance = this;
};
g.Singleton.prototype.foo = 123;
})(window||global);
class Instance {
constructor(public foo: number = 123) {}
}
let instance = new Instance;
export function getInstance() :Instance {
return instance;
}