Skip to content

Instantly share code, notes, and snippets.

@jmoberly
jmoberly / ProgressBarExample.ps1
Created August 30, 2013 22:39
How to have a cool progress bar in Powershell
$thingsArray = 0,1,2,3,4,5,6,7,8,9
$i = 0
foreach($thing in $thingsArray)
{
Start-Sleep -s 1
$i++
$complete = $i / $thingsArray.Length * 100
Write-Progress -activity "Retrieving things..." -status "Percent found: " -PercentComplete $complete
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>feature</string>
</array>
<key>firstLineMatch</key>
<string>기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd(.*)</string>
require "Capybara"
require "Capybara/cucumber"
require "capybara/poltergeist"
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(
app,
window_size: [1280, 1024]#,
require "Capybara"
require "Capybara/cucumber"
require "rspec"
require "selenium-webdriver"
Capybara.register_driver :selenium_chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
if Selenium::WebDriver::Platform.find_binary "chromedriver"
Capybara.default_driver = :selenium_chrome
require "sauce"
require "capybara/cucumber"
require "sauce/cucumber"
require "sauce/capybara"
Sauce.config do |c|
c[:browsers] = [["Windows 8", "Internet Explorer", "10"],
["Windows 7", "Firefox", "20"]]
end
@jmoberly
jmoberly / Git Branch
Created December 9, 2013 14:28
How to get the current branch to appear in Mac Terminal. Add this to your ~/.bash_profile
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@jmoberly
jmoberly / Set-FolderPermission.ps1
Created December 12, 2013 16:53
Set permission on a folder with powershell
$objType =[System.Security.AccessControl.AccessControlType]::Allow
$colRights = [System.Security.AccessControl.FileSystemRights]"Modify"
$InheritanceFlag = "ContainerInherit, ObjectInherit"
$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None
$objUser = New-Object System.Security.Principal.NTAccount("IIS_IUSRS")
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType)
$objACL = Get-ACL "c:\test\Folder"
$objACL.AddAccessRule($rule)
@jmoberly
jmoberly / com.atlassian.bamboo-agent.plist
Last active January 2, 2016 18:18
launchd plist for a bamboo agent on Mac. Just replace the values for your setup. You may have to create a wrapper script to call the Jar file. Make sure to give the sh file execute permission.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.atlassian.bamboo</string>
<key>UserName</key>
<string>username_goes_here</string>
@jmoberly
jmoberly / deleteFolder.js
Created March 3, 2014 22:17
Recursively delete a folder in node.
var deleteFolderRecursive = function(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
@jmoberly
jmoberly / recursive-file-search.js
Created March 24, 2014 20:47
Recursively look at the files under a directory
var fs = require('fs');
var traverseFileSystem = function (currentPath) {
console.log(currentPath);
var files = fs.readdirSync(currentPath);
for (var i in files) {
var currentFile = currentPath + '/' + files[i];
var stats = fs.statSync(currentFile);
if (stats.isFile()) {
console.log(currentFile);
}