Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / Makefile.am
Created December 3, 2016 15:02
Getting swig to work with make distcheck on the neoleo project
# Order of linking of libraries for Motif seems to be important
# I have decided to mandate the use of the Xbae library, rather than
# have it optional.
if UseMotif
GUI = io-motif.c appres.c fallback.c xrdb.c oleo_icon.xpm
GUI_LINK = -lXm -lXt -lXbae -lX11
GUI_DEFINES = -DHAVE_MOTIF
endif
@blippy
blippy / PKGBUILD
Created November 29, 2016 08:58
Test PKGBUILD for neoleo
# Maintainer: Mark Carter <alt.mcarter@gmail.com>
pkgname=neoleo
pkgver=3.0.1
pkgrel=1
pkgdesc="Fork of the GNU oleo lightweight spreadsheet"
arch=('i686' 'x86_64')
url="https://github.com/blippy/neoleo"
license=('GPL')
source=("https://github.com/blippy/neoleo/releases/download/v$pkgver/$pkgname-$pkgver.tar.gz")
md5sums=('802229a004de2c4a4b0efea78355f655')
@blippy
blippy / esql.sqb
Created November 27, 2016 11:39
COBOL embedded SQL example
indentification division.
program-is. esql.
data division.
working-storage section.
exec sql
begin declare section
end-exec.
01 hostvars.
@blippy
blippy / stats.txt
Created November 19, 2016 11:52
orginal stats sources in suckless ptar format
Metadata Encoding: utf-8
Archive Creation Date: 2016-11-19T11:49:57Z
Path: help.txt
Type: Regular File
File Size: 185
User Name: mcarter
User ID: 3003
Group Name: mcarter
Group ID: 4003
@blippy
blippy / toke2.cc
Created November 12, 2016 19:54
Deleted tokenising code
strings multi_split(const string& line, char c)
{
strings result;
std::size_t prev = 0, pos;
while((pos = line.find_first_of(c, prev)) != std::string::npos)
{
if(pos>prev)
result.push_back(line.substr(prev, pos-prev));
prev = pos+1;
}
@blippy
blippy / timer.cc
Created November 12, 2016 19:52
Time sections of code in nanoseconds
#include <chrono>
class Timer
{
public:
Timer() { start(); };
void start() {m_start = std::chrono::high_resolution_clock::now(); };
void stop() {m_stop = std::chrono::high_resolution_clock::now(); };
double nanos() { std::chrono::duration<double> d = m_stop - m_start;
return std::chrono::duration_cast<std::chrono::nanoseconds>(d).count(); };
@blippy
blippy / fmtstr.lisp
Last active November 9, 2016 13:07
Formatting strings to left and right
(defun format-string-left (str width)
(subseq (format nil "~va" width str) 0 width))
;;; (format-string-left "hello" 6) => "hello "
;;; (format-string-left "hello" 4) => "hell"
(defun format-string-right (str width)
(let* ((str1 (format nil "~v@a~a" width " " str))
(len (length str1))
(from (- len width)))
(subseq str1 from )))
@blippy
blippy / percent.sno
Created November 6, 2016 19:41
Calculating percentages using csnobol4
#!/bin/sh
exec snobol4 -b "$0" "$@"
-INCLUDE "/usr/lib/snobol4/1.4.1/bq.sno"
FLOAT = Span('01234567890.')
SPACES = Span(' ')
T = table()
input('readline', 1, , '/home/mcarter/.mcacc/work/s3/epics.rep')
mine readline 'mine' :F(mine)
norm line = readline
@blippy
blippy / spat.sno
Created November 4, 2016 20:07
Simple pattern matching with Snobol4
inp = 'baz,F.bar,go,F.mAgic'
ALPHAS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
myloop inp ('F.' SPAN(ALPHAS)) . hit REM . inp :F(finis)
output = 'Computer says:' hit :(myloop)
finis output = 'Finished'
END
@blippy
blippy / stridx.cob
Created October 31, 2016 10:21
String indexing in COBOL
*> vim: syntax=off
identification division.
program-id. dex.
data division.
working-storage section.
*> 01 my-string occurs 7 times pic x.
01 my-string pic x(7).