Skip to content

Instantly share code, notes, and snippets.

@veysby
veysby / gist:c6fa540da3bc7baf682aec1ebdc321a6
Created July 13, 2016 15:54
CMD: check is specific port open
netstat -an | findstr /C:1158
@veysby
veysby / javactrl.sh
Last active December 10, 2015 21:07
SH: wrapper for Java applications
#!/bin/sh
invoke_help() {
cat << EOF
Usage: $0 -a <ACTION> [-f] [-h]
-a : ACTION, where ACTION is one of:
start : Start the service in the background
stop : Stop the service
status : Show status
@veysby
veysby / jmx_opts.sh
Last active December 10, 2015 20:08
SH: JMX options for Java applications
JMX_OPTS="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote"
JMX_OPTS="$JMX_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JMX_OPTS="$JMX_OPTS -Dcom.sun.management.jmxremote.port=1100"
@veysby
veysby / activemq.txt
Last active April 20, 2020 10:08
Activemq: check health status using REST API
$curl http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,service=Health
{"timestamp":1449776947,"status":200,"request":{"mbean":"org.apache.activemq:brokerName=localhost,service=Health,type=Broker","type":"read"},"value":{"CurrentStatus":"Good"}}
@veysby
veysby / Vagrantfile
Last active December 10, 2015 16:33
Vagrant: 3 machines in private network
Vagrant.configure("2") do |config|
config.vm.define "lb" do |lb|
lb.vm.box = "centos65"
lb.vm.host_name = "lb"
lb.vm.network "private_network", ip: "192.168.0.20"
lb.vm.network :forwarded_port, guest: 22, host: 2220, id: "ssh", auto_correct: true
lb.vm.network :forwarded_port, guest: 80, host: 9099, id: "web", auto_correct: true
config.vm.provider :virtualbox do |vb|
@veysby
veysby / MSSQL_test_table.sql
Last active December 10, 2015 16:17
MSSQL: Create test table with random data
SELECT TOP 1000000
IDENTITY(INT,1,1) AS UniqueInt,
CAST(NEWID() AS VARCHAR(36)) AS UniqueVarChar
INTO #TestTable
FROM Master.sys.All_Columns ac1
CROSS JOIN Master.sys.All_Columns ac2
@veysby
veysby / gist:9586722a06add9b9548a
Created March 3, 2015 16:57
MSSQL: cached query plans
-- DO NOT RUN this script on Production environment
-- Clear the plan cache
dbcc freeproccache
-- Look at the cached query plans
select st.text,*
from sys.dm_exec_cached_plans cp
cross apply sys.dm_exec_sql_text(cp.plan_handle) st
where (st.text like '%select * from Person.Address%')
and st.text not like '%select st.text%'
@veysby
veysby / gist:ba81e5c9eafbd3efc052
Created January 27, 2015 17:06
MSSQL: list tables, indexes, indexed columns, etc
--Source: http://simplesqlserver.com/2013/11/20/indexing-fundamentals/
DECLARE @TableName VarChar(100)
SELECT @TableName = '%'
SELECT TableName = i.SchemaName + '.' + i.TableName
, IndexName = ISNULL(i.IndexName, '[' + Lower(i.IndexType) + ']')
--, SeekUpdateRatio = CASE WHEN i.User_Updates > 0 THEN CAST(i.User_Seeks / CAST(i.User_Updates as DEC(20,1)) as DEC(20,2)) ELSE 0 END
, i.User_Updates
, i.User_Seeks
@veysby
veysby / gist:fdeac9145d11f82a093d
Created January 27, 2015 16:43
MSSQL: index fragmentation
SELECT
OBJECT_NAME(ind.OBJECT_ID) AS TableName,
ind.name AS IndexName,
indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind ON ind.object_id = indexstats.object_id AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30--You can specify the percent as you want
ORDER BY
indexstats.avg_fragmentation_in_percent DESC
@veysby
veysby / gist:4f18e99d206121ee33a6
Created January 27, 2015 16:38
MSSQL: list statistics update date
SELECT
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(o.object_id) AS ObjectName,
type AS ObjectType,
s.name AS StatsName,
STATS_DATE(o.object_id, stats_id) AS StatsDate
FROM sys.stats s
INNER JOIN sys.objects o ON o.object_id=s.object_id
WHERE OBJECTPROPERTY(o.object_id, N'ISMSShipped') = 0
AND LEFT(s.Name, 4) != '_WA_'