Skip to content

Instantly share code, notes, and snippets.

@a2f0
a2f0 / gist:6032220
Last active December 19, 2015 23:08
nginx logrorate
/var/log/nginx/*.log {
daily
compress
delaycompress
rotate 7
missingok
sharedscripts
postrotate
test ! -f /var/run/nginx.pid || kill -USR1 `cat /var/run/nginx.pid`
touch /opt/rails/asap/app/2014/current/tmp/restart.txt
@a2f0
a2f0 / gist:7553611
Created November 19, 2013 22:20
with rvm
# pstree -p
init(1)-+-PassengerWatchd(14233)-+-PassengerHelper(14236)-+-ruby(14262)-+-ruby(14386)-+-{ruby}(14388)
| | | | |-{ruby}(14391)
| | | | `-{ruby}(14392)
| | | |-{ruby}(14387)
| | | `-{ruby}(14389)
| | |-{PassengerHelpe}(14238)
| | |-{PassengerHelpe}(14239)
| | |-{PassengerHelpe}(14240)
| | |-{PassengerHelpe}(14243)
Migration:
class CreateJoinTableCommandTag < ActiveRecord::Migration
def change
create_join_table :commands, :tags do |t|
# t.index [:command_id, :tag_id]
# t.index [:tag_id, :command_id]
end
end
@a2f0
a2f0 / gist:8553481
Last active January 4, 2016 02:09
destroy always fail
Here is the command that I can execute against it (the one that I think I should *not* be able to execute. I basically am trying to write a more complex validation that prevents deletion of a tag based on more complex criteria, but would like to first write a base before_destroy validation that causes the deletion to *always* fail no matter what.
@command = Command.find(params[:id])
tag = Tag.find(params[:tag_id])
@command.tags.delete(tag)
Here is the complete model for tagmapsorter:
class Tagmapsorter < ActiveRecord::Base
belongs_to :command
Would somebody be able to tell me why these queries are giving me different results when I am executing the same query? I am executing one in active record and one natively via SQLite.
SQLite:
sqlite> select * from commands LEFT OUTER JOIN tagmapsorters ON tagmapsorters.command_id = commands.id WHERE tagmapsorters.tag_id is NULL;
3|hi|2014-01-24 07:07:20.149017|2014-01-24 07:07:20.149017|hi|||||
sqlite> select * from commands;
2|unix|2014-01-24 06:47:51.701648|2014-01-24 06:47:51.701648|unix
3|hi|2014-01-24 07:07:20.149017|2014-01-24 07:07:20.149017|hi
4|linux|2014-01-24 07:41:29.121709|2014-01-24 07:41:29.121709|whatever
[TRACE ] Inserted key into loop_instance_map id 54955112 for key ('/etc/salt/pki/master', 'server.cri.uchicago.edu_master', 'tcp://127.0.0.1:4506', 'clear') and process 29714
[DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'somemaster.cri.uchicago.edu_master', 'tcp://127.0.0.1:4506', 'clear')
[TRACE ] Inserted key into loop_instance_map id 54955112 for key ('/etc/salt/pki/master', 'cri-nacl.cri.uchicago.edu_master', 'tcp://127.0.0.1:4506', 'clear') and process 29714
[DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[TRACE ] IPCClient: Connecting to socket: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] LazyLoaded nested.output
$ free -m
total used free shared buffers cached
Mem: 1869 1734 135 0 91 1032
-/+ buffers/cache: 610 1259
Swap: 3999 21 3978
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/VG00-lv_root
196608 12446 184162 7% /
FilesMatch:
this: \.css\.gz$
ForceType: text/css
Header: set Content-Encoding gzip
FilesMatch:
this: \.js\.gz$
ForceType: text/javascript
Header: set Content-Encoding gzip
/etc/httpd/conf.d/{{ pillar['fqdn'] }}-ssl.conf:
apache.configfile:
- config:
- VirtualHost:
this: '*:443'
SSLEngine: 'on'
Header: set Access-Control-Allow-Origin "https://{{ pillar['fqdn'] }}"
SSLCertificateFile: /opt/certbot/config/live/{{ pillar['fqdn'] }}/cert.pem
SSLCertificateKeyFile: /opt/certbot/config/live/{{ pillar['fqdn'] }}/privkey.pem
SSLCertificateChainFile: /opt/certbot/config/live/{{ pillar['fqdn'] }}/fullchain.pem