Skip to content

Instantly share code, notes, and snippets.

with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
@Mikulas
Mikulas / gist:a5b95be4e4858c63b332
Last active December 3, 2018 11:15
PostgreSQL UTF-8 to ASCII folding and webalize
CREATE EXTENSION unaccent;
CREATE OR REPLACE FUNCTION webalize(varchar) RETURNS text AS $$
SELECT trim(both '-' from regexp_replace(lower(unaccent($1)), '[^a-z0-9]+', '-', 'g'));
$$ LANGUAGE SQL;
SELECT unaccent('Příliš žlutý kůň 91. stupeň!');
-- Prilis zluty kun 91. stupen!
SELECT webalize('Příliš žlutý kůň 91. stupeň!');
error_log syslog:server=unix:/var/log/nginx.sock;
http {
log_format verbose '$remote_addr - $remote_user $host "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
map $status $loggable {
~^[2] 0;
default 1;
}
@roryokane
roryokane / 1 – myers (default) algorithm.diff
Last active January 31, 2025 15:52
Comparison between Git diff algorithms: myers (default) vs. patience (example favors myers)
diff --git a/file.txt b/file.txt
index 3299d68..accc3bd 100644
--- a/file.txt
+++ b/file.txt
@@ -1,7 +1,7 @@
+abc
aaaaaa
aaaaaa
bbbbbb
bbbbbb

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

#!/bin/sh
find=`find /Applications /Applications/Utilities -maxdepth 2 -name '*.app' -exec echo \{\} \;`
#echo $find
IFS=$'\n'
apps=($find)
total=${#apps[*]}
echo "Checking $total applications..."
echo "The following applications will break in Gatekeeper on 10.9.5 and Yosemite:"
count=0
@hrach
hrach / nginx.conf
Created June 9, 2014 20:50
nginx + Nette framework rewrite
server {
listen 80;
server_name example.com;
root d:/webs/example.com/www;
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
location ~ \.phpt?$ {
try_files $uri @missing;
@d11wtq
d11wtq / docker-ssh-forward.bash
Created January 29, 2014 23:32
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@lm
lm / index.php
Last active July 24, 2020 15:30
<?php
class AdminerColors
{
function head()
{
static $colors = array(
'127.0.0.1' => '#ED1C24',
'localhost' => '#009245',
@isetz
isetz / README.markdown
Last active December 27, 2015 11:09 — forked from Yavari/README.markdown

Merge with Merge of https://github.com/bassjobsen/Bootstrap-3-Typeahead this fixes error with $.browser and adds minLength option

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function