Skip to content

Instantly share code, notes, and snippets.

View peter-hank's full-sized avatar

Peter Hankiewicz peter-hank

  • Harvard University
  • Cyberspace
View GitHub Profile
@peter-hank
peter-hank / postgres_queries_and_commands.sql
Last active January 25, 2022 16:53 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), 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(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@peter-hank
peter-hank / inotifyexec.py
Created November 1, 2017 20:17 — forked from wernight/inotifyexec.py
inotifywait helper that executes a command on file change (for Linux, put it in ~/bin/)
#!/usr/bin/env python
"""Use inotify to watch a directory and execute a command on file change.
Watch for any file change below current directory (using inotify via pyinotify)
and execute the given command on file change.
Just using inotify-tools `while inotifywait -r -e close_write .; do something; done`
has many issues which are fixed by this tools:
* If your editor creates a backup before writing the file, it'll trigger multiple times.
* If your directory structure is deep, it'll have to reinitialize inotify after each change.
@peter-hank
peter-hank / gist:4049962c8ccd3abefa42e58bdd4a5266
Created January 10, 2018 08:26
Reddit multi-upvote for Greasemonkey
// ==UserScript==
// @name Reddit multi-upvote
// @description Upvotes submissions and comments
// @include https://www.reddit.com/r/url1*
// @include https://www.reddit.com/r/url2*
// @version 1
// @grant none
// ==/UserScript==
// submissions only
/etc/php/7.0/fpm/conf.d/10-mysqlnd.ini,
/etc/php/7.0/fpm/conf.d/10-opcache.ini,
/etc/php/7.0/fpm/conf.d/10-pdo.ini,
/etc/php/7.0/fpm/conf.d/15-xml.ini,
/etc/php/7.0/fpm/conf.d/20-apcu.ini,
/etc/php/7.0/fpm/conf.d/20-calendar.ini,
/etc/php/7.0/fpm/conf.d/20-ctype.ini,
/etc/php/7.0/fpm/conf.d/20-curl.ini,
/etc/php/7.0/fpm/conf.d/20-dom.ini,
/etc/php/7.0/fpm/conf.d/20-exif.ini,
@peter-hank
peter-hank / sync_json.html
Created February 9, 2017 14:25
Sync JSON loading
<html>
<head>
<script>
function loadTextFileAjaxSync(filePath, mimeType) {
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",filePath,false);
if (mimeType != null) {
if (xmlhttp.overrideMimeType) {
xmlhttp.overrideMimeType(mimeType);
}
@peter-hank
peter-hank / Collection.php
Created January 5, 2016 19:13
Sort product attribute options by the position property in Magento (app/code/local/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php)
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@peter-hank
peter-hank / magento-1.9-patch-sorted-attribue-options
Created January 5, 2016 19:20
Sort product attribute options by the position property in Magento patch
From 7423c3fd53926f4e8dac9ab9a4b4f65b94eaa7f7 Mon Sep 17 00:00:00 2001
From: peter-hank <peter.hankiewicz@gmail.com>
Date: Tue, 5 Jan 2016 20:11:19 +0100
Subject: [PATCH] Update Collection.php
---
.../Product/Type/Configurable/Attribute/Collection.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php