Skip to content

Instantly share code, notes, and snippets.

@vpetrigo
vpetrigo / ltree_to_nested.sql
Last active July 18, 2023 04:35
Generate nested set structure from PostgreSQL ltree structure
CREATE VIEW anc_and_des AS
SELECT
m.*,
-- Count all descendats of a vertice
( SELECT COUNT(*)
FROM KeywordLtree AS d
WHERE m.path @> d.path
) AS descendants,
-- Count all ancestors of a vertice
( SELECT COUNT(*)
@that0n3guy
that0n3guy / gist:905c812c0f65e7ffb5ec
Last active April 5, 2025 12:46
Mautic nginx config
server {
# see: http://wiki.nginx.org/Pitfalls
# see: http://wiki.nginx.org/IfIsEvil
listen 80;
root /app;
index index.html index.htm index.php;
error_page 404 /index.php;
# Make site accessible from http://set-ip-address.xip.io
@escopecz
escopecz / commands.php
Last active April 18, 2023 22:43 — forked from alanhartless/cron.php
Script to run Mautic (https://mautic.org) commands from a URL.
<?php
if (!isset($_GET['ILoveMauticReallyIDo'])) {
echo 'The secret phrase is wrong.';
die;
}
$link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$allowedTasks = array(
'cache:clear',
@gesellix
gesellix / ExampleMetricsService.groovy
Last active December 16, 2015 12:49
A Spring PublicMetrics ExpositionHook for Prometheus
package de.gesellix.example
import com.matttproud.accepts.Accept
import com.matttproud.accepts.Parser
import io.prometheus.client.Prometheus
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
@gjuric
gjuric / nginx-proxy-geoip
Created May 7, 2015 15:26
nginx - pass GEOIP headers to proxy host
# http block
geoip_city /usr/local/share/GeoIP/GeoIPCity.dat;
geoip_country /usr/local/share/GeoIP/GeoIPCountry.dat;
# location block
proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3;
proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name;
@lonelycode
lonelycode / tyk_quickstart.sh
Last active December 28, 2022 14:52
Tyk Demo Setup Script
#! /bin/bash
# This script will set up a full tyk environment on your machine
# and also create a demo user for you with one command
# USAGE
# -----
#
# $> ./tyk_quickstart.sh {IP ADDRESS OF DOCKER VM}
kind: List
apiVersion: v1beta3
items:
- kind: ReplicationController
apiVersion: v1beta3
@zxbodya
zxbodya / render-react-with-rxjs.md
Last active November 1, 2021 08:49
React with RxJS, reactive way :)

Observable React elements with RxJS

Note: if you want to skip history behind this, and just looking for final result see: rx-react-container

When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.

But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...

Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.

@gregsh
gregsh / - IDE Scripting.md
Last active March 28, 2025 20:16
IDE Scripting

Here are my attempts to script an IntelliJ-based IDE using javax.script.* API (ex-JSR-223).

The list of available scripting languages and engines:

  1. Groovy - built-in, via Groovy jars and <app>/lib/groovy-jsr223-xxx.jar
  2. JavaScript (Nashorn) - built-in, via Java Runtime <app>/jbr/... (deprecated and will be removed soon)
  3. JavaScript (GraalJS) - https://plugins.jetbrains.com/plugin/12548-intellij-scripting-javascript
  4. JPython - https://plugins.jetbrains.com/plugin/12471-intellij-scripting-python
  5. JRuby - https://plugins.jetbrains.com/plugin/12549-intellij-scripting-ruby
  6. Clojure - https://plugins.jetbrains.com/plugin/12469-intellij-scripting-clojure
#!/bin/bash
JQPATH=$(which jq)
if [ "x$JQPATH" == "x" ]; then
echo "Couldn't find jq executable." 1>&2
exit 2
fi
set -eu
shopt -s nullglob