Skip to content

Instantly share code, notes, and snippets.

un1ko85 / get_posts_cached.php
Created July 4, 2013 11:27
Wrapper around get_posts that utilizes object caching
* Wrapper around get_posts that utilizes object caching
* @access public
* @param mixed $args (default: NUL)
* @param bool $force_refresh (default: false)
* @return void
function get_posts_cached( $args = NULL, $force_refresh = false ) {
$cache_incrementor = wp_cache_get( 'get_posts_cached', 'cache_incrementors' );
un1ko85 / nginx.conf
Created January 6, 2016 08:01
Rewrite URI with nginx and php-fpm. I have faced the problem that REQUEST_URI parameter is not changed on nginx rewrite rule. After some research I have found solution with replacing $request_uri variable.
server {
listen 80;
index index.php;
root /Users/balkon_smoke/Sites/;
error_log /Users/balkon_smoke/Sites/;
access_log /Users/balkon_smoke/Sites/;
location / {
un1ko85 / pnorm.sql
Created July 28, 2022 13:08 — forked from olooney/pnorm.sql
PostgreSQL pnorm() function calculated the c.d.f. of the normal Gaussian distribution. This function match's R's build in pnorm() function to within +/- 2e-7 over the entire real line. However, it's a constant 1/0 above/below z=+7/-7.
CREATE OR REPLACE FUNCTION pnorm(z double precision) RETURNS double precision AS $$
WHEN $1 >= 0 THEN 1 - POWER(((((((0.000005383*$1+0.0000488906)*$1+0.0000380036)*$1+0.0032776263)*$1+0.0211410061)*$1+0.049867347)*$1+1),-16)/2
ELSE 1 - pnorm(-$1)
un1ko85 /
Created June 1, 2022 14:57 — forked from eliasdabbas/
Create a heatmap of SERPs, using a table with columns: "keyword", "rank", and "domain"
import plotly.graph_objects as go
import pandas as pd
def serp_heatmap(df, num_domains=10, select_domain=None):
df = df.rename(columns={'domain': 'displayLink',
'searchTerms': 'keyword'})
top_domains = df['displayLink'].value_counts()[:num_domains].index.tolist()
top_domains = df['displayLink'].value_counts()[:num_domains].index.tolist()
top_df = df[df['displayLink'].isin(top_domains) & df['displayLink'].ne('')]
un1ko85 / pf.conf
Created May 21, 2017 07:34
pf.conf freebsd kiev server
#### First declare a couple of variables ####
### Outgoing tcp / udp port ####
### 43 - whois, 22 - ssh ###
tcp_services = "{ ssh, smtp, domain, www, https, 22, ntp, 43, 587}"
udp_services = "{ domain, ntp }"
### allow ping / pong ####
icmp_types = "{ echoreq, unreach }"
### Allow IP
enabled_ip = "{,, }"
un1ko85 /
Created August 29, 2020 09:58 — forked from NiceGuyIT/
nginx JSON to Filebeat to Logstash to Elasticsearch


This is an example configuration to have nginx output JSON logs to make it easier for Logstash processing. I was trying to get nginx > Filebeat > Logstash > ES working and it wasn't until I connected Filebeat directly to Elasticsearch that I saw the expected data. Google led me to and I realized filebeat setup works for Filebeat > ES but not Filebeat > Logstash > ES. This is because Logstash does not use ingest pipelines by default. You have to enable them in the elasticsearch output block.

Having nginx log JSON in the format required for Elasticsearch means there's very little processing (i.e. grok) to be done in Logstash. nginx can only output JSON for access logs; the error_log format cannot be changed.

Extra fields are output and not used by the Kibana dashboards. I included them in case they might be useful. Since they are not declared in the filebeat setup, their default is "string" when yo

un1ko85 / docker-compose.yml
Created August 29, 2020 09:57 — forked from axw/docker-compose.yml
Docker Compose with Elastic Stack and APM Server 6.5.0
version: "2.1"
- "${APM_SERVER_PORT:-8200}:8200"
- "${APM_SERVER_MONITOR_PORT:-6060}:6060"
command: >
apm-server -e
-E apm-server.rum.enabled=true
-- Продажи товаров с атрибутами
orders.created_at AS created_at,,
-- Категории
SELECT string_agg(c.title, ' / ')
FROM hm_taxonomies_category_product c_p
JOIN hm_taxonomies_categories c ON c_p.category_id =
WHERE c_p.product_id = -- todo: order
-- Сравнение продаж текущий год с предыдущим
-- Категории
SELECT string_agg(c.title, ' / ')
FROM hm_taxonomies_category_product c_p
JOIN hm_taxonomies_categories c ON c_p.category_id =
WHERE c_p.product_id = s.product_id -- todo: order
) AS categories,
un1ko85 /
Created April 23, 2020 15:41 — forked from mosquito/
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service

Description=%i service with docker compose