Skip to content

Instantly share code, notes, and snippets.

🤙

Dan Sullivan deepeeess

🤙
Block or report user

Report or block deepeeess

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@deepeeess
deepeeess / gist:6032220
Last active Dec 19, 2015
nginx logrorate
View gist:6032220
/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
View gist:7553611
# 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)
View gist:8496381
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
@deepeeess
deepeeess / gist:8553481
Last active Jan 4, 2016
destroy always fail
View gist:8553481
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
View gist:8610635
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
View gist:a2fcf585608fbb9645a8
Started GET "/admin/employees/645114968/blogposts" for 127.0.0.1 at 2014-07-28 17:40:10 -0500
Processing by Admin::BlogpostsController#index as HTML
Parameters: {"employee_id"=>"645114968"}
AdminUser Load (0.2ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 1 LIMIT 1
Completed 500 Internal Server Error in 3ms
NoMethodError (undefined method `find' for nil:NilClass):
inherited_resources (1.5.0) lib/inherited_resources/belongs_to_helpers.rb:90:in `evaluate_parent'
inherited_resources (1.5.0) lib/inherited_resources/base_helpers.rb:144:in `block in association_chain'
inherited_resources (1.5.0) lib/inherited_resources/base_helpers.rb:143:in `each'
View gist:f22b381ab71c4ac4576c
p = subprocess.Popen(["mysqldump", "--single-transaction", "-u",
database_username, "--password="+database_password, "--databases",
"--host", server_address, database_name, ],
stdout = open( outputfile, 'w') , stderr=subprocess.PIPE)
error = p.stderr.read()
p_ret = p.wait()
print "return code from mysqldump: " + str(p_ret)
if (len(error)) > 0:
action_error(error)
@deepeeess
deepeeess / gist:3dbf7a087a42373a6407
Last active Aug 29, 2015
detect hung passenger processes by inspecting an isolated application pool, iterating, and authing against the api
View gist:3dbf7a087a42373a6407
#!/bin/sh
#Isolate an application pool and iterate through and authenticate
#Written by Dan Sullivan
#Will detect hung processes
IFS=$'\n'
for i in $(rvmsudo passenger-status --verbose |
pcregrep -M '/opt(.|\n)*^/opt' |
grep -v Requests | grep -v ^/ |
grep -v "App root" | grep -v CPU |
View gist:6371c0ab2d72d555cd7c
<!DOCTYPE html>
<html>
<head>
<title>This shows how to get elements inside included svg images from the surrounding html.</title>
</head>
<body>
<object class="emb" data="images/svglogo.svg" width="100" height="100" type="image/svg+xml"></object>
<embed class="emb" src="images/svglogo.svg" width="100" height="100" type="image/svg+xml" />
<iframe class="emb" src="images/svglogo.svg" width="100" height="100" style="border:0" ></iframe>
<p>
View gist:5d8309046e5ec1ae55dd
<script>//<![CDATA[
window.addEventListener("load", configRainbow, false);
function configRainbow() {
var x=document.getElementById("rainy");
var bigstar;
if (x.contentDocument) {
var star1 = x.contentDocument.getElementById("star1");
var star2 = x.contentDocument.getElementById("star2");
var star3 = x.contentDocument.getElementById("star3");
var star4 = x.contentDocument.getElementById("star4");
You can’t perform that action at this time.