Skip to content

Instantly share code, notes, and snippets.

View pepoluan's full-sized avatar
🏡

Pandu E POLUAN pepoluan

🏡
View GitHub Profile
@pepoluan
pepoluan / CSV-FilterCols.ps1
Created July 21, 2014 08:03
Many tools provide output in CSV format (e.g., Windows Performance Monitor). Sometimes I want to "extract" certain columns for easier analysis. So I whupped up this small scriptlet for PowerShell to do just that.
Function CSV-FilterCols() {
param (
[Parameter(Mandatory=$true)][String]$InCsv,
[Parameter(Mandatory=$true)][String[]]$ColNameRegex,
[Switch]$NoGlobal=$false,
[String]$CsvDelimiter=";",
[String]$OutCsv=""
)
If (!(Test-Path $InCsv)) {
C:\Users\pandu.edward\sims3py\Scripts\python.exe -m sims3utils.test_corrupt --profile E:\z\Sims3\Shrisle_0x00000000\Shrisle_0x00000000.nhd
--profile specified, --quiet (if specified) will be canceled
File to check: E:\z\Sims3\Shrisle_0x00000000\Shrisle_0x00000000.nhd
Stage 1: Header check...OK
Stage 2: Index check...OK
29735 Index Entries in 9.80184892035 seconds
Stage 3: Res check. THIS WILL TAKE A LONG TIME!
29735 Resources in 41.1855053353 seconds
No corruption found.
@pepoluan
pepoluan / init.sls
Last active August 29, 2015 14:24
SaltStack State to install vim and update the syntax files
#!pyobjects
# This init.sls state file should be put into /srv/salt/vim
# And /srv/salt/vim/syntax should contain the VimL scriptfiles you list in syntax_updates below
### TUNABLES ###
# Separate entries with a comma
# Make sure every entry exists in the syntax/ directory
syntax_updates = [ 'sh.vim' ]
@pepoluan
pepoluan / CanonTimeline.py
Last active August 29, 2015 14:26
This script pulls the timeline from the "Timeline of Canon Media" article on Wookieepedia, and extracts the information into a CSV file that can be opened directly (without using Text Import Wizard) by Excel.
#!/usr/bin/env python
from __future__ import print_function, division, unicode_literals
__author__ = 'Pepoluan'
import sys
import codecs
import re
import datetime
@pepoluan
pepoluan / Byteify.vb
Created September 1, 2015 10:19
Byteify User-Defined Function -- convert "###.## KB/GB/MB/KiB/MiB/GiB" to values
' 1. Open Excel's VBA Editor using Alt-F11
' 2. Right-Click on the "VBAProject (Spreadsheet_Name)" entry and choose "Insert > Module"
' 3. Paste the below code starting from the line beginning with "Function" up to and including the line "End Function"
' 4. Now you can use the User-Defined Function in your spreadsheet
'
' SYNTAX:
' =Byteify(Cell, [AssumeBinaryPrefix=False])
' Cell : The Cell Reference (if actually a range, it will use the top left cell only)
' AssumeBinaryPrefix : KB, MB, GB will be assumed to be powers of 1024 (in other words, same as KiB, MiB, GiB)
'
@pepoluan
pepoluan / Get-Ancestors.ps1
Last active December 18, 2015 19:19
Get-Ancestors : recursively gets all groups in which an Active Directory object is a member of (directly or indirectly). It returns an array of Active Directory objects. NOTE: ActiveRoles is REQUIRED.
Function Get-Ancestors() {
# The [switch] decorator allows specifying parameters as a flag
param(
$Identity,
[switch]$Silent,
[switch]$IncludeAllProperties
)
# Initialize the hashtable and the .Net Queue
@pepoluan
pepoluan / GetU.ps1
Created June 25, 2013 05:21
I often had to get a User object from AD, and reuse it again and again and again. To complicate matters, some names are very commonly used among Indonesians. So, I whup up this PowerShell Function to: (1) Pull a User object from AD and put it in a $global: object, so I can use it everywhere, and (2) If there are more than one match, list all the…
Function GetU() {
param(
$usr,
$Order,
[switch]$Silent
)
$EssentialAttributes = @(
"EmployeeID"
"Email"
@pepoluan
pepoluan / bash_color_prompt.sh
Last active June 14, 2016 05:19
Colorful & Informative (but not over-the-top) bash prompt
_Prompt() {
local _rslt=$?
## The above line *MUST* be the first line in this function.
## Not even a comment line may precede it.
# There are two sections in this function: Generate Prompt, and Save History
### 1. Generate colorful prompt
# Special username for root (EUID=0) user.

Keybase proof

I hereby claim:

  • I am pepoluan on github.
  • I am pepoluan (https://keybase.io/pepoluan) on keybase.
  • I have a public key ASD3184JHBHYutCiRnsXJIrOjz5XDGtzsnfOQElHSpivZgo

To claim this, I am signing this object:

@pepoluan
pepoluan / setdns.ps1
Created December 19, 2019 04:57
DNS Switcher Script for PowerShell
# This code is released to the Public Domain.
# Alternatively, you can use one of the following licenses: Unlicense OR CC0-1.0 OR WTFPL OR MIT-0 OR BSD-3-Clause
param(
[Parameter(Mandatory=$True,Position=1)]
[string] $server,
[string] $iface = "Wi-Fi", # EDIT AS NEEDED
[string] $dns_service = "dnscrypt-proxy" # EDIT AS NEEDED
)