Skip to content

Instantly share code, notes, and snippets.

View JadedEvan's full-sized avatar

Evan Reeves JadedEvan

View GitHub Profile
@JadedEvan
JadedEvan / jira-story-point-count.js
Created October 13, 2020 09:31
Javascript snippet to add up the total of story points for a Jira issue search
var total=0;$('#issuetable .issuerow .customfield_10025').each(function(index){if(this.innerText != ''){total += parseInt(this.innerText)}});console.log(total);
@JadedEvan
JadedEvan / git-merge-single-file.sh
Last active October 21, 2016 15:04
How to revert a file to a known working state and apply upstream changes in a patch from a different branch.
# Check out the original file should receive the changes. This should be the version on your working branch
git checkout {MY-WORKING-BRANCH-SHA} -- path/to/my/file.txt
# Generate a diff of the file, ignoring space changes against a known branch. You should be on your working branch for this
git checkout my-working-branch
git diff HEAD..master --ignore-space-change -- path/to/my/file.txt > patch.diff
# Apply the patch. Note that you MUST use the same --ignore-space-change flag to apply properly
git apply --ignore-space-change patch.diff
@JadedEvan
JadedEvan / cloudformation-gnip-kinesis-connector.json
Created July 16, 2015 18:08
Amazon CloudFormation script to create a new EC2 server that runs the GNIP "sample-kinesis-connector" java application. This can be used to read incoming data from GNIP stream and push it over to Amazon Kinesis. GNIP pulled support for the Public AMI in the Amazon Marketplace, so here's one that will take you most of the way.
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description": "Create EC2 instance to run a GNIP Kinesis connector. Creates CloudWatch alarms when 85% stream capacity reached.",
"Parameters" : {
"Environment" : {
"Type": "String",
"Description": "Environment in which to run",
"AllowedValues": ["production", "development"]
},
"InstanceTerminationProtection": {
@JadedEvan
JadedEvan / TUTORIAL-ruby-instance-methods-versus-attribute-accessors.md
Last active July 20, 2016 16:54
An article highlighting the difference in using instance methods over attribute accessors in Ruby classes. A fundamental concept that is often overlooked by beginner and intermediate Rubyists that can lead to cleaner, more predictable code

Ruby Design Patterns - Methods over Attributes

Overview

The objective of this article is to highlight the subtle differences between using class attributes and class methods in Ruby. Both offer a valid way to manipulate the state of an instance of a class. Things can get increasingly complex, hard to test and hard to maintain as more instance variables are introduced. Beginner and intermediate Rubyists often miss this subtle but important point which can introduce bugs that may be hard to fix in their native habitat.

The reasons I prefer to use methods over instance variables:

  • Increases predictability of method calls
  • Increases predictability when testing
@JadedEvan
JadedEvan / HOWTO-openssl.md
Last active March 1, 2017 21:39
Various openssl commands

Self Signed Certificate

Generate a new RSA key of 4096 bits. Adding the -des3 (or any other cipher) requires that the key have a password issued:

openssl genrsa -out server.key 2048

Generate a new CSR (Certificate Signed Request)

openssl req -new -key server.key -out server.csr
@JadedEvan
JadedEvan / git-notes.mdown
Created July 25, 2012 17:23
Library of useful git commands

Git Notes

Merge Two Branches in seperate repos

I have two independent repositories (A and B) and would like to merge one repo. (B) into another one (A) with keeping the whole history of both. What do to?

% cd projectA
% git remote add test ../path/to/other/repo && git fetch test

Adds a new branch called test which pulls in ALL branches from the /other/repo. git fetch test pulls code for all branches

@JadedEvan
JadedEvan / unix-cli-tips.md
Last active December 12, 2019 06:41
UNIX Tips - a catalog of useful UNIX commands

find commands

find . -regextype posix-egrep -regex ".*(rb|js)$"

Find all files ending in .rb or .js.

find . -name "*js" -o -name "*rb"

Same as above, not using regular expressions.

@JadedEvan
JadedEvan / vim-notes.mdown
Created September 22, 2011 18:24
Vim Tips - a catalog of useful Vim commands

Buffer Settings

:set scrolloffset=30
:set scrolloffset=999
:set so=0

Sets the offset when scrolling through a document. A value of 30 will keep a marginal amount of space while scrolling, a value of 999 will keep the cursor centered in the screen, a value of 0 restores Vim's default behavior. All of the above can be added to your ~/.vimrc file to set editor defaults. Vim wikia - scroll centering

Additional buffer settings

class Numeric
def ordinal
self.to_s + ( (10...20).include?(self) ? 'th' : %w{ th st nd rd th th th th th th }[self % 10] )
end
end
@JadedEvan
JadedEvan / chars_remaining.js
Created June 21, 2010 18:05
Javascript onkeup() function that prevents entering more than X characters
function charsRemaining(evt, counterID, max) {
var chars = evt.getValue();
if (chars.length == 1 && chars[0] == '') { chars = []; }
var remaining = max - chars.length;
var counter = document.getElementById(counterID);
if (remaining >= 0) {
if(counter) counter.setTextValue(remaining + ' characters remaining');
}
else {
evt.setValue(evt.getValue().substr(0, max));