Skip to content

Instantly share code, notes, and snippets.

View wsakaren's full-sized avatar

Karen Baker wsakaren

  • WebShopApps
  • Austin, TX
View GitHub Profile
View number of threads open
ps huH p <PID_OF_U_PROCESS> | wc -l
e.g. do ps huH p 2016 | wc -l ; sleep 1; done
@wsakaren
wsakaren / new_relic_tomcat.txt
Last active August 13, 2016 14:46
Setting up New Relic in Tomcat
1.Download Java agent zip file from New Relic site
2. Under the tomcat base directory create a directory newrelic
3. Put the unzipped files in this directory
4. Update the license key in newrelic.yml with that shown in New Relic Admin
5. Update the App Name to something suitable
6. Update catalina.sh to have following:
NR_JAR=/usr/local/tomcat/newrelic/newrelic.jar; export NR_JAR
CATALINA_OPTS="$CATALINA_OPTS -javaagent:$NR_JAR"; export CATALINA_OPTS
7. Restart Tomcat – should now appear as a new application in New Relic
@wsakaren
wsakaren / quick commands
Created August 10, 2016 00:49
magento 2 quick commands
XML Schema Resolution:
bin/magento dev:urn-catalog:generate .idea/misc.xml
@wsakaren
wsakaren / gist:c70aa7c168c3ce492fce9f258aed8a6c
Created August 7, 2016 20:22
Get latest git tag and increment version by 1
git tag --sort version:refname |tail -n1 | gawk -F"." '{$NF+=1}{print $0RT}' OFS="." ORS=""
@wsakaren
wsakaren / log_mysql.sql
Created June 5, 2016 20:14
Enable Logging myqsl
Find your my.cnf:
mysql --help | grep "Default options" -A 1
Edit:
[mysqld]
general_log_file = /opt/local/var/log/mysql56/mysql-query.log
general_log = on
To check:
@wsakaren
wsakaren / composer.json
Created May 31, 2016 18:32
Using a Git Branch in composer
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
},
{
"type": "vcs",
"url": "git@github.com:webshopapps/module-shipper.git"
}
],
list ip tables
sudo iptables -S
list nat ip tables
sudo iptables -L -vt nat
Delete nat ip tables
for i in $( iptables -t nat --line-numbers -L | grep ^[0-9] | awk '{ print $1 }' | tac ); do iptables -t nat -D PREROUTING $i; done
http://lubos.rendek.org/remove-all-iptables-prerouting-nat-rules/
@wsakaren
wsakaren / add_user.sh
Created May 15, 2016 07:18
add user linux with root access, empty ssh key and permissions all set
#!/bin/bash
if id "$1" >/dev/null 2>&1; then
echo "user exists"
else
echo "user does not exist, creating"
useradd -c "$1 last" $1 -m
fi
echo "$1 ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
@wsakaren
wsakaren / datatable_row_edit.js
Created May 9, 2016 02:45
datatable click on row to edit in Rails. Wraps the url in the <tr> element
In datatable declaration:
fnRowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
row_id = ($(nRow).attr("id")).split('_').pop();
$(nRow).attr("data-edit-location", '<%= controller_path %>/' + row_id + '/edit');
return nRow;
}
In document.ready:
@wsakaren
wsakaren / save_bootstrap_accordion_state.js
Created May 8, 2016 05:17
Coffeescript that will save and re-load the open/closed accordions for twitter bootstrap.
$('.panel-collapse').on 'hidden.bs.collapse', ->
if @id
localStorage.removeItem @id
return
$('.panel-collapse').on 'shown.bs.collapse', ->
if @id
localStorage[@id] = 'true'
return