Skip to content

Instantly share code, notes, and snippets.

View coryasilva's full-sized avatar

Cory Silva coryasilva

View GitHub Profile
@coryasilva
coryasilva / mssql-table-usage.sql
Created February 6, 2024 22:04
mssql table usage
select top 100
d.name database_name
,t.name table_name
,sum(us.user_seeks) user_seeks
,sum(us.user_scans) user_scans
,sum(us.user_lookups) user_lookups
,sum(us.user_updates) user_updates
,max(us.last_user_seek) last_user_seek
,max(us.last_user_scan) last_user_scan
,max(us.last_user_lookup) last_user_lookup
@coryasilva
coryasilva / mssql-get-port.sql
Created February 6, 2024 22:02
MSSQL get port
select distinct local_net_address, local_tcp_port
from sys.dm_exec_connections
where local_net_address is not null
@coryasilva
coryasilva / chrome-ver.sh
Created February 6, 2024 20:02
Latest version of chrome
curl --silent https://omahaproxy.appspot.com/all.json | jq -r '.[] | select(.os == "linux").versions[] | select(.channel == "stable").current_version'
# Pipe to cut to get major version
# | cut -d '.' -f1
@coryasilva
coryasilva / delayed-expansion.bat
Created February 6, 2024 20:00
windows batch file delayed expansion
@setlocal EnableDelayedExpansion
@set hosts=server01 server02 server03
@for %%h in (%hosts%) do @(
@set host=%%h
@set host_no=!host:~-1!
@echo !host!
@echo %%h
@echo:!host_no!
)
@coryasilva
coryasilva / geo-bounds-and-center.js
Created February 6, 2024 19:57
Calculate geometric bounds and center
const points = [
// Bounds
[32.8644429,-117.2791394]
, [32.8693815,-117.0464238]
, [32.6162867,-116.9453358]
, [32.5781068,-117.1498078]
// Points inside
, [32.6, -117.1]
, [32.7, -117.2]
]
@coryasilva
coryasilva / downloadFile.js
Created February 2, 2024 15:04
NodeJS Download File; streaming read; streaming write; async; got
import https from 'node:https'
import { join } from 'node:path'
import { createWriteStream } from 'node:fs'
import { pipeline } from 'node:stream/promises'
import got from 'got'
/* Config */
// Enable keep alive for better performance between calls.
https.globalAgent = new https.Agent({ keepAlive: true })
const outDir = './out'
@coryasilva
coryasilva / Leaflet Hovermarker
Created April 24, 2015 05:04
Leaflet Hovermarker
// This was stolen from somewhere on the net while I was working late to fulfill a deadline
// It is now here as a reminder
// sorry for the plagerism...
var HoverMarker = $window.L.Marker.extend({
bindPopup: function(htmlContent, options) {
if (options && options.showOnMouseOver) {
L.Marker.prototype.bindPopup.apply(this, [htmlContent, options]);
//this.off("click", this.openPopup, this);
this.on("mouseover", function(e) {
@coryasilva
coryasilva / servicecontrol.bat
Created December 30, 2014 04:46
Windows Service Control Batch File
@echo off
REM %1 = action
REM %2 = service
REM Set vars
set status=""
set message=""
set hint="C:\>servicecontrol.bat [ START | STOP ] [<service_name>]"
set example=servicecontrol.bat start "My Service Name"
@coryasilva
coryasilva / bug-log-service.js
Last active August 29, 2015 14:11
BugLogHq AngularJs Example
angular.module('BugLogHq', [])
.constant('appName', "app")
.constant('bugLogConfig', {
listener: "",
hostName: "",
apiKey: ""
})
.config(['$provide',
function ($provide) {
$provide.decorator('$exceptionHandler', ['$delegate', '$log', 'BugLogService',
@coryasilva
coryasilva / OKZoom loupe AngularJs Directive.js
Last active December 15, 2015 15:20
AngularJs Directive for OKZoom Loupe
var app = angular.module('loupe', []);
app.controller('MainCtrl', ['$scope',
function($scope) {
$scope.title = 'AngularJS Image Loupe';
$scope.image = 'puppy.jpg';
$scope.loupeOptions = {
width: 360,
height: 144,
round: false,