Skip to content

Instantly share code, notes, and snippets.

@r-plus
r-plus / create.ps1
Created January 30, 2014 08:50
create files for mtime execution handling test on windows.
# make many directories
cd ~\test
for ($i=0; $i -lt 100; $i++) {
New-Item $i\00 -type directory | Out-Null
New-Item $i\99 -type directory | Out-Null
}
# create files and tweak modify-date if file number is even.
function CreateNewFiles($path)
{
Sub findCell2RowCopy()
Dim findString As Variant
Dim firstAddress As String
Dim findResultCell As Range
Dim oldSheet As Worksheet
Dim destinationSheet As Worksheet
Dim destinationRowNumber As Long
Set oldSheet = activeSheet
destinationRowNumber = 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
@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 }
# 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()}
}
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")
@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}我$",
@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()
Configuration ServerSetup
{
param
(
[string[]]
$Node
)
Node $Node
{
#!/usr/bin/env python
import logging
import urllib2
import hmac
import hashlib
import base64
import time
import datetime
import sys