Skip to content

Instantly share code, notes, and snippets.

@aptavout
aptavout / iterate-by-rows.bas
Created May 24, 2013 03:26
Travel row-by-row of a workbook with Excel VBA.
Range("A1").Select
Range(ActiveCell, ActiveCell.CurrentRegion).Select
For Each row In Selection.Rows
Debug.Print Cells(row.Row, 1) ' value of first column in current row
Next
@aptavout
aptavout / iterate-workbooks.bas
Created May 24, 2013 03:23
Iterate across open workbooks in Excel VBA
For Each wb In Workbooks
wb.Activate
Debug.Print ActiveWorkbook.Name
wb.Close
Next
@aptavout
aptavout / simple-curl.bat
Created May 23, 2013 03:14
cURL GET session ID followed by a login POST
@echo off
set url=http://www.target-url.org
set agent=Mozilla/2.02Gold (Win95; I)
curl -c cookies.txt -A "%agent%" %url% > get.txt
set login=jsmith
set pass=intheclear
set query=%login%^&%pass%
@aptavout
aptavout / filter-tags.bat
Last active December 17, 2015 14:29
This is a batch script that replaces <td> and </td> tags with commas. These act as delimiters to extract information from the HTML table.
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in ('findstr /C:"data 3" table.html') do (
set line=%%i
set line=!line:^<td^>=,!
set line=!line:^</td^>=,!
for /f "delims=, tokens=2,3" %%j in ("!line!") do (
echo %%j,%%k > step-2.txt
@aptavout
aptavout / a-table.html
Last active December 17, 2015 14:29
This is an HTML table.
<table border="1">
<tr>
<th>Col 1</th><th>Col 2</th><th>Col 3</th>
</tr>
<tr>
<td>data 1</td><td>data 2</td><td>data 3</td>
</tr>
<tr>
<td>data 4</td><td>data 5</td><td>data 6</td>
</tr>