Skip to content

Instantly share code, notes, and snippets.

//
// Code fragment based on http://stackoverflow.com/q/11515064/827263
//
int main()
{
cout << "Do you want to add, subtract, multiply or divide? I want to : " << endl;
cin >> ans;
@Keith-S-Thompson
Keith-S-Thompson / highlight
Created September 5, 2012 22:56
highlight command
#!/usr/bin/perl
use strict;
use warnings;
if (scalar @ARGV == 0 or $ARGV[0] eq '-h' or $ARGV[0] eq '-help') {
die "Usage: $0 pattern [file...]\n";
}
my $pattern = shift;
@Keith-S-Thompson
Keith-S-Thompson / .gitignore
Created November 8, 2012 22:29
gnatmake on Ubuntu
hello
hello.ali
hello.o
@Keith-S-Thompson
Keith-S-Thompson / README.md
Created December 3, 2012 20:17
OpenSSL SHA1 demo

In response to this question:

This works correctly for me on Ubuntu, and produces the same output each time I run it.

Compile with:

gcc c.c -lssl -lcrypto -o c

Run with:

@Keith-S-Thompson
Keith-S-Thompson / foo.adb
Created December 13, 2012 19:00
Demo for http://stackoverflow.com/q/13851524/827263 "How to assign all elements but one in ada?"
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Foo is
Element_To_Ignore : Integer := 3;
type Array_Of_Integer is array(Positive Range <>) of Integer;
A : Array_Of_Integer := (5,3,2,6);
B : Array_Of_Integer
:= A(A'First .. Element_To_Ignore-1) &
A(Element_To_Ignore+1 .. A'Last);
#include <stdio.h>
int main(void) {
char c[] = "abcd";
c[0] = 'E';
c[1] = 'F';
c[2] = 'G';
c[3] = 'H';
puts(c);
return 0;
}
@Keith-S-Thompson
Keith-S-Thompson / urandom_test.c
Created February 4, 2013 02:38
Generate random numbers from /dev/urandom
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define MAX 36
#define URANDOM_DEVICE "/dev/urandom"
static FILE *urandom;
/*
@Keith-S-Thompson
Keith-S-Thompson / clc.txt
Created March 26, 2013 19:15
Google Groups quoting ruins comp.lang.c article
From: Myth__Buster <[email protected]>
Subject: Re: Macro for setting MSB - Intended to work on both Little and Big-endian machines
Newsgroups: comp.lang.c
Date: Tue, 26 Mar 2013 11:07:21 -0700 (PDT)
On Tuesday, March 26, 2013 11:36:34 AM UTC-4, Keith Thompson wrote:
> Myth__Buster <[email protected]> writes:
>
> > *was at the LS-bit of LS-byte like on little-endian machine . . .
>