Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / scr.cob
Created October 30, 2016 16:33
Creating a COBOL screen
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-ATX.
OBJECT-COMPUTER. IBM-ATX.
SPECIAL-NAMES.
@blippy
blippy / v3-v4.cob
Created October 29, 2016 19:44
In one version, out the other.
001000 IDENTIFICATION DIVISION.
* 2016-10-29 created by mcarter
* convert version3 to version 4
001010 PROGRAM-ID. v3-v4.
002000 ENVIRONMENT DIVISION.
002010 INPUT-OUTPUT SECTION.
FILE-CONTROL.
select fd-in assign to ws-fd-in-name 12
organisation is line sequential.
@blippy
blippy / str2char.cc
Last active October 25, 2016 13:26
Convert a const string to (nonconst) char *
vector<char> v(str.begin(), str.end());
v.push_back(0);
char *str = &v[0];
@blippy
blippy / dec.cc
Created October 21, 2016 15:56
C++ decimal arithmetic
#include <iostream>
#include <decimal/decimal>
using std::cout;
using std::endl;
template<typename T>
void print(T d)
{
cout << std::decimal::decimal_to_double(d) << endl;
@blippy
blippy / ydec
Last active June 19, 2016 12:22
Download a decade's worth of yahoo data
#!/usr/bin/env bash
# download a decade's worth of Yahoo data
# Specify symbol (e.g. VOD.L) in first argument
#echo "$d0" | awk -v T=0 '
dfield () {
echo "$1" | awk -v T="$2" '
@blippy
blippy / xpro.scm
Created June 16, 2016 11:14
Gimp cross-processing
;;; Copyright (c) 2011 Cardinal Peak
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining a copy
;;; of this software and associated documentation files (the "Software"), to deal
;;; in the Software without restriction, including without limitation the rights
;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;;; copies of the Software, and to permit persons to whom the Software is
;;; furnished to do so, subject to the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be included in
@blippy
blippy / thread.rs
Created June 16, 2016 08:25
Simple threads in rust
//#![feature(old_io)]
use std::thread;
use std::old_io::timer;
use std::time::duration::Duration;
fn main() {
let vin = vec![1.4f64, 1.2f64, 1.5f64];
let mut guards = Vec::with_capacity(3);
for i in 0..3 {
@blippy
blippy / ctlbr.cc
Created June 14, 2016 13:47
COBOL-style contraol breaks in C++
#include <functional>
#include <stdlib.h>
#include <iostream>
#include <vector>
template <class T>
class breaker {
public:
@blippy
blippy / mca-yfetch.sh
Created June 11, 2016 10:42
Fetch a bunch of tickers, including USD
#!/usr/bin/env bash
w=$HOME/.mca/work
s1=$w/s1
cd $w/s2
# dollar exchange rate
url="http://download.finance.yahoo.com/d/quotes.csv?s=USDGBP=X&f=nl1d1t1"
curl -s -L $url > usd.csv &
@blippy
blippy / time.cc
Created June 11, 2016 10:08
Format date and time
#include <ctime>
void printtime()
{
std::time_t t = std::time(nullptr);
char buffer[80];
strftime(buffer, 80, "%Y-%m-%d", std::localtime(&t));
std::cout << "*" << buffer << "*\n" ; // *2016-06-11*
strftime(buffer, 80, "%H:%M:%S", std::localtime(&t));
std::cout << "*" << buffer << "*\n" ; // *11:05:08*