Skip to content

Instantly share code, notes, and snippets.

@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>
@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 / 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 / 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 / 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-2d.bas
Created May 24, 2013 03:30
Treat an Excel workbook as a 2-dimensional array, and iterate over it.
Range("A1").Select
Range(ActiveCell, ActiveCell.CurrentRegion).Select
For Each row In Selection.Rows
Dim rowStr As String
For Each col In Selection.Columns
rowStr = rowStr & Cells(row.Row, col.Column)
If col.Column < Selection.Columns.Count Then
rowStr = rowStr & ","
@echo off
setlocal
set winincludes=C:\Program Files\PellesC\Include\Win
set sysincludes=C:\Program Files\PellesC\Include
set INCLUDE=%winincludes%;%sysincludes%
rem /Ze: use Microsoft extensions to avoid winnt.h "No specific architecture" error
pocc sqlite.c /Ze
@aptavout
aptavout / eastward-sphere
Last active August 29, 2015 13:56
Windowed, threaded, double-buffered JFrame with Graphics2D text.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lab;
import java.awt.*;
import javax.swing.JFrame;
@aptavout
aptavout / auto-pivot
Created March 12, 2014 02:23
Programmatic PivotTable using the VBA you already wrote (or recorded)
Const xlHTMLStatic = 0
Set args = Wscript.Arguments
Set objShell = CreateObject("Wscript.Shell")
htmPath = Wscript.Arguments.Item(0)
personalWb = objShell.ExpandEnvironmentStrings("%PERSONALWB%")
Set oXl = CreateObject("Excel.Application")