Skip to content

Instantly share code, notes, and snippets.

View jwstl's full-sized avatar

Jason White jwstl

View GitHub Profile
@kilasuit
kilasuit / sampleprompt.ps1
Last active January 6, 2022 14:46
Powershell prompt
function Prompt
{
# Admin ?
if( (
New-Object Security.Principal.WindowsPrincipal (
[Security.Principal.WindowsIdentity]::GetCurrent())
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
# Admin-mark in WindowTitle
$Host.UI.RawUI.WindowTitle = "[Admin] " + $Host.UI.RawUI.WindowTitlep
@dudelis
dudelis / k2-ci-demo-deploy.ps1
Created March 12, 2018 14:53
K2 Automatic Deployment
#Adds the PowerShell Deployment snapin.
add-pssnapin SourceCode.Deployment.PowerShell
#Scripts the deployment of a package
Deploy-Package $(System.DefaultWorkingDirectory)/K2-CI-Demo-CI/$(Build.BuildNumber)/ExpenseClaim.kspx $(System.DefaultWorkingDirectory)/K2-CI-Demo-CI/$(Build.BuildNumber)/ExpenseClaim.xml
@dudelis
dudelis / k2-listbox-option-draggable.js
Created March 6, 2018 11:31
K2: Draggable listbox options
//Converting the 'text' into '{text}' for the Email Templating placeholders
var dragListBox = function(ev) {
ev.dataTransfer.setData("text",'{' + ev.srcElement.text + '}');
};
//Adding html attributes to make the inner items draggable
$('div[name="NameOfYourListBox"]')
.find('.optionwrapper')
.find('.option')
.attr('draggable', 'true')
.attr('ondragstart', 'dragListBox(event)');
@dudelis
dudelis / k2-ci-demo-package.ps1
Created February 28, 2018 11:08
K2 Automatic Build
param([string]$appName, [string]$categoryPath)
if(-not($appName)){ Throw "You must provide the name for your application"}
if(-not($categoryPath)){ Throw "You must provide the path for your application category"}
#01. Create a folder for the output
New-Item -ItemType Directory -Force -Path $PSScriptRoot\PND
#02. Create a package
Import-Module $PSScriptRoot\Assemblies\K2Field.Powershell.Module.dll -Verbose -Force
@dudelis
dudelis / k2-listcolumn-highlight.html
Last active March 25, 2018 18:54
K2: Highlighting a column in a List View
<!--Insert the snippet below in a Literal Datalabel -->
<style type="text/css">
div[name="View Name"] .grid-body tbody td:nth-child(%ColumnNumber%) {
background: #FFFACD !important
}
</style>
@dudelis
dudelis / Excel-GetCellValue.cs
Created February 26, 2018 13:52
Excel - Get cell value (OpenXML)
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
public static string GetCellValue(string fileName, string sheetName, string addressName)
{
string value = null;
using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, false))
{
WorkbookPart wbPart = document.WorkbookPart;
Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sheetName).FirstOrDefault();
@dudelis
dudelis / k2-checkbox.html
Last active March 25, 2018 18:54
K2: Checkbox html
<!-- Checked -->
<label class="input-control checkbox checked" data-defaultvalue="false">
<span class="input-control-img"></span>
</label>
<!-- Not checked -->
<label class="input-control checkbox" data-defaultvalue="false">
<span class="input-control-img"></span>
</label>
@dudelis
dudelis / GetComputers.cs
Last active March 25, 2018 18:54
Get Computers from AD
public static class AdQueryHelper
{
public static List<AdObject> GetComputers(string ldapPath, int sizeLimit, int pageSize)
{
List<AdObject> adEntries = new List<AdObject>();
using (DirectoryEntry entry = new DirectoryEntry(ldapPath))
{
using (DirectorySearcher mySearcher = new DirectorySearcher(entry))
{
mySearcher.Filter = ("(objectClass=computer)");
@dudelis
dudelis / k2-viewheader-clickable.js
Last active March 25, 2018 18:54
K2: How to make the whole header view clickable (expand/collapse)
var headerClick = function(self) {
if(self){
$(self.currentTarget).find('a').click();
}
};
$('.grid-header').click(headerClick);