Skip to content

Instantly share code, notes, and snippets.

View cschamp's full-sized avatar

Craig Schamp cschamp

  • Boise, Idaho
  • 17:41 (UTC -06:00)
View GitHub Profile
@cschamp
cschamp / iperf.txt
Last active November 21, 2016 16:07
iperf results on AT&T GigaPower NAT'd behind Pace 5268AC
[craig@fsociety] ~ % iperf3 -c iperf.he.net
Connecting to host iperf.he.net, port 5201
[ 6] local 2602:306:b894:1b10:11c1:e51:778:c258 port 51273 connected to 2001:470:0:238::2 port 5201
[ ID] Interval Transfer Bandwidth
[ 6] 0.00-1.00 sec 81.7 MBytes 685 Mbits/sec
[ 6] 1.00-2.00 sec 96.3 MBytes 808 Mbits/sec
[ 6] 2.00-3.00 sec 101 MBytes 849 Mbits/sec
[ 6] 3.00-4.00 sec 104 MBytes 874 Mbits/sec
[ 6] 4.00-5.00 sec 106 MBytes 885 Mbits/sec
[ 6] 5.00-6.00 sec 88.5 MBytes 742 Mbits/sec
@cschamp
cschamp / stackval.cc
Last active August 24, 2016 18:44
phone interview question and solution
// Question. Given this class, write code to return the max value on the stack
class Stack
{
public:
void push(int a); //<-- O(1)
int pop(); //<-- O(1), pop can throw if stack is empty
int top(); //<--- O(1), throws if stack is empty
bool is_empty(); //<--- O(1)
};
@cschamp
cschamp / threads.txt
Last active June 2, 2025 11:09
Threads and global - Pure Storage on-site interview question for an engineering management position.
int global = 0;
void t()
{
for (int i = 0; i < 5; i++)
global++;
}
main()
{
for (int i = 0; i < 5; i++)
@cschamp
cschamp / nbits.c
Last active June 7, 2016 19:06
This is a solution that an interview candidate gave when I asked him to write a function to count the number of 1-bits set in a byte. The interview was for a position at Nimble Storage.
#include <stdio.h>
#include <stdlib.h>
int nbits(unsigned char value);
int testtab[] = {
0x53,
0xaa,
0x55,
0x01,
@cschamp
cschamp / iview.cpp
Created October 25, 2011 21:12
Find endianness
#include <iostream>
using namespace std;
namespace {
bool A = false;
bool B = false;
struct C {
/* Base64_EncodeLength: Returns the maximum number of bytes that 'src'
will be encoded to (not including any NULL-termination). Cannot fail. */
int
Base64_EncodedLength(const uint8 *src, uint32 srclength);
/* Base64_Encode: Encoded 'src' into 'target'. Does not NULL-terminate. Returns
the size of the encoded string on success or -1 on failure. Behavior undefined
if 'srclength' is 0. */
/*
* int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
* o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
*/
int i;
main()
{
for(; i["]<i;++i){--i;}"]; read('-'-'-',i+++"hello, world!\n",'/'/'/'))
if [[ $OSTYPE == darwin* ]] ; then PCOLOR=yellow
else PCOLOR=red
fi
PROMPT="%{$fg_no_bold[green]%}%24<..<%~%{$fg_no_bold[default]%} %(2L!%#%#!%#) "
/*
* int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
* o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
*/
int i;
main()
{
for(; i["]<i;++i){--i;}"]; read('-'-'-',i+++"hello, world!\n",'/'/'/'))
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}