Skip to content

Instantly share code, notes, and snippets.

@r-plus
r-plus / SavedSpace.xml
Created January 27, 2015 09:27
Cacti templace - WindowsServer2012 Data Deduplication
<cacti>
<hash_0000248223b362bd688a74951a1ee6323e69d1>
<name>Windows - DedupSavedSpace(WMI)</name>
<graph>
<t_title>on</t_title>
<title>|host_description| - DedupSavedSpace</title>
<t_image_format_id></t_image_format_id>
<image_format_id>1</image_format_id>
<t_height></t_height>
<height>120</height>
@r-plus
r-plus / analyze_robocopy_log.py
Created August 3, 2014 03:49
Output file size and max length of filepath per division to csv from robocopy log.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Usage:
# script.py <robocopy.log> [robocopy.log]...
import re
from sys import argv
# key = division name
#!/usr/bin/env python
import logging
import urllib2
import hmac
import hashlib
import base64
import time
import datetime
import sys
Configuration ServerSetup
{
param
(
[string[]]
$Node
)
Node $Node
{
@r-plus
r-plus / FindAllDC.ps1
Created July 2, 2014 05:20
Find all current domain controllers.
# http://gallery.technet.microsoft.com/scriptcenter/101ebd1a-effe-4a89-9c38-7673fa4d1687
$domain = [directoryServices.ActiveDirectory.Domain]::GetComputerDomain()
$domain.FindAllDomainControllers()
@r-plus
r-plus / matcher.ps1
Created June 9, 2014 14:18
Ordered regexp matching code with PowerShell v3.0+
$json = @"
{
"matcher":
[
{
"regexp" : "^re$",
"dest" : "dest1"
},
{
"regexp" : "^h\\w+eほげ.{3}我$",
host = "192.168.0.1"
user = "user"
password = "password"
batch_path = "C:\Users\user\echo.bat"
Const WbemAuthenticationLevelPktPrivacy = 6
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objWbemLocator.ConnectServer(host, "root\cimv2", user, password, "", "")
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
Set objWin32_Process = objWMIService.Get("Win32_Process")
# Get local wsus object.
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$WsusServerAdminProxy = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
# Decline itanium updates.
$ItaniumUpdates = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match "IA64|Itanium" -and $_.Title -notmatch "x86|x64"}
If ($ItaniumUpdates) {
$ItaniumUpdates | %{$_.Decline()}
}
@r-plus
r-plus / vimrc
Created March 31, 2014 11:06
このvimrcで、3f367ccを適応したNeoBundleだとVim起動時にvim-airlineがロードされていない。4ed2b62まで戻ると、このvimrcでもairlineはロードされる。3f367ccの状態でneomruのLazyをとるとvim-airline, neomruがロードされる。
" NeoBundle
set nocompatible
filetype plugin indent off
if has('vim_starting')
let g:neobundle#types#git#default_protocol = has('gui_win32') ? 'https' : 'git'
set runtimepath+=~/vimfiles/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/vimfiles/bundle/'))
let g:neobundle#default_options._ = { 'verbose' : 1, 'focus' : 1 }
@implementation NSArray(ValueAtIndex)
- (NSArray *)valueAtIndex:(NSUInteger)index
{
NSMutableArray *array = [NSMutableArray array];
for (NSArray *a in self)
if (a.count >= index + 1)
[array addObject:a[index]];
return [NSArray arrayWithArray:array];
}
@end