Skip to content

Instantly share code, notes, and snippets.

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

Trevor Linton trevorlinton

👨‍👩‍👧‍👦
View GitHub Profile
@trevorlinton
trevorlinton / node_in_osx_main.mm
Last active February 19, 2020 19:01
Integrating node's event loop safely into CFRunLoop OSX (uvcf goes to 100% cpu after App run)
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#include "node.h"
#include "v8_typed_array.h"
#include "CoreFoundation/CoreFoundation.h"
static int init_argc;
static char **init_argv;
@interface AppDelegate : NSObject <NSApplicationDelegate>
@trevorlinton
trevorlinton / tint2_example.js
Created July 9, 2014 05:22
Tint2 Web Browser Example
application.addEventListener('launch', function() {
var win = new Window(800,600);
win.title = "My web browser, probably should add a status bar...";
var web = new WebView(win);
web.addEventListener('load', function() {
console.log('We may load this, unsure yet, nothing has been received but the request for: '+web.location);
});
web.addEventListener('request', function() {
console.log('Weve received a request and may go parse it out, last chance to cancel.');
@trevorlinton
trevorlinton / wpfbrowserex.cpp
Last active August 29, 2015 14:13
Rendering Content over WPF WebControl
#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>
@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
@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 / 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

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 / README.md
Last active August 20, 2024 14:00
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

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 / 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/[email protected]
[copy in main.go]
go build main.go