Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Livesay alivesay

View GitHub Profile
View spiral.c
inline bool contains(int x, int y, Bounds rect) {
return (x <= rect.right) && (y <= rect.bottom) && (x >= rect.left) && (y >= rect.top);
}
void BuildStringFromMatrix(int* Matrix, int NumRows, int NumColumns, char* OutBuffer) {
Bounds rect = { NumColumns - 1 , NumRows - 1, 0, 0 };
int dir = 0;
int count = 0;
int x = 0;
View itoa.cc
inline int abs(int n) { return (n < 0) ? -n : n; }
char* itoa(int Value, int Base) {
static const char lookup[] = "0123456789ABCDEF";
static const size_t bufferSize = 65;
static char buf[bufferSize] = {0};
int i = bufferSize - 1;
int n = Value;
do {
View eggdropping.cc
template <typename T>
T worstCase(T p_psxCount, T p_floorCount) {
Cache<T> cache;
auto min = [](T a, T b) { return (a < b) ? a : b; };
auto max = [](T a, T b) { return (a > b) ? a : b; };
auto memo_W = [&cache](T n, T k, auto &&W) {
return (cache.count({n,k}) > 0) ? cache[{n,k}] : cache[{n,k}] = W(n,k,W);
};
View bridge.c
int timeToCrossBridge(int* party, int partySize) {
if (partySize == 1) return party[0]; // 1 torch, 1 guy, no problem
if (partySize == 2) return party[1]; // easy
if (partySize < 1) return -1; // no party :(
int *p = &party[partySize - 1]; // p moves backwards from slowest
int *fastest = &party[0];
int *nextFastest = &party[1];
int time = 0;
int slowest = 0;
View gist:52cafba907e72e96d2845fb8c0d0c911
MGET /data
Header: PAGE=0 <-- OK 209 {data:PAGE=0, TOTAL=3}
MGET /data
Header: PAGE=1 <-- OK 209 {data:PAGE=1, TOTAL=3}
MGET /data
Header: PAGE=2 <-- OK 200 {data:PAGE=2, TOTAL=3}
View call.json
"resource": "/catalog/item",
"key": "130047:1:2",
"fields":{
"bib":{
"resource": "/catalog/bib",
"key": "130047"
},
"call":{
"resource": "/catalog/call",
View gist:b87dfa47fbbfd591db00018ce3c50d67
1 import React, { Component } from 'react';
2
3 function handleErrors(response) {
4 if (!response.ok) {
5 throw Error(response.statusText);
6 }
7 return response;
8 }
9
10
View gist:7cb0d7353ce6b54df405051f37f3cdb7
/home/alivesay/.gvm/pkgsets/go1.11.1/proficy:/home/alivesay/go:/home/alivesay/.gvm/pkgsets/go1.11.1/global
View gist:f723244b57708ec8c513b7935d90b300
$ go build
unexpected directory layout:
import path: github.com/go-chi/chi
root: /home/alivesay/go/src
dir: /home/alivesay/go/src/github.com/alivesay/proficy/vendor/github.com/go-chi/chi
expand root: /home/alivesay/go/src
expand dir: /home/alivesay/go/src/github.com/alivesay/proficy/vendor/github.com/go-chi/chi
separator: /