Skip to content

Instantly share code, notes, and snippets.

@Ptico
Ptico / basic.sql
Created December 13, 2019 16:50 — forked from nesquena/basic.sql
PostgreSQL Common Utility Queries
/* How to calculate postgreSQL database size in disk ? */
SELECT pg_size_pretty(pg_database_size('thedbname'));
/* Calculate size of a table including or excluding the index */
SELECT pg_size_pretty(pg_total_relation_size('big_table'));
SELECT pg_size_pretty(pg_relation_size('big_table')); /* without index */
/* See indexes on a table with `\d tablename` */
@Ptico
Ptico / site.conf
Created October 1, 2015 12:49 — forked from paskal/site.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
@Ptico
Ptico / ramfs
Last active August 29, 2015 14:07 — forked from raggi/ramfs
#!/bin/bash
ramfs_size_mb=1024
mount_point=~/volatile
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`
newfs_hfs -v 'Volatile' ${ramdisk_dev}
mkdir -p ${mount_point}
mount -o noatime -t hfs ${ramdisk_dev} ${mount_point}
echo "remove with:"
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@Ptico
Ptico / deploy.rb
Last active December 16, 2015 00:19 — forked from Lightpower/gist:5347055
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
App = {};
// Another sandbox functions
/**
* Creates namespace in sandbox by string definition
* If part of namespace already defined - keep it untouchable,
* else - create empty object.
*
* App.namespace("Hello.World");
@Ptico
Ptico / ruby-1.9-tips.rb
Created February 27, 2011 22:18 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 tips and tricks
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
# cap web:deploy:desable & cap web:deploy:enable
server {
...
if (-f $document_root/system/maintenance.html) { set $maintenance 1; }
if ($request_uri ~* (jpg|jpeg|gif|js|css)$) { set $maintenance 0; }
if ($maintenance) { rewrite ^(.*)$ /system/maintenance.html; break; }
...
}