This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.ComponentModel; | |
using System.Reflection; | |
using System.Collections; | |
using System.Text.RegularExpressions; | |
namespace FilteredBindingList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shutil import copyfile | |
import os | |
count = 0 | |
destinationdir = '' | |
sourcedir = '' | |
for (dirname, dirs, files) in os.walk(sourcedir): | |
for file in files: | |
filename, file_extension = os.path.splitext(file) | |
file_extension = file_extension.strip(".") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import datetime | |
import win32wnet | |
from datetime import date | |
# Destination path | |
host = 'devfs02' # SMB server | |
share = 'K' # SMB share | |
username = 'tde' # SMB user | |
password = 'etech' # SMB user password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following DOS batch one liner will rename many same-named folder folders. | |
The following example will rename folders under "Reports Test 2\data" that ends with "Custodian1" and renames it to "Custodian2." | |
for /f "tokens=*" %a in ('dir /b /s "Reports Test 2\data" ^| findstr /r "Custodian1$"') do ren "%a" "Custodian2" | |
This can be easily customized for example to rename folders or files in the current folder: | |
for /f "tokens=*" %a in ('dir /b') do ren "%~na" "%~na2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following will provide an automatic way of adding version information into a Microsoft Word document using an external text file. This is an ideal way in versioning documents using external controls such as a build script. The script can update external version file and then create a PDF of the document. Thereby, creating a "build" of the Word document. | |
1. Add a version.txt file in the same folder as your document. This file will contain a single line with the version information (e.g. 1.0.0) | |
2. Open the Word document and Add an IncludeText Quick Part. | |
3. Reveal the field codes by typing ALT-F9 | |
4. Position the cursor after "{ INCLUDETEXT" just before the closing " }" tag. | |
5. Go to Quick Part and insert a FileName field and tick the "Add path to filename" checkbox. | |
You should have the following code at this point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def NEW_LINE = System.getProperty("line.separator") | |
if (args.length < 1) | |
{ | |
println "Enter a URL as an argument." | |
System.exit(-1) | |
} | |
def address = args[0] | |
def urlInfo = address.toURL() | |
println "====================================================================" | |
println "====== HEADER FIELDS FOR URL ${address}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example on how to parse arguments passed to a groovy script | |
import jenkins.model.* | |
if (args.length != 2 ) { | |
println "Error on arguments!" | |
} | |
def jobName = args[0] ?: 'a_job' | |
def viewName = args[1] ?: 'a_view' | |
println jobName + ' ' + viewName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.json.JsonSlurper | |
/*** | |
* This method uses JsonSlurper to parse a given JSON text into | |
* a more accessible data list and map structure. The following | |
* example illustrates this transformation | |
* | |
* def result = slurper.parseText('{"person":{"name":"Guillaume","age":33,"pets":["dog","cat"]}}') | |
* | |
* assert result.person.name == "Guillaume" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
* Use this method to get an authentication token for a given URL and authentication string | |
* @param auth is an authentication string in the form of username:password or username:authtoken | |
* @param addr is the url to access | |
***/ | |
def requestConnection(auth,addr) | |
{ | |
def authString = "${auth}".getBytes().encodeBase64().toString() // Use authentication token | |
def conn = addr.toURL().openConnection() | |
if (authString.length() > 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use the following Groovy script to inject into the current build context | |
// Install the EnvInject plugin, https://wiki.jenkins.io/display/JENKINS/EnvInject+Plugin. | |
// In your job, Enable the Inject environment variables to the build process and | |
// Enter in the Evaluated Groovy script field. Make sure to keep the Use Groovy Sandbox | |
// unchecked. This script returns a hashmap of all environment variables including | |
// build specific ones into the current environment. | |
// | |
// By doing this, Jenkins specific environment variables can be accessed later on | |
// in a non=system Groovy script with a simple way. For example, to get the value of the | |
// JENKINS_URL is done this way: |