Skip to content

Instantly share code, notes, and snippets.

@sharshenov
sharshenov / gist:965e71881f4e824797df
Last active August 29, 2015 14:04
Postgres setup
sudo apt-get install postgresql-9.3 postgresql-contrib
sudo -u postgres psql
create role USERNAME with password 'PASSWORD';
alter role USERNAME login;
create database DBNAME;
@sharshenov
sharshenov / gist:2ce672c6e584b288d9cd
Last active August 29, 2015 14:05
Setup postfix gmail relay on ubuntu
# YOLO
sudo su
# Install postfix (use Internet Site configuration)
apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
# Setup allowed SSL certs
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | tee -a /etc/postfix/cacert.pem
# Add to /etc/postfix/main.cf
@sharshenov
sharshenov / gist:b8371f4ea4f09318415d
Last active August 29, 2015 14:06
Logrotate template for rails apps
# save as /etc/logrotate.d/APPNAME
/home/deploy/apps/APPNAME/shared/log/*.log {
su deploy deploy
daily
missingok
rotate 30
compress
delaycompress
notifempty
copytruncate

Keybase proof

I hereby claim:

  • I am sharshenov on github.
  • I am sharshenov (https://keybase.io/sharshenov) on keybase.
  • I have a public key whose fingerprint is ED36 8D30 17B6 39F8 B58E 1E7D EDF0 0A21 B208 D134

To claim this, I am signing this object:

@sharshenov
sharshenov / gist:b494474ae3a0685f6a2f
Created March 22, 2015 06:23
Set postgresql template1 default charset to UTF-8
# open console as postgres user
sudo -u postgres psql
# paste this
update pg_database set datistemplate = FALSE where datname = 'template1';
drop database template1;
create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate = TRUE where datname = 'template1';
@sharshenov
sharshenov / gist:a414add41a3bcc219c6e
Created March 24, 2015 07:12
Fix sublimetext closing on Ctrl+W
1. Select Preferences / Key Bindings(user)
2. Paste this:
```json
[
{ "keys": ["ctrl+w"], "command": "close_file" },
]
```
@sharshenov
sharshenov / 404.html
Created August 20, 2015 09:49
Page not found for RoR
<h1>Page not found</h1>
@DanielApp.module "Entities", (Entities, App, Backbone, Marionette, $, _) ->
App.commands.setHandler "when:fetched", (entities, callback) ->
xhrs = _.chain([entities]).flatten().pluck("_fetch").value()
$.when(xhrs...).done ->
callback()
chain: function() {
collection.fetch()
whenFetched(collection,function() {
...
another_collection.fetch()
whenFetched(another_collection,function() {
...
});
);
},
@sharshenov
sharshenov / throttler.rb
Created April 19, 2016 18:08
Basic throttler
class Throttler
class << self
def limit *attrs
throttler.limit *attrs
end
private