Skip to content

Instantly share code, notes, and snippets.

View richardsondx's full-sized avatar

Richardson Dackam richardsondx

View GitHub Profile

Keybase proof

I hereby claim:

  • I am richardsondx on github.
  • I am richardsondx (https://keybase.io/richardsondx) on keybase.
  • I have a public key ASAbWDn-nbRVwC_v7ul--0bEjDuiQ6JqT-lW8XPJXXineQo

To claim this, I am signing this object:

@richardsondx
richardsondx / inflections.rb
Last active March 18, 2020 06:36
Humanize Method
class String
# ..... some code
#
# See ActiveSupport::Inflector.humanize.
def humanize(capitalize: true, keep_id_suffix: false)
ActiveSupport::Inflector.humanize(self, capitalize: capitalize, keep_id_suffix: keep_id_suffix)
end
# .... more codee
end
@richardsondx
richardsondx / README.md
Last active January 8, 2020 18:42
Util to Flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]

ArrayUtil

I wrote a class with a custom :flatten method in Ruby similar to [1,2,3].flatten This method recursively flatten an Array

Prerequisite

You'll need:

  • ruby
  • minitest
@richardsondx
richardsondx / README.md
Created January 8, 2020 18:39
Util to Flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]

ArrayUtil

I wrote a class with a custom :flatten method in Ruby similar to [1,2,3].flatten This method recursively flatten an Array

Prerequisite

You'll need:

  • ruby
  • minitest
@richardsondx
richardsondx / Gemfile_code_smell.rb
Last active May 19, 2017 20:33
Performance Gemfile & Best Practises Gems
# Code smell
gem 'rubocop'
gem "rubycritic", require: false
gem 'reek'
gem 'simplecov', require: false
gem 'gemsurance'
# Better error page for Rack apps
gem "better_errors"
gem "binding_of_calle"
@richardsondx
richardsondx / gmail.js
Created April 1, 2016 16:13
My app is a chrome extension. (chrome browser). I'm trying to trigger a `SAVE` on the draft in gmail
// compose is the compose window element
// Here I'm clicking the x button on the compose window. But it Doesn't seem to work or trigger a save.
$(compose).find('[aria-label="Save & Close"]').trigger('click');
// select subject to trigger a Save, not sure if that works.
$(compose).find('input[name=subjectbox]').trigger('select');
// Reload Page
$.ajax({
url: window.location.href,
@richardsondx
richardsondx / .jrubyrc
Created March 11, 2016 19:16 — forked from tychobrailleur/.jrubyrc
Sample .jrubyrc, with comments
# Example of .jrubyrc
# Set compilation mode. JIT = at runtime; FORCE = before execution. (JIT, FORCE, OFF, OFFIR)
# compile.mode = FORCE
# Dump to console all bytecode generated at runtime.
# compile.dump = true
# Enable verbose JIT logging (reports failed compilation)
# jit.logging.verbose = true
@richardsondx
richardsondx / gc_overhead_exception.txt
Created March 10, 2016 18:23
Global action exception caught: GC overhead limit exceeded
Global action exception caught: GC overhead limit exceeded; ["java.util.LinkedHashMap.newNode(LinkedHashMap.java:256)", "java.util.HashMap.putVal(HashMap.java:630)", "java.util.HashMap.put(HashMap.java:611)", "java.security.Provider.implPut(Provider.java:832)", "java.security.Provider.put(Provider.java:322)", "org.bouncycastle.jce.provider.BouncyCastleProvider.addAlgorithm(Unknown Source)", "org.bouncycastle.jce.provider.BouncyCastleProvider.addAlgorithm(Unknown Source)", "org.bouncycastle.jcajce.provider.symmetric.AES$Mappings.configure(Unknown Source)", "org.bouncycastle.jce.provider.BouncyCastleProvider.loadAlgorithms(Unknown Source)", "org.bouncycastle.jce.provider.BouncyCastleProvider.setup(Unknown Source)", "org.bouncycastle.jce.provider.BouncyCastleProvider.access$000(Unknown Source)", "org.bouncycastle.jce.provider.BouncyCastleProvider$1.run(Unknown Source)", "java.security.AccessController.doPrivileged(Native Method)", "org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(Unknown Source)", "org.
@richardsondx
richardsondx / java_error.txt
Created March 10, 2016 01:46
Java::JavaLang::OutOfMemoryError (GC overhead limit exceeded):
Java::JavaLang::OutOfMemoryError (GC overhead limit exceeded):
java.lang.Throwable.getStackTraceElement(Native Method)
java.lang.Throwable.getOurStackTrace(Throwable.java:827)
java.lang.Throwable.getStackTrace(Throwable.java:816)
java.lang.Thread.getStackTrace(Thread.java:1552)
org.jruby.RubyKernel.caller20(RubyKernel.java:1041)
org.jruby.RubyKernel$INVOKER$s$0$2$caller20.call(RubyKernel$INVOKER$s$0$2$caller20.gen)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:193)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:189)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:129)
@richardsondx
richardsondx / gzip.rb
Last active April 4, 2017 07:49
Monkey patch to fix Authentication failure! invalid_credentials: OAuth2::Error jruby 8 , rails 3.2.13 devise 3.2.4 | Force faraday to 'uncompressed' gzip
# In Rails, add this to your Initializer/ folder
#
# Fix by @richardsondx - Richardson Dackam
#
# Thi monkey patch is not actually forcing farady to uncompress the response but it's telling it not to compress
# So it forces Faraday to avoid compressing the response.
# The gresponse from google had the header 'accept-encoding': 'gzip'
# unlike http.net, http.request doesn't automatically uncompress gzip request
# more info about http.request at https://github.com/ruby/ruby/blob/ruby_2_2/lib/net/http.rb