Skip to content

Instantly share code, notes, and snippets.

View mjpitz's full-sized avatar
🏳️‍🌈
out and proud

Mya mjpitz

🏳️‍🌈
out and proud
View GitHub Profile
@mjpitz
mjpitz / StickyGithubHeader.js
Last active November 19, 2015 13:49
Make the project banner on a repository page sticky as you scroll down (new ui only)
(function() {
var $ = function(str) {
return document.querySelector(str);
};
var win = window;
var doc = document.documentElement;
var mast = $('#js-repo-pjax-container .pagehead');
var mastTop = mast.offsetTop;
var adjustedMargin = mast.offsetHeight;
@mjpitz
mjpitz / dataUtil.js
Last active June 29, 2018 15:51
Useful data analysis methods for NodeJS.
/**
* @fileoverview Useful data operations for manipulating large sets of data.
*
* I initially wrote this utility for handling the idea-frameworks
* documentation generator where I would group and regroup data into more
* manageable chunks.
*/
var util = require('util');
@mjpitz
mjpitz / di.js
Last active August 29, 2015 14:11
Simple dependency injection using reflection
(function($, undefined) {
var dependencies = {},
instances = {};
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
function stripComments(functionString) {
return functionString.replace(STRIP_COMMENTS, '');
}
var FN_NEW_LINE_REPLACE = /[\s\r\n]+/;
@mjpitz
mjpitz / protobuf-closure.sh
Created September 25, 2014 07:49
Easily create a protobuf plugin for closure objects
#!/bin/bash
############################################################
# First, you must build the library files for the protobuf
# tool. In order to do this, follow the steps below in the
# source directory for protobuf.
#
# 1. ./autogen.sh
# 2. ./configure
# 3. make
#
@mjpitz
mjpitz / GetterSetterVerifier.java
Last active March 7, 2023 17:32
A class that uses reflection to automate the testing of getters and setters.
import com.google.common.base.Defaults;
import com.google.common.collect.Sets;
import javax.annotation.Nonnull;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Set;
@mjpitz
mjpitz / simpleservers.sh
Last active August 29, 2015 13:56
Simple servers for command line. Serve html or php scripts with the following commands.
function servephp() {
local port="${1:-8080}"
open "http://localhost:${port}"
php -S localhost:$port
}
function serve() {
local port="${1:-8000}"
open "http://localhost:${port}"
python -m SimpleHTTPServer "$port"
@mjpitz
mjpitz / ResourceController.java
Created February 6, 2014 17:19
Fully stubbed out REST controller for Spring MVC
package com.example.controllers;
import com.example.models.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;