Skip to content

Instantly share code, notes, and snippets.

@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")
@aptavout
aptavout / tdbc::odbc standalone exe
Last active August 29, 2015 14:02
The Holy Grail of small-scale solutions
# a Tcl script to automate builds
# instructions from http://wiki.tcl.tk/11861
# using tclkit.exe and sdx.kit from Google Code
# https://code.google.com/p/tclkit/downloads/list
# *** as well as TWAPI binaries ***
#
# Copy your source files into a work directory !!
#
# usage: tclsh this-script.tcl gui.tcl
#
@aptavout
aptavout / getch.c
Last active August 29, 2015 14:06
One implementation of getchar()
#include <stdio.h>
#define MAXLINE 81 /* MAXLINE = MAXCARD + 1 */
#define MAXCARD 80
#define NEWLINE '\n'
#define BLANK ' '
static int getch_lastc = MAXLINE;
static char getch_buf[MAXLINE];
@aptavout
aptavout / putch.c
Created September 22, 2014 04:26
A fixed-length putchar()
#include <stdio.h>
#define MAXLINE 81 /* MAXLINE = MAXCARD + 1 */
#define MAXCARD 80
#define NEWLINE '\n'
#define BLANK ' '
static int putch_lastc = -1;
static char putch_buf[MAXLINE];
@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 */
@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 / 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%