Skip to content

Instantly share code, notes, and snippets.

@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 / 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 & ","
@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>
@aptavout
aptavout / natlog.for
Created October 21, 2014 06:48
Calculate natural logarithm
c
c evaluate the natural logarithm e
c
c variables
c 123456 a
c fln the value of the natural logarithm
c iterm the current term in the summation
c next the next number in a factorial operation
c fdenom the value of the current factorial
c
@aptavout
aptavout / tree.c
Created September 23, 2014 05:02
Array-based tree traversal
/* demonstrate tree data structure with multi-dimensional arrays */
/* construct a tree of this form: */
/* 1 */
/* 2 3 */
/* 4 5 6 */
/* as a table, */
/* node children */
/* 1 2 3 */
/* 2 4 5 */