Skip to content

Instantly share code, notes, and snippets.

View denishacks's full-sized avatar

Denis Barsukov denishacks

View GitHub Profile
{
"specversion" : "1.0",
"type" : "com.github.pull.create",
"source" : "/cloudevents/spec/pull",
"subject" : "123",
"id" : "A234-1234-1234",
"time" : "2018-04-05T17:31:00Z",
"comexampleextension1" : "value",
"comexampleothervalue" : 5,
"datacontenttype" : "text/xml",
@denishacks
denishacks / README.md
Created March 31, 2024 13:09 — forked from lcrilly/README.md
Prometheus exporter for NGINX Unit metrics

Prometheus exporter for NGINX Unit metrics

The NGINX Unit control API includes a /status endpoint for usage statistics. This is a solution for exposing these metrics in Prometheus format.

The application (run by Unit) queries the /status URI on the control socket and converts the JSON response into Prometheus text format. PHP and Python implementations are available.

These instructions assume an existing Unit installation with a working configuration. We will add a new listener on the default prometheus port (9090) and route it directly to the Prometheus app.

Step 0. Install the preferred Unit language module (unit-php or unit-python)

@denishacks
denishacks / inmemory-webpack-compiler.js
Created April 4, 2021 13:19 — forked from kisenka/inmemory-webpack-compiler.js
Webpack in-memory filesystem
var webpack = require('webpack');
var MemoryFS = require('memory-fs');
var SingleEntryDependency = require('webpack/lib/dependencies/SingleEntryDependency');
var fs = new MemoryFS();
fs.mkdirpSync('/src');
fs.writeFileSync('/src/app.js', 'require("./dep.js")', 'utf-8');
fs.writeFileSync('/src/dep.js', 'module.exports = function(msg){console.log(msg)}', 'utf-8');
fs.writeFileSync('/src/extra-entry.js', 'require("./dep.js")', 'utf-8');
@denishacks
denishacks / parallels-tools.sh
Last active March 29, 2020 18:05
How to install Parallels Tools (Parallels 15) on CentOS 7
sudo yum install -y epel-release
sudo yum install -y dkms
rpm -Uvhi ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/7.0/x86_64/updates/security/kernel-devel-3.10.0-957.el7.x86_64.rpm
sudo mkdir /mnt/media
sudo mount /dev/cdrom /mnt/media
cd /mnt/media
sudo ./install

Npm has a lot of commands, lets make a cheat sheet!

Community Features

  • adduser (alias: add-user | login)

    Create or Login into the npm server.

npm adduser

@denishacks
denishacks / app.jsx
Created March 25, 2019 09:33
Segmented auto-moving input (one-time-password)
const Digit = ({onFocus, onKeyUp}) => {
return (
<input onFocus={onFocus}
onKeyUp={onKeyUp}
style={{
display: 'inline-block',
marginLeft: '20px',
width: '40px',
height: '40px',
fontSize: 32,
@denishacks
denishacks / postgres_queries_and_commands.sql
Created July 15, 2018 15:33 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@denishacks
denishacks / IDNAConvert.php
Last active August 29, 2015 14:16
The class internationalized domain names (see RFC 3490, 3491, 3492 and 3454 for detials) as they can be used with various registries worldwide to be translated between their original (localized) form and their encoded form as it will be used in the DNS (Domain Name System).
<?php
// {{{ license
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
//
// +----------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU Lesser General Public License as |
// | published by the Free Software Foundation; either version 2.1 of the |
// | License, or (at your option) any later version. |