Skip to content

Instantly share code, notes, and snippets.

View koleksiuk's full-sized avatar
🦀
Ship!

Konrad Oleksiuk koleksiuk

🦀
Ship!
View GitHub Profile
require 'dentaku'
class ExtendedCalculator < Dentaku::Calculator
def initialize(*args)
super
add_exponent
end
private
class Message
class Starred
attr_accessor :user, :message
InvalidUserError = Class.new(StandardError)
def initialize(user, message)
self.user = user
self.message = message
.btn-warning {
background-color: #faa732;
background-image: -moz-linear-gradient(top, #fbb450, #f89406);
background-image: -ms-linear-gradient(top, #fbb450, #f89406);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
background-image: -o-linear-gradient(top, #fbb450, #f89406);
background-image: linear-gradient(top, #fbb450, #f89406);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0);
class Fraction
@numerator, @denominator = 0,0
def initialize(n = 0,d = 0)
@numerator, @denominator = n, d
end
def read
@numerator, @denominator = gets.chomp, gets.chomp
end
def write
puts "#{@numerator} / #{@denominator}"
function Test() {
this.nazwa = "test";
}
Test.prototype.a = function() {
console.log(this.nazwa);
return "lol";
}
Test.prototype.b = function() {
module Models
module DateScope
extend ActiveSupport::Concern
included do
default_scope order('date_start ASC')
end
module ClassMethods
#== Some more methods
class Complex
def initialize(_re = 0.0, _im = 0.0)
self.re = _re
self.im = _im
end
def +(val)
Complex.new(self.re + val.re, self.im + val.im)
end
class Queue
def initialize(val)
@head = Container.new(val)
end
def add(val)
temp = Container.new(val)
head = @head
loop do
break unless head.next
def isAnagramOfPalindrome (s)
return 0 if s.length < 2 # no need to check 1 or 0 character words
# # returns letters in hash
# f.e. "aabcba" ===> {"c"=>["c"], "b"=>["b", "b"], "a"=>["a", "a", "a"]}
letters = s.split("").group_by{|x| x}
# selects these arrays where size is odd and checks if it's empty
return 1 if letters.select{|key,value| value.length % 2 != 0 }.empty?
return 0 # return for clarity
class Array
def selection_sort
(0...length).each do |i|
min = i
(i+1...length).each do |j|
min = j if self[j] < self[i]
end
self[i], self[min] = self[min], self[i]
end