Skip to content

Instantly share code, notes, and snippets.

View trevorlinton's full-sized avatar
👨‍👩‍👧‍👦

Trevor Linton trevorlinton

👨‍👩‍👧‍👦
View GitHub Profile
@trevorlinton
trevorlinton / README.md
Created May 15, 2020 20:16
Great programming challenges

Build a pagination (e.g., 1,2,4,...)

  1. For any amount of items
  2. Variable amount of items on each page
  3. Show at maximum 11 items in the pagination. (Use ... to summarize missing items).
  4. Must have a previous button that always shows (that's disabled if nothing is previous)
  5. Always show the next button that always shows (that's disabled if nothing is next)
  6. Always show the first and second page (if they're available)
  7. Always show the last page and second to last page (if they're available)
  8. Always show the page before the current page (if its available)
  9. Always show hte page after the current page (if its available)

Akkeris

Individual Contributor License Agreement ("Agreement") v1.0

Thank you for your interest in the Akkeris. In order to clarify the intellectual property license granted with Contributions from any person or entity, we ust have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of Akkeris and its users; it does not change your rights to use your own Contributions for any other purpose.

You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Akkeris. In return, the Akkeris shall not use Your Contributions in a way that is contrary to the public benefit or inconsistent with the spirit of open source initiatives. Except for the license granted herein to Akkeris and recipients of software distributed by Akkeris, You reserve all right, title, and interest in and to Your Contributions.

@trevorlinton
trevorlinton / jwks.json
Last active September 20, 2019 04:52
Test JWKS
{
"alg": "RS256",
"kty": "RSA",
"use": "sig",
"n": "toC1Xe0FZZC6P9ADCbskb-OkynP92SIiu9j7dBVLc7vJ19q-7hxIAJDhluMx_ws33b51UM2Uk2JfPcElYoOQmsXj2OYmCx5vmucyHFb7KlakPZYNFPE25yHJ_2XY-HAtDEIjEnMhHnVsEZdliZTziXW7Bmgtj-yIfcKkSkC0M10C8YH37nh4Ny_ZeuxWuAh0lmKlb5RPKbPYGcp2qFaUrSCuytW19ivNpxBLLLfeZOUoCfQWjbuH6KuZth61cQ8M3LpZ821YAv3PARW7Bo-vFc2CidOd-Ubac6yqGV_pEtO5_GL7foECm1nCBlRJejCtnySHHkNWD3jnE0enFIDfiQ",
"e": "AQAB",
"kid": "G3EnbZXTmjxLv6_vfmDDzx7VSDDxkvLsQv6zInguH9U"
}
@trevorlinton
trevorlinton / creating-kubernetes-client.md
Created July 19, 2019 17:29
Create kubernetes client

To compile run:

mkdir [project]
cd [project]
export GO111MODULE=on
go mod init
go get k8s.io/client-go@v12.0.0
[copy in main.go]
go build main.go

Find all objects in a namespace (even custom resources)

function kubectlgetall {
  for i in $(kubectl api-resources --verbs=list --namespaced -o name | grep -v "events.events.k8s.io" | grep -v "events" | sort | uniq); do
    echo "Resource:" $i
    kubectl -n ${1} get --ignore-not-found ${i}
  done
}
@trevorlinton
trevorlinton / README.md
Last active March 7, 2024 21:09
Signing your commits on Github

OSX Steps:

  1. Install gpg if you dont have it.
brew install gpg
  1. See what email address and name you're using for git
git config --global user.email

Using Github with Two Factor Auth.

It's a fairly common complaint that after enabling github two factor authentication that command line utilities stop working. The underlying issue is command line utilities send your username and password with each request to github, using two factor authentication disables github from accepting just your username and password, so your command line utilities such as git appear to stop working. Github will still accept a personal access token instead of your password however.

Re-enabling your command line utilities (OSX)

@trevorlinton
trevorlinton / on being a good programmer.md
Last active September 27, 2019 00:05
On being a good programmer.
  1. Your code will fail, no really, with 100% reliability. Only those who plan for failure don't become subjected to it when it occurs. Why? It's a so-called-mental-modal, when you're programming, believing your code will fail, and it will, often causes you to place better error handling, assertions or write unit tests to help diagnose a failure, not prevent it. Some of the nastiest bugs in the world are those which are not reliabily reproducable, or hard to track down the CAUSE of the bug. You'll find yourself spinning your wheels for weeks if you don't plan for how you will debug problems.
  2. Use assertions on all inputs to a function/method to check the semantics and validity (or, type, if javascript). Doesn't really matter how trivial the assertion is. And it doesn't matter how small the code base, it could grow. Why? When errors occur, they don't propogate the error, this makes it infinitely easier to find the source of the problem, rather than backtracing from some side effect bad input cause
@trevorlinton
trevorlinton / main.cpp
Created April 1, 2015 04:14
Hacking on IWebBrowser and DirectX
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <vcclr.h>
#include <windows.h>
#include <mmsystem.h>
#include <msclr/marshal.h>
#include <msclr/marshal_cppstd.h>
#include <d3d9.h>
//#include <dispex.h>
@trevorlinton
trevorlinton / Generating Code Statistics.md
Last active August 29, 2015 14:17
Generate code statistics (Java/JSF/Scala)

Generating Pressure Stats

These can be useful statistics (along with other static analysis tools) to see what types of pressure a class within Java or Scala is under. This will also search for xhtml/includes to measure on JSF the inclusion rate for XHTML files. This is implemented as a simple bash script that outputs a JSON file:

java_class_use.sh

#!/bin/sh
if [ "$1" == "" ]; then
  echo "java_class_use.sh directory"
 exit 1