Skip to content

Instantly share code, notes, and snippets.

View StephenLujan's full-sized avatar

Stephen Lujan StephenLujan

View GitHub Profile
@StephenLujan
StephenLujan / prowandMagnitFiller.js
Last active January 10, 2023 20:38
prowand magnit defaults timesheet filler for tampermonkey
// ==UserScript==
// @name prowand magnit timesheet filler
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://prowand.pro-unlimited.com/worker/standard/billing/billingedit/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=pro-unlimited.com
// @grant none
// ==/UserScript==
@StephenLujan
StephenLujan / stored-procedure-test-lib.ps1
Created August 23, 2021 05:48
PowerShell functions for writing automated tests against SQL stored procedures
###########################################################
# Constants
$DEFAULTS = [PSCustomObject]@{
dataSource = "YourServer.com,1434;"
database = "DB"
testOutputPath = [Environment]::GetFolderPath("Desktop")+"\DB_TEST"
queryTimeout = 600
connectionTimeout = 15
}
<#
To fix problems with running sites in iis express from visual studio:
1. Close visual studio completely
2. Run this script as an administrator
3. Reopen your solution in visual studio
If you can't run this script, first run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
#>
@StephenLujan
StephenLujan / Update-Java-Certs.ps1
Created February 25, 2016 20:30
Fix all java run-times' connections to the internet when behind enterprise firewalls/proxies that alter the certificate paths
<#
.Synopsis
Fix all java run-times connections to the internet behind enterprise firewalls/proxies that alter the certificate paths
.Description
Run as administrator and in the same directory as your enterprise's root certificate authority.
@StephenLujan
StephenLujan / logging_subprocess.py
Last active August 29, 2015 14:17
A resource for creating subprocesses, each controlled from a separate thread that feeds their stdout and stderr to python loggers, by default one yielding color coded console output. Originally developed for unix and python 2. Other compatibility is untested.
import os
import threading
import subprocess
import time
import select
import logging
import signal
try:
from Queue import Queue, Empty
@StephenLujan
StephenLujan / euler_3_best.py
Created January 18, 2014 13:05
tried to optimize performance and get closer to production quality
#!/usr/bin/env python
"""
This is a solution to the first backend challenge. This solution uses some best practices,
and a function that is both highly performance optimized and more flexible than the requirements.
"""
import time
BLAH = """nononoffffccaaccaaddaaaadddchjkl
asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasddfasdfasdasdfds
@StephenLujan
StephenLujan / euler_3_easy.py
Created January 18, 2014 13:02
easy 5 minute attempt at euler 3
BLAH = "nononoffffccaaccaaddaaaadchjkl"
longest = ""
for x in range(0, len(BLAH)):
for y in range(1, len(BLAH) + 1 - x):
string = BLAH[x:][:y]
uniqueChars = set(char for char in string)
if len(uniqueChars) < 3:
if len(string) > len(longest):
longest = string
print longest
@StephenLujan
StephenLujan / euler_3_one_liner.py
Last active January 3, 2016 16:29
1 line solution (plus input line)
BLAH = "nononoffffccaaccaaddaaaadchjkl"
print max([string[:y] for string in [BLAH[x:] for x in range(0, len(BLAH))] for y in range(1, len(string) + 1) if len(set(string[:y])) < 3], key=lambda x: len(x))
@StephenLujan
StephenLujan / pymongotest
Last active December 20, 2015 10:19
pymongo test
'''
Created on Jul 30, 2013
@author: slujan
'''
import unittest
from pymongo import MongoClient
import datetime
class TestMongo(unittest.TestCase):
@StephenLujan
StephenLujan / displaySharePointSiteHierarchy.ps1
Created April 10, 2013 20:59
A simple PowerShell function that will recurse through a SharePoint site to display the hierarchy of sites under it. Like so: site|- subsite| |- subsubsite|- subsite
function _displaySites([Microsoft.SharePoint.SPWeb]$SPWeb, [int] $depth = 0, [int] $maxDepth = 9999){
if ($depth -eq 0) {
Write-Output($SPWeb.title);
} else {
$string = "|- " + $SPWeb.title;
for ($i=2; $i -le $depth; $i++) {
$string = "| " + $string
}
Write-Output($string);