Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Stewart Park stewartpark

🏠
Working from home
Block or report user

Report or block stewartpark

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stewartpark
stewartpark / xor.py
Created Oct 12, 2015
Simple XOR learning with keras
View xor.py
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD
import numpy as np
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([[0],[1],[1],[0]])
model = Sequential()
model.add(Dense(8, input_dim=2))
@stewartpark
stewartpark / chatbot.py
Last active Sep 12, 2019
A very simple/naive chatbot implementation with GPT-2
View chatbot.py
import gpt_2_simple as gpt2
import os
# model_name = '124M'
# model_name = '355M'
model_name = '774M'
if not os.path.exists('models/' + model_name):
gpt2.download_gpt2(model_name=model_name)
View keybase.md

Keybase proof

I hereby claim:

  • I am stewartpark on github.
  • I am stewartpark (https://keybase.io/stewartpark) on keybase.
  • I have a public key ASAmU77qRuCUZm4za1N7322wqNYO3bVH97qH-8PeDCueIgo

To claim this, I am signing this object:

@stewartpark
stewartpark / README.md
Created Jun 15, 2019
Kubernetes-enabled Drone CI job/namespace cleaner
View README.md

Kubernetes-enabled Drone CI currently has two problems.

  1. Cleaning up jobs is dependent on TTL, which is not enabled by default in most Kubernetes clusters.
  1. For each app's pipelines, it creates a namespace. Which is really nice, but sometimes it creates forever terminating namespaces.

You also have to give it the right authorization on a RBAC-enabled cluster. I don't recommend using this on a production cluster. Probably waiting for Drone CI to mature is a better idea.

@stewartpark
stewartpark / oom-killer.yml
Last active Aug 9, 2019
Userspace Early OOM Killer for Kubernetes Nodes
View oom-killer.yml
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: oom-killer
namespace: kube-system
labels:
k8s-app: oom-killer
spec:
selector:
View git-server.py
#!/usr/bin/env python
# This is an example Git server. http://blog.nerds.kr/post/106956608369/implementing-a-git-http-server-in-python
# Stewart Park <stewartpark92@gmail.com>
from flask import Flask, make_response, request, abort
from StringIO import StringIO
from dulwich.pack import PackStreamReader
import subprocess, os.path
from flask.ext.httpauth import HTTPBasicAuth
View kill-ns.sh
#!/bin/bash
###############################################################################
# Copyright (c) 2018 Red Hat Inc
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
@stewartpark
stewartpark / ruby_migrator.rb
Created Jun 20, 2018
Quick and dirty Ruby lexer/parser/rewriter to make the rails 5 migration easier
View ruby_migrator.rb
#!/usr/bin/env ruby
##
# Quick and dirty ruby lexer
class RubyLexer
TOKENS = {
identifier: /\A[@a-zA-Z_][a-zA-Z_0-9]*/m,
symbol: /\A:[a-zA-Z0-9_]+/m,
string: /\A"([^"]|\\.)*"|\A'([^']|\\.)*'/,
shellout_literal: /\A`([^`\\]|\\.)*`/m,
@stewartpark
stewartpark / reval
Last active Jun 12, 2018
Play with a running ruby process safely
View reval
#!/usr/bin/env bash
#
# ./reval "pid" "ruby code"
rm /tmp/ruby.out 2> /dev/null
expr=$(echo $2 | base64)
(
echo "set breakpoint pending on";
echo "tb rb_funcallv"
echo "commands"
@stewartpark
stewartpark / fetch-random-error.patch
Created May 23, 2018
A patch to `node-fetch` to cause random errors
View fetch-random-error.patch
--- node_modules/node-fetch/lib/index.js 2018-03-25 13:54:59.000000000 -0700
+++ node_modules/node-fetch/lib/index.patched.js 2018-05-23 13:51:07.000000000 -0700
@@ -249,6 +249,9 @@
return consumeBody.call(this).then(function (buffer) {
try {
+ if(Math.random() < 0.1) {
+ return Body.Promise.reject(new FetchError('random error raised as a test'));
+ }
return JSON.parse(buffer.toString());
You can’t perform that action at this time.