Skip to content

Instantly share code, notes, and snippets.

View velosipedist's full-sized avatar

Nick Konev velosipedist

View GitHub Profile
@velosipedist
velosipedist / postgresql-list-foreign-keys.sql
Created October 31, 2013 13:52
List all foreign keys in PostgreSQL database, analog of MySQL SHOW CREATE TABLE mytable;
--- Source: http://solaimurugan.blogspot.ru/2010/10/list-out-all-forien-key-constraints.html
SELECT
tc.constraint_name,
tc.constraint_type,
tc.table_name,
kcu.column_name,
tc.is_deferrable,
tc.initially_deferred,
rc.match_option AS match_type,
@velosipedist
velosipedist / rewrite.apacheconf
Last active December 25, 2015 10:59
Change web root using .htaccess. Can be used in Laravel bootstrapped app, or in any project under localhost with spec
# for example, we are in /www/htdocs/myproject
# but webroot situated in /www/htdocs/myproject/public_html
# let's create /www/htdocs/myproject/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_URI} !public_html/
RewriteRule (.*) public_html/$1 [L]
@velosipedist
velosipedist / wordpress-photo-digest
Last active December 19, 2015 09:59
Quick way to list images from Wordpress posts without using "attachment" ("media") posts. Just parse some fresh posts to list found <img/> tags.
<?php
// fetch fresh published posts
$imgPosts = get_posts(array(
'posts_per_page' => 10, // max count
'orderby' => 'post_modified',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish'
));