Skip to content

Instantly share code, notes, and snippets.


Diego E. Salazar DiegoSalazar

View GitHub Profile
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
Dumber gist uses dumber bundler, the default bundle file
DiegoSalazar / scratch.rb
Last active Feb 3, 2017
Implementation of Floyd's Cycle Detection Algorithm
View scratch.rb
class Node
attr_reader :value
attr_accessor :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
def end?
DiegoSalazar / scratch.rb
Last active May 4, 2017
Linked list reversal solutions
View scratch.rb
# A node of a linked list
class Node
attr_reader :value, :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
def reverse(reversed = nil)
DiegoSalazar / paginatedAutocomplete.js
Created Oct 27, 2016
jQuery UI wrapper over Autocomplete that adds pagination
View paginatedAutocomplete.js
$.widget("paginatedAutocomplete", $.ui.autocomplete, {
options: {
minLength: 1,
sourceUrl: '',
pageSize: 10,
source: function (request, response) {
var self = this;
url: this.options.sourceUrl,

Keybase proof

I hereby claim:

  • I am diegosalazar on github.
  • I am diegosalazar ( on keybase.
  • I have a public key ASCUA8M_jJ9DZRPNgZJY_aOjxwsaAnG8ujhjOTWYTpVTSQo

To claim this, I am signing this object:

DiegoSalazar /
Last active Sep 22, 2016
Prevents accidentally exiting the shell
# Prevent me from accidentally exiting the shell
exit() {
echo "Exit the shell? y/n"
read a
if [ "$a" = "y" ]; then
builtin exit
View convert_hash_to_html.rb
def convert_hash_to_html(data)
html = "<dl>"
data.each do |key, val|
html << "<dt>#{key}</dt>"
if val.is_a? Hash
html << "<dd>#{convert_hash_to_html val}</dd>"
elsif val.is_a? Array
html << "<dd>#{convert_array_to_html val}</dd>"
DiegoSalazar / fibber.rb
Created Jul 2, 2016
Memoized Fibonacci in Ruby
View fibber.rb
# memoized fibonacci in Ruby
class Fibber
attr_accessor :hash
def initialize
@hash = {}
def memo_fib(n)
for number in 0..n
if number < 2
@hash[number] = number
DiegoSalazar / pre-commit
Created Jun 15, 2016
git pre-commit hook to block changes containing the string debug in a ruby comment
View pre-commit
. git-sh-setup # for die
git-diff-index -p -M --cached HEAD -- | grep '^+' | grep -n '# debug' && die 'Blocking commit: debug detected in code'
DiegoSalazar /
Created May 24, 2016
Reload the last selected tab based on the window hash
$.fn.rememberSelectedTab = (tabSelector = "aria_controls")->
selectedTab = window.location.hash.replace "#", ""
if selectedTab && selectedTab != ""
@each ->
$(@).find("ul.nav-tabs li").click ->
name = $(@).find("a").attr tabSelector
window.location.hash = name
You can’t perform that action at this time.