Skip to content

Instantly share code, notes, and snippets.

View gwynolanga's full-sized avatar

Kirill Ilin gwynolanga

  • Batumi, Georgia
  • 04:33 (UTC +04:00)
View GitHub Profile
@malchak
malchak / missing_num_array.rb
Last active September 28, 2020 19:00
Solutions to Find Missing Number in Array.
# Question:
# Suppose you have an array of 99 numbers.
# The array contains the digits 1 to 100 with one digit missing.
# Write four different algorithms to compute the missing number.
# Two of these should optimize for low storage and two of these should optimize for fast processing.
# (Keep in mind, there are no duplicates and the array is not already sorted.)
#######################################################
@joyrexus
joyrexus / README.md
Last active March 22, 2025 12:57 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created July 25, 2012 07:58
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@jordan-brough
jordan-brough / gist:1926410
Created February 27, 2012 19:14
ruby count_by using group_by
# See http://jordan.broughs.net/archives/2012/07/enumerablecount_by-for-ruby
# Ruby >= 1.8.7 (incl 1.9.x)
module Enumerable
def count_by(&block)
Hash[group_by(&block).map { |key,vals| [key, vals.size] }]
end
end
@rstacruz
rstacruz / index.md
Last active April 28, 2025 21:24
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one