Skip to content

Instantly share code, notes, and snippets.

@eric1234
eric1234 / me.json
Created August 15, 2016 15:49
Me in JSON format
{
"name": {
"first": "Eric",
"last": "Anderson"
},
"title": ["Owner", "Programmer"],
"email": "eric@pixelwareinc.com",
"phone": "404-290-8411",
"company": {
"name": "Pixelware, LLC",
@eric1234
eric1234 / README.md
Last active July 5, 2016 20:48
Experiment in a Localized Extension

Sometimes I want to extend a core object to keep things object oriented but I want to limit the scope of my extension. Refinements provide a nice solution to that but for a single method extension I find it a bit bulky. Here is some standard syntax:

class SomeObject

  module Extension
    refine Array do
 def average
@eric1234
eric1234 / README.md
Last active November 13, 2018 12:02
Modified radio buttons so they are allowed to be unchecked

Include this script and all your radio buttons can be unchecked. The result is the radio box group goes back to a state where no radio is checked. Sort of a cross between a radio button and a checkbox. This means your backend should be prepared for that field to be empty even if you populated it when the page was loaded.

This script assumes it is operating in a Turbolinks environment as it initializes using the page:change event. If you are not using Turbolinks you will want to change it to use the jQuery ready event.

@eric1234
eric1234 / README.md
Last active December 12, 2015 01:10
Protect data from being lost in form edit on navigation

Based on http://stackoverflow.com/a/11844403/120067 but with the following enhancements:

  • It is coffeescript which IMHO automatically makes it better. :)
  • It is entirely based on event bubbling so dynamic content is automatically handled (@AlphaMale's update also has this).
  • It only operates on POST forms as GET forms do not have data we typically want to avoid loosing (i.e. GET forms tend to be search boxes and filtering criteria).
  • It doesn't need to be bound to a specific button for carrying out the save. Anytime the form is submitted we assume that submission is saving.
  • It is Turbolinks compatible. If you don't need that just drop the two page: event bindings.
  • It is designed so that you can just include it with the rest of your JS and your entire site will be protected.

Install with gist-dep with:

@eric1234
eric1234 / trello.md
Last active August 7, 2020 21:21
Trello Guidelines

A few quick guidelines on my conventions when using Trello. These are not rules. Trello doesn't enforce a structure allowing each project to adapt to it's needs. But this is a good place to start:

Lists

  • Unquoted - Any card being added to the project which is not in the statement of work and not a bug related to work covered by the statement of work goes here. The goal of this list is to avoid scope creep. If scope is being added we want it to be an explicit decision with an explicit cost estimation. The person creating the card should try to estimate the cost (or get someone to do so for them). The client can then choose to move it to the Todo list if they want to increase the scope. If they choose to hold off for now this list provides an excellent idea source for future rounds of development.
  • Todo - These are tasks that need to be done which are not in active development.
  • In Progress - These are tasks that are actively being worked on by a developer. If you are not actively w
@eric1234
eric1234 / README.md
Last active August 29, 2015 14:10
Fast mass deletion on S3 for Node

Description

This script is conceptually based on s3nuke but with an entirely different implementation. The key differences are:

  • Uses deleteObjects to delete in batches rather than calling a delete for each key.
  • Is implemented in node to take advantage of it's evented IO

Performance

@eric1234
eric1234 / 2.0.0-p0-rbenv.patch
Last active August 29, 2015 14:04 — forked from thescouser89/1.8.7-rbenv.patch
Like the original 1.8.7 patch but for 2.0.0-p0
--- ext/openssl/ossl_pkey_ec.c
+++ ext/openssl/ossl_pkey_ec.c
@@ -762,8 +762,10 @@
method = EC_GFp_mont_method();
} else if (id == s_GFp_nist) {
method = EC_GFp_nist_method();
+#if !defined(OPENSSl_NO_EC2M)
} else if (id == s_GF2m_simple) {
method = EC_GF2m_simple_method();
+#endif
@eric1234
eric1234 / even_height.coffee
Last active August 29, 2015 14:03
Script to force unrelated elements to have the same height. Does not dynamically adjust for changes in content but you can re-run the "apply" function after a data change if you need to allow for changing content.
# https://gist.github.com/eric1234/13501faf7471a45d10be
class @EvenHeight
constructor: (@elements...) -> @apply()
apply: ->
# In case the page doesn't have the elements so we don't have to
# check when calling the constructor.
return if @elements.length == 0
@eric1234
eric1234 / 1.9.2-p320.patch
Last active August 29, 2015 14:02 — forked from thescouser89/1.8.7-rbenv.patch
Like the original 1.8.7 patch but for 1.9.2-p320
--- ext/openssl/ossl_pkey_ec.c
+++ ext/openssl/ossl_pkey_ec.c
@@ -761,8 +761,10 @@ static VALUE ossl_ec_group_initialize(in
method = EC_GFp_mont_method();
} else if (id == s_GFp_nist) {
method = EC_GFp_nist_method();
+#if !defined(OPENSSl_NO_EC2M)
} else if (id == s_GF2m_simple) {
method = EC_GF2m_simple_method();
+#endif
@eric1234
eric1234 / gem_cache.rb
Created May 2, 2014 17:34
Gem.cache polyfill - For running REALLY old Rails applications (1.2.x) under newer versions of RubyGems.
# I put this right after rubygems is loaded in my boot.rb file
def Gem.cache
cache = Object.new
def cache.search name, *requirements
Gem::Specification.find_all_by_name name, *requirements
end
def cache.find *args, &blk
Gem::Specification.all.find *args, &blk
end