Skip to content

Instantly share code, notes, and snippets.

@yitznewton
yitznewton / Dockerfile.jenkins
Created September 23, 2022 18:32
Dockerfile.jenkins
# At cppdh/jenkins:latest
FROM jenkins/jenkins:latest
USER root
RUN apt-get update && apt-get install -y awscli ruby
USER jenkins
@yitznewton
yitznewton / fluent_stub.php
Created July 8, 2022 04:10
Stub for fluent interface
<?php
class Stub
{
private array $stubMethods = [];
public function stubMethodChain(array $chain, \Closure $callback): void
{
if (count($chain) === 0) {
return;
@yitznewton
yitznewton / timezones.yml
Last active June 29, 2022 17:51
Time zones
---
- region: North America
zones:
- common_name: Hawaii Standard Time
core_offset: -10
identifiers: [Pacific/Honolulu]
- common_name: Alaska Time
core_offset: -9
identifiers: [America/Anchorage]
- common_name: Pacific Time
@yitznewton
yitznewton / phpinfo_passwords_redacted.php
Created November 22, 2021 15:34
phpinfo() with passwords redacted
<?php
// outputs phpinfo() with passwords redacted
ob_start();
phpinfo();
$phpinfoString = ob_get_clean();
$phpinfoDom = new DOMDocument();
$phpinfoDom->loadHTML($phpinfoString);
$x = new DOMXPath($phpinfoDom);
$passwordCells = $x->query('//td[@class="e" and (contains(., "PASSWORD") or contains(., "password"))]/../td[@class="v"]');
@yitznewton
yitznewton / product_dev_tools.md
Last active December 28, 2020 23:54
Software development tracking tools

Has promise

  • Kanban Flow

Meh

  • Pivotal Tracker
  • Kanbanize - maybe
  • ClickUp - doesn't seem to have the right focus of metrics; similar to Pivotal?
  • Sprintly
  • Rally - too huge
@yitznewton
yitznewton / heroku_k12.sh
Last active February 17, 2020 15:51
Heroku H12 errors from API
#!/bin/bash
errors_for_date () {
START_DATE=$1
END_DATE=$2
echo $START_DATE $END_DATE
curl "https://api.metrics.heroku.com/metrics/1df0f834-36ae-4f6c-8acb-4e1ec975e166/router/errors?process_type=web&start_time=${START_DATE}T16%3A00%3A00.000Z&end_time=${END_DATE}T16%3A00%3A00.000Z&step=1440m&region=" \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0' \
-H 'Accept: application/vnd.heroku+json; version=3.monitoring-events' -H 'Accept-Language: en-US,en;q=0.5' \
-s --compressed -H 'Referer: https://dashboard.heroku.com/' -H 'X-Origin: https://dashboard.heroku.com' \
@yitznewton
yitznewton / rubocop_exclusions.rb
Created January 23, 2020 14:52
Rubocop exclusion detector
require 'pathname'
require 'yaml'
def exclusions(config, directory)
config.flat_map do |k,v|
if k == 'Exclude'
v.map { |file_name| Dir.glob(directory.join(file_name)) }
elsif v.is_a?(Hash)
exclusions(v, directory)
else
let datetime = (date) => {
return [
date.getMonth() + 1,
'/',
date.getDate(),
'/',
date.getFullYear(),
' ',
date.getHours(),
':',
@yitznewton
yitznewton / pay_geo.rb
Last active March 23, 2018 15:54
Find pay centers
require 'active_support'
require 'active_support/core_ext'
require 'kmeans-clusterer'
def median(array)
sorted = array.sort
len = sorted.length
(sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
end
@yitznewton
yitznewton / linked_list.js
Created July 8, 2015 18:58
Linked List Kata
// $ brew install node
// $ npm init
// $ npm install -S mocha chai sinon
//
// $ npm test
var sinon = require("sinon");
var expect = require("chai").expect;
var LinkedList = function() {