Skip to content

Instantly share code, notes, and snippets.

View danatcofo's full-sized avatar

Daniel Gidman danatcofo

  • Netreo
  • Kansas City
View GitHub Profile
@danatcofo
danatcofo / DebOrRpm.sh
Created January 11, 2022 23:04
Find out if your linux system uses deb or rpm packages.
#!/bin/bash
deb_pkg=$(which dpkg)
rpm_pkg=$(which rpm)
pkgType=""
if [ -n $deb_pkg ]; then
pkgCount=$(dpkg --get-selections | grep "[[:space:]]install" | wc -l)
if [ $pkgCount != "0" ]; then
pkgType="deb"
@danatcofo
danatcofo / ResizeWatcher.js
Last active December 18, 2020 17:27
SizeWatcher singleton using the ResizeObserver api
const instance =
window.$resizeWatcher ||
(window.$resizeWatcher = {
entries: [],
handlers: [],
observer: new ResizeObserver(entries =>
entries.forEach(entry => {
var index = instance.entries.indexOf(entry.target);
if (index > -1) {
instance.handlers[index].handle(entry.contentRect);
@danatcofo
danatcofo / UpdateIfDifferent.linq
Last active September 30, 2016 15:31
c# extension method to update a property if its different than the new value. Useful with Linq2SQL updates.
<Query Kind="Program" />
void Main()
{
"Test String: empty => value".Dump();
var testCase = new testcase { TestString = string.Empty };
testCase.UpdateIfDifferent(x => x.TestString, "new value");
"Test String: value => empty".Dump();
testCase = new testcase { TestString = "new value" };
testCase.UpdateIfDifferent(x => x.TestString, string.Empty);
@danatcofo
danatcofo / DeleteBitbucketBranches.js
Created July 14, 2016 16:37
Delete Bitbucket Branches from Console of web app
$("[id='" + $(".branch-container button").filter(function(){ var val = ($(this).attr("aria-controls") || ""); return val.indexOf("branch-actions-release/") == -1 && val !== "branch-actions-master" && val !== "branch-actions-develop";}).first().attr("aria-controls") + "'] .close-branch").click();
$("button.aui-button.aui-button-primary.dialog-submit").click();
@danatcofo
danatcofo / SqlClr.Rijndael.cs
Created April 16, 2014 14:50
Sql Clr functions to perform Rijndael encryption and decryption
using System;
using System.IO;
using System.Security.Cryptography;
using System.Data.SqlTypes;
using System.Text;
using Microsoft.SqlServer.Server;
public class Functions
{
[SqlFunction(IsDeterministic = true, IsPrecise = true, DataAccess = DataAccessKind.None)]
@danatcofo
danatcofo / FunctionalModuleExample.ts
Last active August 29, 2015 13:56
turn your typescript modules into functions
/*
* This is an example of how to turn your typescript modules into functions.
*/
function Example(command: string, ...params: any[]): void;
function Example(command: string, ...params: any[]): any {
var isConstructor = false;
if (this instanceof Example && !this.__previouslyConstructedByExample) {
isConstructor = true;
this.__previouslyConstructedByExample = true;
}
@danatcofo
danatcofo / jquery.signalR.subscriptions.js
Created April 24, 2013 17:43
Intention of the file is to provide subscription method by which you can subscribe multiple receivers to the same hub and different methods on that hub without having to handle the coordination of those subscriptions yourself. Let the plugin handle that. in that mind it creates 2 main methods off of $.signalR. First is $.signalR.subscribe("<hub>…
(function ($) {
// var fn = $.signalR.subscribe("hub", "method", function(data){ /* do something */ });
// $.signalR.unsubscribe(fn);
// $.signalR.onConnected(function(clientId){ /* do something */ });
var signalr_conn_timeout, onConnect, onDisconnect, handleInt,
validateSub, subscriptions, connected, log, init, notifyConnected,
connectedSubs;
// identity seed for handle names